Created
September 16, 2015 13:28
-
-
Save YellowAfterlife/4befb658e6bd78718132 to your computer and use it in GitHub Desktop.
Movement code for GameMaker using bbox_ variables and collision_line calls.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (keyboard_check(vk_left)) repeat (3) { | |
var _x = bbox_left - 1; | |
if (!collision_line(_x, bbox_top, _x, bbox_bottom, obj_solid, false, true)) x -= 1; | |
} | |
if (keyboard_check(vk_right)) repeat (3) { | |
var _x = bbox_right + 1; | |
if (!collision_line(_x, bbox_top, _x, bbox_bottom, obj_solid, false, true)) x += 1; | |
} | |
if (keyboard_check(vk_up)) repeat (3) { | |
var _y = bbox_top - 1; | |
if (!collision_line(bbox_left, _y, bbox_right, _y, obj_solid, false, true)) y -= 1; | |
} | |
if (keyboard_check(vk_down)) repeat (3) { | |
var _y = bbox_bottom + 1; | |
if (!collision_line(bbox_left, _y, bbox_right, _y, obj_solid, false, true)) y += 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment