Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Code snippet for player movement/per-frame operations from Kizuna: The Girl Who Saved Christmas
- if dead = 1
- {
- with (obj_playerbullet) instance_destroy();
- if sound_isplaying(snd_shot) sound_stop(snd_shot);
- }
- if dead = 1 && xrot != -90 { xrot -= 3; }
- if dead = 0 && xrot < 0 { xrot += 6; }
- direction -= ((display_mouse_get_x() - display_get_width()/2) / 10) //for the mouse left/right movement
- //speed = 0 //so the player doesn't pick up massive speed every step
- if dead = 1 movespeed = 0;
- else movespeed = 4;
- // move forward
- if keyboard_check(ord("W"))
- {
- nx = x + lengthdir_x(movespeed,direction);
- ny = y + lengthdir_y(movespeed,direction);
- if !place_meeting(nx, y, obj_wall_basic) //check if object in path
- x = nx;
- if !place_meeting(x, ny, obj_wall_basic) //check if object in path
- y = ny;
- }
- //move backwards
- if keyboard_check(ord("S"))
- {
- nx = x + lengthdir_x(movespeed,direction+180);
- ny = y + lengthdir_y(movespeed,direction+180);
- if !place_meeting(nx, y, obj_wall_basic) //check if object in path
- x = nx;
- if !place_meeting(x, ny, obj_wall_basic) //check if object in path
- y = ny;
- }
- //strafe left
- if keyboard_check(ord("A"))
- {
- nx = x - sin(direction*pi/180)*movespeed;
- ny = y - cos(direction*pi/180)*movespeed;
- if !place_meeting(nx, y, obj_wall_basic) //check if object in path
- x = nx;
- if !place_meeting(x, ny, obj_wall_basic) //check if object in path
- y = ny;
- }
- //strafe right
- if keyboard_check(ord("D"))
- {
- nx = x + sin(direction*pi/180)*movespeed;
- ny = y + cos(direction*pi/180)*movespeed;
- if !place_meeting(nx, y, obj_wall_basic) //check if object in path
- x = nx;
- if !place_meeting(x, ny, obj_wall_basic) //check if object in path
- y = ny;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement