Computer Science Canada

cannonball game problem

Author:  Sevensins [ Mon Feb 26, 2007 9:39 pm ]
Post subject:  cannonball game problem

ok for my grade 11 project I need to create a simple cannonball game where you enter the velocity and angle. My teacher gave me the formula but she went to a confrence for a week and the sub. cant help me so i need help. The formula goes somthing like this
"x:= round(5*velocity*time*cosd(angle))"
"y:=round(5*velocity*time*sind(angle)*0.5*time*time)"
i know about the predefined words its just that it says "interger overflow in 'round' on y's line.
can anyone figure it out

Author:  Clayton [ Mon Feb 26, 2007 9:44 pm ]
Post subject:  Re: cannonball game problem

It would help to see all of the code, but it's my bet that that time^3 you have going on there isn't helping you much....
Can't really do too much until we can figure out what sort of values you are dealing with.

Author:  berrberr [ Fri Mar 02, 2007 10:02 pm ]
Post subject:  Re: cannonball game problem

Well a few months ago I wanted to make the same thing as you, but gave up Laughing. Anyways, this is what I came up with. I know its not quite correct but maybe it will point you in the right direction...

Turing:
const GRAVITY := -0.0001
var x, y, xSpeed, ySpeed, angle,power : real := 0
put "Angle: "
get angle
put "Power: "
get power
xSpeed := cosd(power)/5
ySpeed := sind(angle)/5
loop
setscreen("offscreenonly")
View.Update
    x += xSpeed
    y += ySpeed
    ySpeed += GRAVITY
    Draw.FillBox(0,0,maxx,maxy,white)
    Draw.FillOval (round (x), round (y), 3, 3, black)
end loop


: