Code archives/Graphics/Simple Projectile Motion

This code has not been declared by its author to be Public Domain code, and therefore should not be assumed to be so.

Download source code

Simple Projectile Motion by NobodyInParticular
(Posted 25 years ago)
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,&quot;Press any key to exit...&quot;
Flip
FlushKeys()
WaitKey()
End