Computer Science Canada

Parabola bullet thing

Author:  RaLz [ Mon May 26, 2003 3:56 pm ]
Post subject:  Parabola bullet thing

ok im making that one tank game where there are two tanks on bothsides and you shoot a bullet and it has to make an arch shape to get to the other side and hit the other tank.
Now i know im supposed to use a parabola for the bullet but i am bad at math and i don't know where to start so if someone could please do the bullet process for me or help me out that would be great. It needs to include how much power the shot is going to have and altitude.

Author:  AsianSensation [ Mon May 26, 2003 4:14 pm ]
Post subject: 

Projectile_Posx := Projectile_Velocity * cosd (Angle) * Projectile_Time
Projectile_Posy := (-1 / 2) * Gravity * Projectile_Time ** 2 + Projectile_Velocity * sind (Angle) * Projectile_Time

it's the coordinates for the projectile, put it in a loop, increase the time variable each loop, and u should have it. I also have the equation that involves air-resistance, if you want it, i'll post it up.

Author:  RaLz [ Mon May 26, 2003 6:53 pm ]
Post subject: 

yea that would be cool if you could

Author:  RaLz [ Mon May 26, 2003 6:56 pm ]
Post subject: 

also it would be cool if you could explain that code to me cuz i don't get any of it

Author:  void [ Mon May 26, 2003 8:43 pm ]
Post subject: 

basic projectile physics:
x= v*cos*theta*t
y=v*sin*theta-g*t^2/2

v=velocity
cos and sin are constants (use sind and cosd when ur doing it in turing)
t= time
g= gravity (i think its 9.8 or 9.3 m/ s^2)
theta= angle at which the projectile is shot
x= x-co ordinate
y= y- co ordinate
but yea....if you dont understand that...you should go ask your math teacher...they'll prolly help you better AND they will think ur a smart kid and boost your mark a good 3-4 % Very Happy any more help..just ask

Author:  RaLz [ Mon May 26, 2003 8:46 pm ]
Post subject: 

thanx douchie

Author:  void [ Mon May 26, 2003 8:51 pm ]
Post subject: 

yo!!.. who da blu...wiyado...who is this kid!!! and how does he know who i am...(only people i know can mess up my name like that and get away with it!!) lol..yea..who is this?

Author:  Homer_simpson [ Mon May 26, 2003 8:52 pm ]
Post subject: 

oh that's some cool formula Very Happy 8)
good to know...=)

Author:  RaLz [ Mon May 26, 2003 8:53 pm ]
Post subject: 

Ok i don't get what the projectile time has to do with it

Author:  RaLz [ Mon May 26, 2003 8:55 pm ]
Post subject: 

its Raheel

Author:  void [ Mon May 26, 2003 8:56 pm ]
Post subject: 

how long it takes to get from the initial launching point to reach the landing point....just make time a constant...its better that way/......WHO ARE YOU?!?!?!?!?....TELL ME...BEFORE I KILLL YOU (that was not a threat)

Author:  Homer_simpson [ Mon May 26, 2003 9:02 pm ]
Post subject: 

ok... i tried using it in turing... one problem...
how do u multiply sine or cos in the formula?

Author:  void [ Mon May 26, 2003 9:15 pm ]
Post subject: 

code:

var x, y, th : real
const v := 9
const t := 1
const g := 9.8
th := 12
x := v * cosd (th) * t
y := v * sind (th) * t - g * t ** 2 / 2

now the only problem is making x and y back into integers so i can locate with themm.....

Author:  AsianSensation [ Mon May 26, 2003 9:23 pm ]
Post subject: 

x := cosd(angle) + (mass * velocity * cosd(angle) / air resistance) * (1 - e**(-air resistance * time / mass))

y := sind(angle) - (mass * gravity * time / air resistance)+((mass * velocity * sind(angle) / air resistance) + (mass**2 * gravity / (air resistance**2))) * (1 - e**(-air resistance * time / mass))

http://www.phy.davidson.edu/StuHome/jocampbell/projectile/projectile.htm

I think that web site give u the equation and maybe some explaination for it.

Author:  RaLz [ Mon May 26, 2003 9:35 pm ]
Post subject: 

Yeahhhh this game has gotten wayy to complicated for me since iam onlin gr 10 and ihaven't learnt that much physics i will prolly not be able to do this. So any other suggestions cuz i thought this game wouldn't be this hard

Author:  Homer_simpson [ Mon May 26, 2003 9:38 pm ]
Post subject: 

so this would be the code:
code:
var x, y, th : real
const v := 50
var t := 1.0
const g := 9.8
th := 45

loop
    t += .1
    x := v * cosd (th) * t
    y := v * sind (th) * t - g * t ** 2 / 2
    drawfilloval (round (x) + 100, round (y) + 200, 5, 5, 12)
    delay (50)
    drawfilloval (round (x) + 100, round (y) + 200, 5, 5, white)
    drawdot (round (x) + 100, round (y) + 200 + 6, 9)
    exit when t >= 10
end loop

Author:  AsianSensation [ Mon May 26, 2003 9:40 pm ]
Post subject: 

well, u don't really have to understand it to use it. I mean, it's just plugging in the numbers and constants and producing a value(personally, I'm in grade 10 too, and I manage to learn a bit of physics myself, but not that much, and I just plugged in numbers). But if you think this is too hard, then you could just make a cursor, and have the tanks shoot in whatever direction ur cursor in pointing at.

Author:  void [ Mon May 26, 2003 9:50 pm ]
Post subject: 

oky...time to teach a few rules of thumb
#1- age doesnt affect knowledge
#2- when a gr.10 is doing a summative, (s)he is not gonna program AIR RESISTANCE into the game
#3- NEVER, EVER, EVER MAKE THINGS CONFUSING he asked how to do simple projectile, not a whole re-enactment so that nasa can plot a chart of how a bullet travels and then crate an ultimate bullet that isnt affected by petty things such as air resistance

Author:  RaLz [ Mon May 26, 2003 9:52 pm ]
Post subject: 

yea i wanted to use the arrow keys and just increase the value and decreease the angle
and then have like up and down be the power the bullet is shot at

Author:  Homer_simpson [ Mon May 26, 2003 9:54 pm ]
Post subject: 

or this .... 8)
code:
View.Set ("graphics:3000;900")
var x, y, th : real
var v := 80
var t := 1.0
const g := 9.8
th := 45
var xx := 0
var x2 := 0
var bounce := 20
loop
    t += .1
    x := v * cosd (th) * t
    y := v * sind (th) * t - g * t ** 2 / 2
    if y <= 0 then
        t := 0
        v -= bounce
        xx += round (x - 0)

    end if
    drawfilloval (round (x) + xx, round (y) + 200, 5, 5, 12)
    delay (10)
    drawfilloval (round (x) + xx, round (y) + 200, 5, 5, white)
    drawdot (round (x) + xx, round (y) + 200 + 6, 9)
    drawline (0, 195, maxx, 195, 9)
    exit when t >= 20 or v <= 0
end loop

Author:  AsianSensation [ Mon May 26, 2003 10:02 pm ]
Post subject: 

oh, my bad, I thought you wanted to be able to hold down a key or something(like in worms) and release and then shoot. Then just use what homer gave you.

Void, I didn't try to make things more confusing, he asked for the formula with air resistance, just trying to be helpful.

Author:  RaLz [ Mon May 26, 2003 10:03 pm ]
Post subject: 

wow thanx man

Author:  void [ Mon May 26, 2003 10:10 pm ]
Post subject: 

k sorry azn...i didn realize....i just thought raheel would be such a dumbass
he doesnt even understand basic physics...hes not gonna understand complex shit like that

Author:  void [ Mon May 26, 2003 10:35 pm ]
Post subject: 

code:

var t := 1.0
const g := 9.8
th := 1
var x1 := 100
var y1 := 100
procedure shoot
    loop
        t += .1
        x := v * cosd (th) * t
        y := v * sind (th) * t - g * t ** 2 / 2
        drawfilloval (round (x), round (y) + 200, 5, 5, 12)
        delay (10)
        drawfilloval (round (x), round (y) + 200, 5, 5, white)
        drawdot (round (x), round (y) + 200 + 6, 9)
        exit when t >= 20
    end loop
end shoot

procedure action
    loop
        getch (key)
        if ord (key) = 200 then
            th += 1
            locate (13, 13)
            put th : 3
        elsif ord (key) = 208 then
            th -= 1
            locate (13, 13)
            put th : 3
        elsif ord (key) = 32 then
            shoot
            t := 1.0
        end if
    end loop
end action

action



this is the one with the keys

Author:  void [ Mon May 26, 2003 10:37 pm ]
Post subject: 

o h y e a.....
code:

var w : int := Window.Open ("fullscreen, noecho, nocursor")
var key : string (1)
var x, y, th : real
var v := 90

yyou might wanna add that too

Author:  void [ Mon May 26, 2003 10:39 pm ]
Post subject: 

PLEASE DONT LOCK THIS...i just realized that i made a mistake so i hafta repost it.....i hope oyu dont get mad at my 3 posts in a row
code:

var w : int := Window.Open ("fullscreen nocursor")
var key : string (1)
var x, y, th : real
var v := 90
var t := 1.0
const g := 9.8
th := 45
var x1 := 100
var y1 := 100
procedure shoot
    loop
        t += .1
        x := v * cosd (th) * t
        y := v * sind (th) * t - g * t ** 2 / 2
        drawfilloval (round (x), round (y) + 200, 5, 5, 12)
        delay (10)
        drawfilloval (round (x), round (y) + 200, 5, 5, white)
        drawdot (round (x), round (y) + 200 + 6, 9)
        exit when t >= 10
    end loop
end shoot

procedure action
    loop
        getch (key)
        if ord (key) = 200 then
            th += 1
            locate (13, 13)
            put th : 3
        elsif ord (key) = 208 then
            th -= 1
            locate (13, 13)
            put th : 3
        elsif ord (key) = 32 then
            shoot
            t := 1.0
        end if
    end loop
end action

action



thats it....change the time to make the ball last longer

Author:  Homer_simpson [ Mon May 26, 2003 10:49 pm ]
Post subject: 

or u could have just editted yer first post Rolling Eyes


: