• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Basic movement, problem with operator (+=) [SOLVED]

T

TheXGuy

Guest
Hello, I was following a tutorial and trying to understand every step of it but I'm stuck on this. I don't know why he uses this line:
x += hsp;​
Instead of
x = hsp;​

Actually I don't really understand what the operator += or -= means.

The full code is shown in this picture.

http://i.imgur.com/FmWcOQJ.jpg
 
R

RealsLife

Guest
Because in the code if you push vk_left or whatever
let's say hsp = 3;

If you use this x = hsp; for example the position of x in the object becomes the value 3 and we don't want that instead we want the current position of x = x + hsp(or in this case 3), because x += hsp is actually a shorter version of x = x + hsp.
 
Top