Allow keyboard input only if a condition is true

Get help using Construct 2

Post » Mon Apr 09, 2012 12:08 am

Hi everyone,

I'm making a simple lander game to teach myself the basics of Construct2.

The player's object (MarsLander) has a variable called Fuel. When Fuel <= 0, the player should not be able to control the lander. That is, the System should ignore the keypresses. Or, when fuel >= 0, the player can control the lander.

What I want is this:

IF MarsLander.Fuel >= 0
     do keyboard input

What I have is this:
System.EveryTick
System.MarsLander.Fuel >=0
Keyboard.UpArrow pressed do stuff
Keyboard.DownArrow pressed do stuff
Keyboard.LeftArrow pressed do stuff
Keyboard.RightArrow pressed do stuff

But, that allows the player to move the ship around even if there is 0 fuel.

Any guidance is much appreciated.

Has
B
2
Posts: 2
Reputation: 304

Post » Mon Apr 09, 2012 12:11 am

First off you don't need the every tick event. The condition is compared every tick.
Second, add the keyboard conditions as sub events to the variable compare condition.
If it doesn't evaluate to true, then the sub events aren't run.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Mon Apr 09, 2012 1:37 am

Thanks, Newt.

Works great.

B
2
Posts: 2
Reputation: 304

Post » Mon Oct 22, 2012 11:01 pm

[QUOTE=hasman] Thanks, Newt.

Works great.

[/QUOTE]

Hi! Share please source. Thank you.haer2012-10-22 23:02:20
B
17
S
3
G
1
Posts: 9
Reputation: 2,973


Return to How do I....?

Who is online

Users browsing this forum: Justin1967, Nifl and 27 guests