Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 KraZy KeePuPs- (Ball, BOUNCE, GRAVITY, MOUSE)
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rhomer




PostPosted: Fri May 28, 2004 11:59 pm   Post subject: KraZy KeePuPs- (Ball, BOUNCE, GRAVITY, MOUSE)

I just made this game and its pretty fun ( i know it sucks)....enjoy!!

code:


setscreen ("offscreenonly")
setscreen ("graphics:600;max")
var ballx : int := maxx div 2
var bally : int := 20
var radius : int := 20
const xdecay := 0.995
const ydecay := 0.99
const gravity := -0.2
var dx, dy : real := 0
var mousex, mousey, button : int := 0
var score : int := 0
var highscore : int := 0
var touching : boolean := false

loop
    Mouse.Where (mousex, mousey, button)
    drawfilloval (ballx, bally, radius, radius, white)
    if button = 1 and Math.Distance (ballx, bally, mousex, mousey) <= 20 and touching = false then
        touching := true
        dy += 8
        dx -= (ballx - mousex) div 2
        score += 1
    else
        touching := false
    end if

if dx <= 1 and dx > -1 and dx not= 0 and bally not= 20 then
        dx += 1
    end if


    ballx += round (dx)
    bally += round (dy)
    dx *= xdecay
    if dy > 1 or bally > 22 then
        dy += gravity
    else
        bally := 20
        if score > highscore then
            highscore := score
        end if
        score := 0
    end if
    dy *= ydecay

    if ballx > maxx - 20 then
        ballx := maxx - 20
        dx *= -xdecay
    elsif ballx < 20 then
        ballx := 20
        dx *= -xdecay
    end if

    Text.Locate (1, maxcol div 2 - 2)
    put round (score / 2), "/   HIGHSCORE = ", highscore
    drawfilloval (ballx, bally, radius, radius, green)
    View.Update
    delay (10)
end loop

Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Sat May 29, 2004 3:49 pm   Post subject: (No subject)

That is fun Razz

I realy like the phiscks in this, realy cool. There is a small typeo in your code at the line:

if dx = < 1 amd dx > -1 and dx not= 0 then

i think you whont it to be:

if dx <= 1 and dx > -1 and dx not= 0 then

so it will acualy complie Wink


Good game +bits.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Catalyst




PostPosted: Sat May 29, 2004 3:52 pm   Post subject: (No subject)

and here
code:

    put round (score / 2), "/   HISHSCORE = ", highscore


should be
code:

    put round (score / 2), "/   HIGHSCORE = ", highscore


otherwise very fun Very Happy
Delta




PostPosted: Sat May 29, 2004 9:45 pm   Post subject: (No subject)

Ok I'm not sure if anyone else had noticed this or just neglected to mention it... but your ball after you hit it continues to move like a crazy animal. (watch for yourself if you don't understand the term crazy animal).
Otherwise it would be kind fun if the ball didn't move away from the mouse when you tried to click it. Stupid ball *shakes fist*
Dan




PostPosted: Sat May 29, 2004 11:43 pm   Post subject: (No subject)

i thougth it was sposted to do that?

also it did not go very crazy when my mouse touched it, just moved slowy to the left or right deponding on what side it touched it from.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
guruguru




PostPosted: Sun May 30, 2004 12:09 am   Post subject: (No subject)

Thats pretty fun. Try getting it to go from side to side... its hard!

The one problem I have (dont take offence :p) is that sometimes you have to wait a while for the ball to fall back down again.
Delta




PostPosted: Sun May 30, 2004 6:09 am   Post subject: (No subject)

I didn't mean that it moves away from the mouse like it was coded that way. I'm hoping it was an accident. Because the ball usually bounces off and then if it takes more than a second or two to come back down then it switches direction. That's not horrible. But when the ball drops and rolls, it just keeps rolling and switching directions on the ground, not cool.
Dan




PostPosted: Sun May 30, 2004 10:41 am   Post subject: (No subject)

Oh i see what you mean now, i think it has somting to do with this line:

code:

    if dx <= 1 and dx > -1 and dx not= 0 then
        dx += 1
    end if


may be chage it to:

code:

    if dx <= 1 and dx > -1 and dx not= 0 and bally not= 20 then
        dx += 1
    end if


seems to make it work better
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: