How do I spawn just one bomb

Get help using Construct 2

Post » Fri Jan 11, 2013 7:33 am

I've searched the forums and I couldn't find any help and I'm new to Construct.

I want to make a game where the player collects bombs and can plant them where ever to destroy things blocking paths. But I want it so I can only drop a bomb after the player collides with the icon on screen.

I've played with the events/ variables for hours and after the player collects one bomb it's like they now have unlimited. How can I make the player just drop one until the player gets another one?

Thank you!

p.s - I want the player to press the "D" key on the keyboard to drop the bombJVrocker892013-01-11 07:36:02
B
2
Posts: 2
Reputation: 254

Post » Fri Jan 11, 2013 7:50 am

I'd do something like:

Variable: bombs = 0

Player takes bomb, bombs + 1
Player uses bomb, bombs -1

if player bombs < 1, don't allow using bombs
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Fri Jan 11, 2013 8:46 am

I got it so when the player walks over the bomb icon it adds 1 to the variable and I also have it set so when I press the "D" key it spawns the exploding bomb and subtracts 1 from the variable but when I still press the "D" Key it keeps spawning bombs and I can't figure out how to stop allowing the use of bombs
B
2
Posts: 2
Reputation: 254

Post » Fri Jan 11, 2013 9:01 am

You need to add another condition to the bomb planting where it checks the variable. If the variable is < 1 you do not allow them to plant the bomb. You can do this two ways:

1. On your plant the bomb event add a second condition that if variable is equal to 1 (Events only happen if all conditions are met)

2. On your plant the bomb event add a condition that variable is not equal to or greater than 0 (again, if the condition is not met, the event does not fire of it's actions)

You can check the platformer tutorial or the basic tutorial (sorry I forget which one has you add multiple conditions to an event) for an example of adding multiple conditions to an event. I believe it is in the platformer tutorial by Ashley where you set the animation for idle or running based on multiple conditions. Also the part about jumping on the snails also has multiple conditions that need to be met in order to tell if you kill the snail or take damage instead. These should give you a good starting point.

Basically what you need to do as part of the bomb action, is to check to make sure the variable = 1 or is greater then 0. If it fails the check, the condition is not met and the action should not happen.
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,413


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 16 guests