Skip to content

A2 - Creating a Character

In this assignment, you will create a chracter and integrate it into your game.

Resources for this Assignment

Part 1 Steps - Creating the Character

  • Go to Vitruvian Studio

  • Go through the various options on the lefthand side to create a character to your liking

  • Click the purple Save button near the righthand side

  • Click the purple renderings button - at the far right, last button down in the group of three, with an icon that looks like a folder with triangles on it.

  • Click Download All.

  • Unzip the folder.

Part 2 Steps - Creating the Sprites

  • In GMS, create a new sprite and name it spr_player_walk_left

  • Click the button to import an image, then from your folder of spritesheets from the previous step choose walk.png

  • Click the Edit Image button

  • In the Image menu at the very top, choose Convert to Frames. Use the following settings:

    • Number of Frames: 8
    • Frames per Row: 8
    • Frame Width: 64
    • Frame Height: 64
    • Vertical Cell Offset: 1
  • Click the Convert button

  • Back in the Image menu, select Auto Trim All Frames

  • You can test the animation by pressing the play button (triangle icon). You will probably want to slow down the frame rate - look for the FPS setting at the bottom-left of the screen. I'd recommend about 10.

  • Optional for now (but you'll need to do it eventually) - adjust the collision mask for the sprite as demonstrated in the video and in class

  • Repeat this process for the other animations (right, up, and down). In the Convert to Frames step, you'll need to adjust the Vertical Cell Offset setting to select the row from the spritesheet you want to isolate.

  • In the asset manager, right-click the Object folders and create a new object.

  • In the window that opens, click the No Sprite button, and choose the player_walk_down sprite

  • In the Events window, click Add Event --> Step --> Step

  • Choose GML Code if asked

  • Paste in the following code:

Player Object Step Code
var move_speed = 4;

// Input
var h_input = keyboard_check(vk_right) - keyboard_check(vk_left);
var v_input = keyboard_check(vk_down) - keyboard_check(vk_up);

// Movement
x += h_input * move_speed
y += v_input * move_speed

// Animation - prioritize horizontal movement if both are pressed
if (h_input != 0) {
    if (h_input > 0) {
        sprite_index = spr_player_walk_right;
    } else {
        sprite_index = spr_player_walk_left;
    }
} else if (v_input != 0) {
    if (v_input > 0) {
        sprite_index = spr_player_walk_down;
    } else {
        sprite_index = spr_player_walk_up;
    }
}

// Play animation when moving, stop when idle
if (h_input != 0 || v_input != 0) {
    image_speed = 1;  // Adjust to control animation speed
} else {
    image_speed = 0;
    image_index = 0; // Freeze on first frame
}
  • Close the object and open your room

  • Drag the player from the asset manager to a location of your choice on the room map

  • Run the project (triangle button in the top icon bar) and use the arrow keys to move your player