» Goto page Previous  1, 2

Would you play Angry Birds if you had it on your calculator?
Yes  100%  [ 19 ]
No  0%  [ 0 ]

caleb1997 wrote:
Kerm: Yes, I know algebra.

And for the arc, I know how to calculate that. My equation of choice is:
2v^2*sin(theta)*cos(theta))/g

g=9.8 m/s^2
v= initial velocity
y=starting height (will be 2)
theta= angle relative to the ground, which will be completely horizontal.

V will depend on how far back you draw the slingshot. Or would it be 0?

The difficult part is coding in something that will make the bird fall down, and whatever it hit to move/die.
Would anyone mind helping me write a algorithm that will Pxl-Test in front of the point (that will be the bird, for now) so it can be checked for collision?

V would definitely not be 0, because then the equation would end up always being = to 0. I don't see why the angle relative to the ground would always have to be horizontal, then you would never have a nice arc, but rather just something that looks like -X^X. If you want to use a kinematic formula to find where the projectile will end up (on a tower for example) I'd recommend using P=(Vsin(theta)^2)/2g, where P is the range, g is the gravity, theta is the angle relative to the x axis, and V is the initial velocity. Maybe you would also want to reduce the 9.8 to something a little smaller simply because in the real game, the birds almost seem to be on the moon haha.
mr womp womp wrote:
V would definitely not be 0, because then the equation would end up always being = to 0. I don't see why the angle relative to the ground would always have to be horizontal, then you would never have a nice arc, but rather just something that looks like -X^X. If you want to use a kinematic formula to find where the projectile will end up (on a tower for example) I'd recommend using P=(Vsin(theta)^2)/2g, where P is the range, g is the gravity, theta is the angle relative to the x axis, and V is the initial velocity. Maybe you would also want to reduce the 9.8 to something a little smaller simply because in the real game, the birds almost seem to be on the moon haha.

This equation is useful, but I graphed it and I want to stretch it out a little bit out horizontally. I want it to actually look like a straight line that turns into a parabola. Because when a bird gets launched, the velocity is great enough for it to travel in a near-straight line for a second or so. Then gravity takes over, and the line turns into a parabola.
mr womp womp wrote:
in the real game, the birds almost seem to be on the moon haha.

They are birds after all
So the line is going to be determined by how far the slingshot is going to be drawn back, because the bird is going to be at (0,0), so if you have maximum power, at (-5,-5), the line equation would be y=x, because the slope would be 1. But if it's (-5,-3), it would be 3/5.

The beginning of the code is here:

Code:
```ClrDraw:FnOff ~2->A:~2->B ~6->Xmin:~6->Ymin:30->Xmax:30->Ymax Line(0,~3,0,0):Line(0,0,~3,3):Line(0,0,3,3)  //draws the slingshot// Repeat Z=105 getKey->Z If max(Z=[24,34,26,25]):Then A-(Z=24)+(Z=26)-(A>=0)+(A=~6)->A B-(Z=34)+(Z=25)-(B>=0)+(B=~6)->B Line(~3,3,A,B):Line(3,3,A,B) Pt-On(A,B) End```

Feel free to comment.

Edit: I'm using the slope-formula equation for this, with A and B as x1 and y1, and 0 as x2 and y2.
For v initial, since you are simulating a slingshot, you probably want to use Hooke's law. https://en.wikipedia.org/wiki/Hooke%27s_law

Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
» Goto page Previous  1, 2
» All times are UTC - 5 Hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum