Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[Tutorial] 2D RPG Movement

This tutorial will explain how to create 2D RPG style movement in your game maker game.

First of all we need a characterset. The one I will be using is:

sprite1.png

(c) REFMAP used without permission for example purposes only


First right click "sprites" and click "create new".
Click "load sprite" and choose the characterset you want to use.
Click "Edit sprite".


You will notice at the moment the whole image is your sprite. We need to splice it into individual subimages.


Click "File" > "Create from strip". Choose your sprite image.


Now set the height and width of each sprite, and how many images there are in total. In my example there are 12 images, which are 24 pixels wide, and 32 pixels high. Click done and your sprites are created. You now have one sprite made up of 12 (or 16, or however many) subimages.


Create an object called "obj_player" and give it the sprite you just created as it's sprite.


You need the following events in this object:


Please note: the "move left" is however you will be moving your player. In my game this is done differently as I'm using an online dll - so, you'll have to work that bit out yourself. I think "move fixed" should help you.


CREATE
  • Change sprite to your_sprite, subimage 0, speed 0
  • Excecute code [ step = 0 ]


KEYBOARD - LEFT
  • Move left
  • Set variable: step = 1 relative
  • IF variable step = 10
    • change sprite: your_sprite, subimage = 9
  • IF variable step = 20
    • change sprite: your_sprite, subimage = 10
  • IF variable step = 30
    • change sprite: your_sprite, subimage = 11
  • IF variable step = 40
    • change sprite: your_sprite, subimage = 10



What is basically happening here is the event is adding 1 to a variable every pixel the player moves. When they move a certain amount of pixels the sprite changes to the next in the walking cycle.



You should note the 9, 10, 11, 10, are just examples relative to the sprite above. Your numbers will most certainly be different - they read lef to right, top to bottom, like so:


0 . 1 . 2
3 . 4 . 3
6 . 7 . 8
9 .10.11


You need to duplicate the LEFT event four times - once for each direction, and change the subimages accordingly.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top