How do I clean up command inputs?

Get help using Construct 2

Post » Tue Jul 15, 2014 10:39 pm

Weird title, I know.

Here's my dilemma:

Building a fighting game prototype, trying to streamline the handling of inputs. I'm translating device commands so that it'll be easier to handle multiple types of input (Keyboard, Gamepad, Touch if I so will it.)

The problem I've run into is that I'm forced to use a lot of nesting to get it to work as it should. I've included the CAPX , so you can see my work so far. The eventsheet with the offending events is in the Control sheet, under Layer 1: Raw Input Keyboard.

The logic behind what I'm doing is that if you press a key, as long as you aren't pressing an opposing key, it will alter the value to it's correct state. If you're familiar with the Number notation used in the fighting game community, it's like that. (Explanation: Look at your number pad. 2, 4, 6, and 8 correspond to a cardinal direction and 1, 3, 7, and 9 are diagonals. 5 is neutral.)

The way I wanted to do it is if you're pressing left or right, the value is set to 4 or 6. Then if you press up or down, it will either add 3 or subtract 3 from the value, while it's held. Thus, if you're holding right (6) and holding up ( X +3 ) you'll get 9, which is up-right. And if you're just holding up, it should be Neutral (5) + Up (X+3) and equal 8, which is just Up. If you let go of Up, it should return to it's value pre-Up, which would be 4, 5, or 6 respectively.

Needless to say, that didn't quite work out right. So I ended up making complicated nesting to get it just as it's supposed to work, and just set values instead.

It looks ugly as sin to me, and I'm asking if there's a cleaner way of doing it. Trying to keep the number of events to a minimum. I teach a class of 11 year olds development with Construct2 for my summer job, and I want to keep it under 100 events so that they can take it home and mess with it in the free version.
You do not have the required permissions to view the files attached to this post.
B
2
Posts: 2
Reputation: 154

Post » Wed Jul 16, 2014 12:54 am

I'm guessing you're looking to set a numerical value to your input to mirror a keypad. This is simpler - I've reduced the input to 4 lines. There are probably other ways of doing it, of course.

prototype_v2.capx
You do not have the required permissions to view the files attached to this post.
A big fan of JavaScript.
B
76
S
20
G
74
Posts: 2,244
Reputation: 46,462

Post » Wed Jul 16, 2014 1:29 am

My take on this issue..
Although it really doesn't cut down that much on the code, it only works with triggered events..
You do not have the required permissions to view the files attached to this post.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jul 16, 2014 1:36 am

Actually, with some minor adjustments it seems it is exactly like you asked for in the first post, haha..
Simplified it!
You do not have the required permissions to view the files attached to this post.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jul 17, 2014 8:01 pm

I am very grateful! Exactly what I needed!

You guys are awesome. This also gives me some better insight for the rest of the project.

Thanks!
B
2
Posts: 2
Reputation: 154


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 8 guests