• 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!

Scripts to simplify movement

V

Vincent

Guest
So I am currently trying to use scripts to make the movement, but I don't know hy this idea I had isn't working.
This is the script:
Code:
global.axis = global.axis + global.distance
This is the object's Step event:
Code:
if keyboard_check_pressed (ord ("W"))
    {
    global.axis = y
    global.distance = (-10)
    movement ()
    }
Any idea why this isn't working?
Thanks!
 
T

tehguy

Guest
Because changing the global variable isn't going to do anything without reassigning it to the object's Y.

Code:
if keyboard_check_pressed (ord ("W"))
    {
    global.axis = y
    global.distance = (-10)
    movement ()
    y = global.axis
    }
or you could just do

Code:
if keyboard_check_pressed (ord ("W"))
    {
        y -= 10 //or y = y - 10
    }
since x/y are instance-level variables that hold the object's current x/y positions
 
Top