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

Need help with states and movement between two different objects

L

Loafwad

Guest
I am trying to make it so when I press E (for now) I am able to control my boat using WASD

Any help would be greatly appreciated

this is my messy code that I have formulated over many failed attempts
And is what i have been closest to achieve what i want where the boat does not move when I am not inside it

Code:
sail_sp = 0;
scr_getinput();

if key_E
{
    state = state.boat
}

if state = state.boat
{
sail_sp = 4;
if key_up
    {
        y -= sail_sp;
    }
if key_down
    {
        y += sail_sp;
    }
if key_right
    {
        x += sail_sp;
    }
if key_left
    {
        x -= sail_sp;
    }
}
 
D

DarthTenebris

Guest
Try
Code:
if (keyboard_check(key_*))
instead.

Hope I helped :)
 
L

Loafwad

Guest
Try
Code:
if (keyboard_check(key_*))
instead.

Hope I helped :)

I am already getting my input from my script scr_getinput();

Code:
key_up = keyboard_check(ord("W"))
key_down = keyboard_check(ord("S"))
key_right = keyboard_check(ord("D"))
key_left = keyboard_check(ord("A"))

key_E = keyboard_check(ord("E"))
 
D

DarthTenebris

Guest
Code:
if (keyboard_check(ord('E'))) {
     if (keyboard_check(ord('W')) {
          y -= sail_sp;
     }
     if (keyboard_check(ord('A')) {
          x -= sail_sp;
     }
     if (keyboard_check(ord('S')) {
          y += sail_sp;
     }
     if (keyboard_check(ord('D')) {
          x += sail_sp;
     }
}
I am not quite sure what's wrong with your code then, but try the above code and see if it works.

Hope I helped :)
 
Top