Snake
1 Basic Movement

Section Menu

Snake Home | 1 | 2 | 3 | 4 | 5

Introduction - Please Read Before Starting

This game is quite tricky to do. Making the snake body follow the snake head is easiest to achieve by using some Game Maker Language (GML). If you have no experience of programming, you may find the explanations very difficult to follow.

Create Sprites & Objects

Create 2 sprites, spr_head and spr_body and load the images you were given.

Create 2 solid objects using these sprites, call them obj_head and obj_body.

Basic Movement

Add a room to your game and plonk the snake head object somewhere in the room.

Now return to the snake object window and add a Create Event. Drag in a Move Fixed icon and start the snake head moving to the right at a speed of 5. You will be removing this event later but will need it now to get the snake head moving.

The movement of the snake will be controlled using Key Press Events for each of the arrow keys. Start by adding a Key Press Event for the left arrow key. Drag in a Set Variable icon and fill in the window as shown,

Game Maker Screenshot

This tells Game Maker that the movement should now be to the left. The diagram below explains how angles are used in Game Maker.

Game Maker Screenshot

Therefore, the direction of movement should be set as follows,

  • LEFT - 180
  • RIGHT - 0
  • UP - 90
  • DOWN - 270

Add the appropriate actions to allow movement in all four directions.

Save and test the work that you have done so far.

⇐ Previous | Next ⇒