Code archives/Graphics/Simple Projectile Motion
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Here is a simple/basic example of Projectile Motion like what would be used in a Worms or Pocket Tanks type game... | |||||
;Basic Projectile Motion Example ;coded by: James Profitt (NobodyInParticular) ;--------------------------------------------- ;BOS = Bottom of Screen ;XSP = X start point ;G = Gravity (Earth's gravity = 9.80m/s^2) ;V = Velocity (Power) ;A = Angle (in degrees) ;T# = Time ;--------------------------------------------- AppTitle "Basic Projectile Motion Example" Graphics 800,600,32,2 SetBuffer BackBuffer() BOS = GraphicsHeight() XSP = 0 G# = 9.80 T# = 0 Cls V = Input("Enter Velocity/Power:") A = Input("Enter Angle:") Cls While Y < BOS T# = T# + .1 X = XSP + ((V * Cos(A)) * t#) Y = BOS - ((V * Sin(A)) * t# - .5 * G# * T#^2) Plot X,Y Flip Wend Text 0,0,"Press any key to exit..." Flip FlushKeys() WaitKey() End |
Comments
None.
Code Archives Forum