Help Understanding What I Just Did (Analog Controls)

Get help using Construct 2

» Wed Dec 03, 2014 5:28 pm

I am making a dual-analog shooter, and I just implemented the gamepad controls. They work great, but because I got part of the solution from a tutorial, I don't quite understand exactly what it does. I'm working on the game with a student, so it's important that I understand how it's working so I can explain it to him.

The left stick controls the ship movement and the right stick controls its orientation. Where I'm confused is what the three pairs of numbers are referring to in the first action in the right analog-stick event, here: "angle(0,0,Gamepad.Axis(0,2),Gamepad.Axis(0,3))". Can anyone break this down in a semi easy-to-comprehend way, please? Thanks!

B
3
Posts: 8
Reputation: 193

» Wed Dec 03, 2014 5:34 pm

From the manual :
Retrieve the current position of an analog joystick on a specific gamepad. Index specifies left analog X and Y or right analog X and Y axes, subject to Key mapping. Axes range from -100 to 100. Axis values within the Analog deadzone are returned as 0.
So I believe the that axis index 2 and 3 means X and Y axes of right stick if you use basic mappings.
B
80
S
33
G
27
Posts: 1,027
Reputation: 21,114

» Wed Dec 03, 2014 6:12 pm

Thanks, Magistross. Yes, I am using the basic mappings. I still have a few questions about this though.

What is the first 0,0 referring to?
What is the 0 in (0,2) and (0,3) referring to?
B
3
Posts: 8
Reputation: 193

» Wed Dec 03, 2014 6:40 pm

It's the gamepad index, 0 being the first gamepad. Unless you have multiple gamepads, you should always use index 0.
B
80
S
33
G
27
Posts: 1,027
Reputation: 21,114

» Wed Dec 03, 2014 8:30 pm

So every instance of 0 before a comma is telling it that this refers to gamepad 0, correct?
What about the second 0 in 0,0? What's that doing?

And thanks again for the help, I really appreciate it.
B
3
Posts: 8
Reputation: 193

» Wed Dec 03, 2014 9:40 pm

First, there is the angle(x1,y1,x2,y2) which gives the angle between the two points provided. Second, there are two Gamepad.Axis(gamepadIndex,axisIndex) which return the displacement of each axis. The angle() function is used with (0,0) as first point, and gamepad axes displacement as second. In a whole, the expression gives you the angle formed by the right analog stick.
B
80
S
33
G
27
Posts: 1,027
Reputation: 21,114

» Wed Dec 03, 2014 11:06 pm

Ok, I think I got it, or at least enough to explain the concept. That was a little more complicated than I was expecting -- certainly the most complicated thing we've encountered thus far.

Just out of curiousity, is there a less-involved way that we could have accomplished this right analog stick action?
B
3
Posts: 8
Reputation: 193