TNT Basic Forums > Programming Q&A
Weapon Projectile System
< Last Thread     Next Thread >
Thread        Post A Reply

02-28-2003 12:45

Posted by:
No Frills

Click Here to Email No Frills   Find more posts by No Frills

After much, much head scratching to try and figure out how to fire a 'projectile' type weapon and plot its path, I stumbled across this beauty during a search for something else (isn't it always the way....)

I thought I'd include it here - to save anyone else the stress of 'reinventing the wheel' or hunting around the net for weeks on end.

It needs some very basic 'conversion' - but it works a treat

the original article can be found on here:

So I assume its 'Blitz Basic' either PC or (God love it) Amiga flavour.

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
V = Input("Enter Velocity/Power:")
A = Input("Enter Angle:")
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
Text 0,0,"Press any key to exit..."

Hope it's of use - I know it was to me.

02-28-2003 12:46

Posted by:
No Frills

Click Here to Email No Frills   Find more posts by No Frills

The 'original' coders URL

Woops! the original URL got 'trimmed' from the above post.

I got the source from:

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.