
-----------------------------------
rhomer
Fri May 28, 2004 11:59 pm

KraZy KeePuPs- (Ball, BOUNCE, GRAVITY, MOUSE)
-----------------------------------
I just made this game and its pretty fun ( i know it sucks)....enjoy!!



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)  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



-----------------------------------
Dan
Sat May 29, 2004 3:49 pm


-----------------------------------
That is fun  :P 

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 not= 0 then

so it will acualy complie  :wink: 


Good game +bits.

-----------------------------------
Catalyst
Sat May 29, 2004 3:52 pm


-----------------------------------
and here 

    put round (score / 2), "/   HISHSCORE = ", highscore 


should be

    put round (score / 2), "/   HIGHSCORE = ", highscore 


otherwise very fun  :D

-----------------------------------
Delta
Sat May 29, 2004 9:45 pm


-----------------------------------
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
Sat May 29, 2004 11:43 pm


-----------------------------------
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.

-----------------------------------
guruguru
Sun May 30, 2004 12:09 am


-----------------------------------
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
Sun May 30, 2004 6:09 am


-----------------------------------
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
Sun May 30, 2004 10:41 am


-----------------------------------
Oh i see what you mean now, i think it has somting to do with this line:


    if dx  -1 and dx not= 0 then
        dx += 1
    end if


may be chage it to:


    if dx  -1 and dx not= 0 and bally not= 20 then
        dx += 1
    end if


seems to make it work better
