Computer Science Canada

Speeding things up

Author:  Pinto2 [ Fri Oct 21, 2005 9:16 am ]
Post subject:  Speeding things up

This isn't the end product, but i'm having trouble seeing why the ball moves at such a rediculous speed.
setscreen ("graphics: max; max")
colourback (black)
cls
var y , direction_of_x, x, direction_of_y: int := 20
direction_of_y := 1

View.Set ("offscreenonly")
loop
cls
y := y + direction_of_y
x := x + direction_of_x
if y = maxy - 10 then
direction_of_y := direction_of_y * -1
elsif y = 10 then
direction_of_y := direction_of_y * -1
end if
drawfilloval (500, y, 20, 20, brightred)
View.Update
end loop

It's probably just a stupid mistake, that or my computers really really slow. Thanks

Author:  StarGateSG-1 [ Fri Oct 21, 2005 10:23 am ]
Post subject: 

I would read through the tutorials because i can't find anything different form my programs

Author:  beard0 [ Fri Oct 21, 2005 11:44 am ]
Post subject: 

Just make direction_of_y a larger number (it should really refer to the velocity of y, not the direction). Also, you are adding 20 to x each time through, which will eventually create an overflow. Also, in your if condtion, they can both be on the same line using "or", since their contents is the same - you should also be testing using <= and >=. Once you start changing the velocity, there's no guarantee that you will hit those numbers exactly.

Author:  Pinto2 [ Fri Oct 21, 2005 2:30 pm ]
Post subject: 

Thanks, i'll modify it now, i just wasn't sure if it was my slowwwww computer i'm using or my code.


: