We also set "sprite_index" equal to our player_direction. x and y are special variables in an object that correlate to the object's position inside the room, so by setting this x and y values we are actually moving our object around the screen. If so, we take "x" and set it equal to our current x value plus the value we determined for our movement speed along the x axis. That gives us the ability to reduce the values of our x and y positions without needing to have a positive and negative movement speed.įollowing that, we check to see if our x_axis or y_axis variables are anything other than 0. You'll notice that to move left or up we actually take our movement speed and multiple it by -1. The next set of "else if" statements do the same thing for the left, up and down arrow keys, setting our movement speed along the x or y axis as appropriate. "keyboard_check(vk_right)" will return true if the right arrow key is currently pressed, so we'd go ahead and set our movement along the x axis to be equal to the movement speed, and set the player direction to be equal to the macro "RIGHT", meaning right now we want to use the sprite "spr_player_right". This checks the current state of our keyboard to see if the right arrow key is being pressed. Next we used the function "keyboard_check" to check for "vk_right". The first two lines set our default movement to 0.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |