Gravity

BlitzPlus Forums/BlitzPlus Beginners Area/Gravity

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I haven't personally tried this (I'm can't load blitz plus at work I tried once and got busted DOH!!!) anyway I think something like this might work I'll try it at home tonight if I think about it and see what I did wrong


Type rock
field V1 ; horizontal velocity you are throwing at
field height; the initial height you are throwing at
field Angle ; angle you are throwing at in radians
field x,y
end type

intiitialize your rock with whatever you are starting with
global rock.rock = new rock
rock\v1 = whatever
rock\angle = whatever
rock\height = whatever
rock\x = whatever

;in your main loop somewhere

if rock\y < rock\height ; if your y is less than your height you are back where you started from vertically

drawimage(rockimage, rock\x, rock\y)
UpdateRock()
end if


Function UpdateRock()
rock\y = rock\x * (Tan(rock\angle)) - (((4.9) * (rock\x ^ 2)) / ((rock\V1 ^ 2) * ((Cos(angle)) ^ 2)))

rock\x = rock\x + 1 ;increment by a pixel or whatever you want

end function