Keyboard Commands Logic Issue

Get help using Construct 2

Post » Sun Nov 24, 2013 8:13 pm

Hello guys! This problem is not technical as much as it is logical, yet I can't seem to wrap my head around how to code (use the event sheet) to get my desired result.

The player will have to press and hold a certain pattern and amount of keys in order to do an attack, after the attack has been done the player needs to repeat the sequence in order to do the attack again.


Here is a couple of examples I have made that come close to what I want it to be like (you should see why being able to reset the sequence is important to not make the game unfair)

Example 1:

LINK: h.ttps://googledrive.com/host/0B-1nIpPDmmZuajFMLUJfQXRhVm8/index.html
CAPX: h.ttps://drive.google.com/file/d/0B-1nIpPDmmZuYzdiOE9fZUdpRmc/edit?usp=sharing

Example 2:

LINK: h.ttps://googledrive.com/host/0B-1nIpPDmmZubFJSUjk3WlB4cTQ/index.html
CAPX: h.ttps://drive.google.com/file/d/0B-1nIpPDmmZuS04tNjZWbXMySE0/edit?usp=sharing

(I think I've uploaded the right files correctly)

Instructions:
Hold in this order (F + S + H + D + L)
You can hold (F + S + H + D) and then tap L in both versions, I do NOT want the game to be like this, rather the opposite, that the player keeps repeating the sequence since I plan on adding different attacks (I hope by playing it makes my issue make more sense, I might be over explaining it :P)


Thank you in advance for checking it out, if you don't have time to download and check the event sheet then the LINK is the straight up game so far so yeah!
B
8
Posts: 12
Reputation: 338

Post » Mon Nov 25, 2013 5:03 am

Remember that each of the events is actioned every tick. So, if the F key is held down for one second the value of the Attack variable will be 60 - add a text object to display the Attack and you'll see what I mean...

Your logic assumes that each of the events will behave a bit like a trigger so you need to figure a way to log if the keys are pressed in the correct order - I suggest using either a variable for each key being held down (testing that the previous key is down first) or an array and then making a test of those parameters.
A big fan of JavaScript.
B
76
S
20
G
74
Posts: 2,251
Reputation: 46,476

Post » Tue Nov 26, 2013 4:50 pm

Oh I've been so blind!

Thank you for your reply, I'm now using a combination of variables (I might change it for an array when I implement more attacks) and I also figured out I could use both "On key pressed" and "On key released" to track if the player is holding the key down or not, without making the variable fly off the charts when its increased :P

I would post links but it's quite difficult as a new user to the forum, thank you for your help though! :)
B
8
Posts: 12
Reputation: 338


Return to How do I....?

Who is online

Users browsing this forum: badmoodtaylor and 13 guests