Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Player is STILL
- if (global.ctrl_left = 0 && global.ctrl_right = 0 && global.ctrl_up = 0 && global.ctrl_down = 0)
- {
- hspeed = 0;
- vspeed = 0;
- sprite_index = sp_PlayerMov;
- image_speed = 0;
- global.CharAnim = 'still';
- if (global.CharDirect = 'right')
- {
- image_index = 0;
- }
- if (global.CharDirect = 'left')
- {
- image_index = 5;
- }
- if (global.CharDirect = 'up')
- {
- image_index = 10;
- }
- if (global.CharDirect = 'down')
- {
- image_index = 15;
- }
- }
- //RIGHT Walking Animation
- if (global.ctrl_left = 0 && global.ctrl_right = 1)
- {
- if (global.CharAnim = 'still')
- {
- sprite_index = sp_PlayerMov;
- image_index = 1;
- image_speed = 0.15;
- global.CharAnim = 'moving';
- global.CharDirect = 'right';
- }
- if (global.CharAnim = 'moving' && global.CharDirect != 'right')
- {
- sprite_index = sp_PlayerMov;
- image_index = 1;
- image_speed = 0.15;
- global.CharAnim = 'moving';
- global.CharDirect = 'right';
- }
- if (image_index > 4)
- {
- image_index = 1;
- }
- }
- //RIGHT Input
- if keyboard_check_pressed(ord('D'))
- {
- if (global.ctrl_left = 1)
- {
- global.ctrl_left = 0;
- }
- hspeed = global.CharSpeed;
- global.ctrl_right = 1;
- }
- if keyboard_check_released(ord('D'))
- {
- global.ctrl_right = 0;
- if keyboard_check(ord('A'))
- {
- global.ctrl_left = 1;
- hspeed = -global.CharSpeed;
- }
- if (global.ctrl_left = 0)
- {
- hspeed = 0;
- }
- }
- //LEFT Walking Animation
- if (global.ctrl_left = 1 && global.ctrl_right = 0)
- {
- if (global.CharAnim = 'still')
- {
- sprite_index = sp_PlayerMov;
- image_index = 6;
- image_speed = 0.15;
- global.CharAnim = 'moving';
- global.CharDirect = 'left';
- }
- if (global.CharAnim = 'moving' && global.CharDirect != 'left')
- {
- sprite_index = sp_PlayerMov;
- image_index = 6;
- image_speed = 0.15;
- global.CharAnim = 'moving';
- global.CharDirect = 'left';
- }
- if (image_index > 9)
- {
- image_index = 6;
- }
- }
- //LEFT Input
- if keyboard_check_pressed(ord('A'))
- {
- if (global.ctrl_right = 1)
- {
- global.ctrl_right = 0;
- }
- hspeed = -global.CharSpeed;
- global.ctrl_left = 1;
- }
- if keyboard_check_released(ord('A'))
- {
- global.ctrl_left = 0;
- if keyboard_check(ord('D'))
- {
- global.ctrl_right = 1;
- hspeed = global.CharSpeed;
- }
- if (global.ctrl_right = 0)
- {
- hspeed = 0;
- }
- }
- //UP Walking Animation
- if (global.ctrl_up = 1 && global.ctrl_down = 0 && global.ctrl_left = 0 && global.ctrl_right = 0)
- {
- if (global.CharAnim = 'still')
- {
- sprite_index = sp_PlayerMov;
- image_index = 11;
- image_speed = 0.15;
- global.CharAnim = 'moving';
- global.CharDirect = 'up';
- }
- if (global.CharAnim = 'moving' && global.CharDirect != 'up')
- {
- sprite_index = sp_PlayerMov;
- image_index = 11;
- image_speed = 0.15;
- global.CharAnim = 'moving';
- global.CharDirect = 'up';
- }
- if (image_index > 14)
- {
- image_index = 11;
- }
- }
- //UP Input
- if keyboard_check_pressed(ord('W'))
- {
- if (global.ctrl_down = 1)
- {
- global.ctrl_down = 0;
- }
- vspeed = -global.CharSpeed;
- global.ctrl_up = 1;
- }
- if keyboard_check_released(ord('W'))
- {
- global.ctrl_up = 0;
- if keyboard_check(ord('S'))
- {
- global.ctrl_down = 1;
- vspeed = global.CharSpeed;
- }
- if (global.ctrl_down = 0)
- {
- vspeed = 0;
- }
- }
- //DOWN Walking Animation
- if (global.ctrl_up = 0 && global.ctrl_down = 1 && global.ctrl_left = 0 && global.ctrl_right = 0)
- {
- if (global.CharAnim = 'still')
- {
- sprite_index = sp_PlayerMov;
- image_index = 16;
- image_speed = 0.15;
- global.CharAnim = 'moving';
- global.CharDirect = 'down';
- }
- if (global.CharAnim = 'moving' && global.CharDirect != 'down')
- {
- sprite_index = sp_PlayerMov;
- image_index = 16;
- image_speed = 0.15;
- global.CharAnim = 'moving';
- global.CharDirect = 'down';
- }
- if (image_index > 19)
- {
- image_index = 16;
- }
- }
- //DOWN Input
- if keyboard_check_pressed(ord('S'))
- {
- if (global.ctrl_up = 1)
- {
- global.ctrl_up = 0;
- }
- vspeed = global.CharSpeed;
- global.ctrl_down = 1;
- }
- if keyboard_check_released(ord('S'))
- {
- global.ctrl_down = 0;
- if keyboard_check(ord('W'))
- {
- global.ctrl_up = 1;
- vspeed = -global.CharSpeed;
- }
- if (global.ctrl_up = 0)
- {
- vspeed = 0;
- }
- }
- //Boundaries
- obj_Player.x = clamp(obj_Player.x, sprite_width/2 ,room_width - sprite_width/2);
- obj_Player.y = clamp(obj_Player.y, sprite_height/2 ,room_height - sprite_height/2);
- //VIEW
- view_object[0] = obj_Player;
- view_hborder[0] = room_width/2;
- view_vborder[0] = room_height/2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement