Programming an Arch
Moderator: Moderators
Programming an Arch
I want to create a program to simulate an arch a la Artillery Duel. This could useful for jumping or side-view projectile motions. I know this is probably a simple math question, but I am open to suggestions. I want to figure out a way to do it with speed.
-
- The Most Noble Order of Denial
- Posts: 343
- Joined: Fri May 01, 2009 4:44 pm
I'd guess something like this.
Doesn't need a whole lot of CPU.
Doesn't need a whole lot of CPU.
Code: Select all
10 g=0.05
20 vx=3;vy=3;x=0;y=0
30 ? "bang"
40 x=x+vx;y=y+vy;vy=vy-g;
50 [plot bullet at x,y]
60 if y>0 then goto 40
70 ? "boom"
-
- The Most Noble Order of Denial
- Posts: 343
- Joined: Fri May 01, 2009 4:44 pm
Nope +y is up, if you added g then it would shoot off into space.IsaacKuo wrote:Probably "vy=vy+g" rather than "vy=vy-g". I'm assuming +y is "down" rather than "up".
Oh, and to "jump", you need to start with a negative vy, like "vy=-3".
BTW, the mathematical term for this curve is a "parabola".
Depends on your coordinate system.