Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //walking
- if status = "idle"
- {
- speed = 0
- itran = 1
- //get keyboard input
- var hor_input = (ctrl.hRight[1] - ctrl.hLeft[1]);
- var ver_input = (ctrl.hDown[1] - ctrl.hUp[1]);
- if (hor_input != 0 || ver_input != 0)
- {
- walking = 1
- //get direction for movement
- var moveDir = point_direction(0, 0, hor_input, ver_input);
- //movement
- var checkX = lengthdir_x(spd, moveDir);
- var checkY = lengthdir_y(spd, moveDir);
- //set sprite
- if ver_input = 1
- {
- pimagexscale = 1
- usprite_index = spr_bodyfront
- lsprite_index = spr_legsfront
- faced = 270
- }
- if ver_input = -1
- {
- pimagexscale = 1
- usprite_index = spr_bodyup
- lsprite_index = spr_legsup
- faced = 90
- }
- if hor_input = 1
- {
- pimagexscale = -1
- usprite_index = spr_bodyside
- lsprite_index = spr_legsside
- faced = 0
- }
- if hor_input = -1
- {
- pimagexscale = 1
- usprite_index = spr_bodyside
- lsprite_index = spr_legsside
- faced = 180
- }
- if hor_input = -1 and ver_input = -1
- {
- pimagexscale = 1
- usprite_index = spr_heroha
- faced = 135
- }
- if hor_input = -1 and ver_input = 1
- {
- pimagexscale = 1
- usprite_index = spr_herofa
- faced = 225
- }
- if hor_input = 1 and ver_input = -1
- {
- pimagexscale = -1
- usprite_index = spr_heroha
- faced = 45
- }
- if hor_input = 1 and ver_input = 1
- {
- pimagexscale = -1
- usprite_index = spr_herofa
- faced = 315
- }
- //check collision
- if ( !place_meeting(x+checkX, y+checkY, obj_block) ){
- x += checkX;
- y += checkY;
- }
- }
- else
- {
- //(optional) round x and y when not moving
- x = round(x);
- y = round(y);
- walking = 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement