BBC BASIC for Windows
« Artillery »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:48pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Artillery  (Read 555 times)
Kendall Down
Guest
xx Artillery
« Thread started on: Mar 23rd, 2011, 9:54pm »

I want to write a simple artillery type game for my grandsons. Does anyone have a formula for calculating the path of a canonball given angle of gun and muzzle velocity? Gravity should come into it somewhere, I suppose.
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Artillery
« Reply #1 on: Mar 23rd, 2011, 10:43pm »

on Mar 23rd, 2011, 9:54pm, Guest-Kendall Down wrote:
Does anyone have a formula for calculating the path of a canonball given angle of gun and muzzle velocity?

There's a formula here:

http://en.wikipedia.org/wiki/Trajectory

User Image

(where v0 is the initial speed, theta is the angle of elevation and g is the acceleration due to gravity).

Or in BASIC code:

Code:
y = - (x^2) * g / COS(theta)^2 / (2 * v0^2) + x * TAN(theta) 

Or in an entire program:

Code:
      MODE 8
      
      v0 = 110
      g = 9.8
      theta = RAD(60)
      
      a = TAN(theta)
      b = g / COS(theta)^2 / (2 * v0^2)
      
      FOR x = 0 TO 1278 STEP 2
        y = x * a - x^2 * b
        DRAW x,y
      NEXT 

Richard.
« Last Edit: Mar 23rd, 2011, 11:35pm by admin » User IP Logged

Kendall K Down
Guest
xx Re: Artillery
« Reply #2 on: Apr 8th, 2011, 09:39am »

Thanks. I shall play around with that over the weekend.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls