First open Game Maker 8.1 lite edition. Go to File > Advanced Mode. Make sure there is a check mark next to Advanced Mode. We will need this later.

Next will we need to add a sprite. You can do this in a number of ways:

  • You can click Resources > Create Sprite
  • Click the red pac-man looking icon
  • Right click the Sprites folder on the left side of the screen and select Create Sprite.

The best way to create sprites is to use sprite sheets. Here is a template you can use to create you own sprites!

I took off their heads so its easier to edit them. I know that kinda sounds wrong :)

Once you have created your ideal sprite its time to put it into Game Maker. In the Create Sprite screen select Edit Sprite. Then click File > Create from Strip. This allows us to create sprites using a sprite sheet.

Input these values if you are using the template:

  • number of image : 2
  • images per row : 2
  • image width : 16
  • image height : 16
  • horizontal pixel offset : 1
  • vertical pixel offset : 3
  • horizontal separation: 2

Name this sprite something similar to heroDown and repeat for all other directions. This blog will only be using 4 direction movement.

Next we will need some object to initialize some global variables. You can create on object using either:

  • Click Resources > Create Object
  • Click the blue ball icon
  • Right click the Objects folder and select Create Object

Name the object playerController or something similar. At the bottom click Add Event and select Create. This event only happens at the creation of the object. On the right hand side click the Control tab. Under the Code sub tab find Execute Code.

Now drag Execute Code under Actions like in the picture above. Double click Execute a piece and code and put this code in:

global.partySize = 3;

for(i = 0; i < global.partySize; i+= 1)
    global.partyMember[i] = “Rye”

global.partySize is the max size of your party in the game. We will be using this later on.

Next we do a for loop using global.partySize to determine the size of an array. We create an array global.partyMember[i] = “Rye” You should put the name of your main character in the quotations. I am using Rye.

Ok we are finished with the playerController select OK at the bottom left of the window. Next lets create our player object. Create another object and name it Hero. Make sure to give it a sprite. In the create event put in this code:

// Determines the object’s speed
playerSpeed = 4;

// Determines how fast the object is animated
image_speed = 0.2;

// Determines the order of the characters. 0 is the leader, 1 is the second party member, etc.
partyLocation = 0;

And then create a step event using Step and put in this code:

// Move the object on a grid of 32 x32 with a speed of playerSpeed
// Update sprite if speed is not 0
if playerSpeed > 0
Ok grid_snap and update_sprite are two scripts we need to create so lets do that next.

Create a script – in a similar fashion as you did with objects and sprites. Name the script grid_snap and put this in:

//Usage :  grid_snap(speed,placeSnapped)

speed        = argument0;
placeSnapped = argument1;

// Check to see if object is snapped to a grid with argument1
if place_snapped(placeSnapped, placeSnapped)
        // Change directions
        if keyboard_check(vk_left)
            direction = 180
        if keyboard_check(vk_right)
            direction = 0
        if keyboard_check(vk_up)
            direction = 90;
        if keyboard_check(vk_down)

// Set the speed to zero when no key is pressed
if (place_snapped(placeSnapped,placeSnapped)) && (!keyboard_check(vk_up))&& (!keyboard_check(vk_down))&& (!keyboard_check(vk_left))&&(!keyboard_check(vk_right))

And create another script called updateSprite:

//Usage : update_sprite(partyLocation,direction)

partyNumber = argument0;
direction   = argument1;

// Change sprites based on the character
if global.partyMember[partyNumber] = “Rye”
    if direction = 0
        sprite_index = ryeRight;
    if direction = 90
        sprite_index = ryeUp;
    if direction = 180
        sprite_index = ryeLeft;
    if direction = 270
        sprite_index = ryeDown;

All you have left is to create a room and put the Hero object and playerController object in it. Run the game with F5 and test it out!

Next Post Monday: Party Movement.

About these ads

7 responses »

  1. I love the efforts you have put in this, thank you for all the great posts.

  2. Justin says:

    I keep getting an error on the – if global.partyMember[partyNumber] = “Rye” – line. Any ideas?

    • retrorpgs says:

      Sounds Like An Array Out Of Bounds Error.

      First Thing You Will Want To Do Is Make Sure Everything Is Defined Correctly.

      In The Player Controller Object:
      Make Sure Global.Partymember Is Being Set To Some Value.

      global.partySize = 3;

      for(i = 0; i < global.partySize; i+= 1)
          global.partyMember[i] = “Rye”

      In The Hero Object:
      In The Create Event Make Sure That

      partyLocation = 0;

      partyLocation Must Always Be In Bounds Of 0 And Global.partysize-1

      If That Does Not Fix It:
      Go To The Script update_Sprite


      // Change sprites based on the character
      if global.partyMember[partyNumber] = “Rye”

      Change partyNumber To 0. Only Do This For Testing.

    • Halden says:

      The quotation marks on my GameMaker platform are not recognized so just try re-typing them

      Let me know if it worked

  3. GamerDaddy says:

    Having trouble with this ( ). Not too sure why it’s not liking the: “sprite_index = branksRight;” line…

    • retrorpgs says:

      Hi GamerDaddy,

      Thanks for the screenshot. This helps me discover the problem faster. Whenever you get a variable get error that means that Game Maker cannot find the resource. It usually means the resource / variable has not been defined. Make sure you have a sprite called branksRight. That should solve the problem.

  4. Halden says:

    NVM I fixed it :D

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s