Problem.....for Drop the ball.
Author |
Message |
spen
|
|
|
|
|
Sponsor Sponsor
|
|
|
Cervantes
|
Posted: Sun Jun 13, 2004 7:24 am Post subject: (No subject) |
|
|
here's how I would do it.
code: |
setscreen ("offscreenonly")
var ball_time := 0
var counter := 1
var x, y, vy : array 1 .. 15 of real
var draw : array 1 .. 15 of boolean
for i : 1 .. 15
x (i) := Rand.Int (0, maxx)
y (i) := maxy
vy (i) := 0
draw (i) := false
end for
const gravity := 0.015
loop
cls
if Time.Elapsed - ball_time >= 1000 then
ball_time := Time.Elapsed
if counter >= 15 then
counter := 1
else
counter += 1
end if
draw (counter) := true
end if
for b : 1 .. 15
if draw (b) then
vy (b) -= gravity
y (b) += vy (b)
drawfilloval (round (x (b)), round (y (b)), 10, 10, black)
if y (b) < 0 then
y (b) := maxy
vy (b) := 0
draw (b) := false
end if
end if
end for
View.Update
delay (10)
end loop
|
note that it would look a bit better if you were to make the balls spawn just a little above maxy, so that the user can't actually see them materialize like they do
|
|
|
|
|
|
spen
|
Posted: Sun Jun 13, 2004 11:32 am Post subject: Thank u~!! |
|
|
Thank u so much~
It's cool~
|
|
|
|
|
|
|
|