How do I create a catapult mechanic for a launch game?


(Reece Speight) #1

Hey guys, I have a game idea to create an horizontal launch game for a college project. I want to be able to launch the player using a catapult that you pull back by holding the down key (for now, importing to android later).

My question is how would i get this working, i have very little experience programming but i do know the basics of FP so any help would be amazing!

Thanks guys in advanced!


(Midcode) #2

For every frame the down key is held down, “tension” can increase (perhaps using FP.elapsed to compensate for time). This increase could perhaps could be done logarithmically (i.e. the more tension there is, the harder it is to add more tension).

Whilst pulling back, the player’s position should be locked to that of the catapult’s string.

After this, the velocity of the player will be proportional to the tension (F = ma), and the player should be released. Note that this should be done in the x and y axes, using trigonometry.

Each individual velocity component should then be altered constantly, by gravity and air resistance.


(Zachary Lewis) #3

@rspeight11 Where exactly are you stuck? What have you tried? Walk us through your thought process.


(Reece Speight) #4

I have little to no experience programming i know the basics but i don’t even know where to start


(Midcode) #5

If that’s the case, it’d probably be best if you watched some of the tutorials available here before jumping right in.


(I'll tell you what I want, what I really really want) #6

I’m not really a pro myself, but people always say: break it down to smaller problems, one by one, and step by step make problems manageable to overcome by the knowledge you already have.

And it works.


(Zachary Lewis) #7

We can work through it together. Let’s get a basic list of what we know.

  • Bullets will fire at an angle (which may change)

  • Bullets will fire with a power (which may change)

This pretty much describes our catapult. We can see now what variables we need: angle and power.

Now, as long as we hold a key, the power will increase. Once we release the key, the bullet will be shot. This is the point where we make a simple prototype.