Platformers

From Game Editor

Jump to: navigation, search

For quick and simple directions for starting a platform Basics of a platformer This goes further into the makings of a platformer.

The most important actors that you will need to create are the main character and ground. Other actors may be items/powerups, enemies, doors, non-ground obstacles.

Main Character

In platformers, the main character can usually:

  • Walk
  • Run
  • Duck
  • Jump
  • Attack

Other things that the main character usually has:

  • HP
  • Powerups
  • Anything you want

Moving

The basics of moving would be left and right, changing the animation of your main actor. In many platformers, you can run when holding down a certain button. One of the biggest problem for people when making platformers is overcoming moonwalking. This takes steps through the basic walking up to more advance movement. To see the finished script events, for walking, running, ducking, jumping, and attacking, go to the bottom of this section.

There are many ways to make your actor move, for more choices, Moving. This is basic left right movement, not including running.

Main Character -> KeyDown event -> Left (Enabled) -> Script Editor

x-=4;
ChangeAnimation("Event Actor", "walk_left", NO_CHANGE);

Main Character -> KeyDown event -> Right (Enabled) -> Script Editor

x+=4;
ChangeAnimation("Event Actor", "walk_right", NO_CHANGE);

To run, usually, the player must press a button, and while it is pressed the main character will run. For this example, the run button will be [X]. This example does not utilize a separate variable, instead it is implemented within the move events.

Main Character -> KeyDown event -> Left (Enabled) -> Script Editor

char * key = GetKeyState();  // This allows you to use keys as variables, gets key state
if(key[KEY_x]==0) // Run button not pressed
{
    x-=4; // Walking speed
    ChangeAnimation("Event Actor", "walk_left", NO_CHANGE);
}
else if(key[KEY_x]==1)
{
    x-=7; // Running speed
    ChangeAnimation("Event Actor", "run_left", NO_CHANGE);
}

Main Character -> KeyDown event -> Right (Enabled) -> Script Editor

char * key = GetKeyState();  // This allows you to use keys as variables, gets key state
if(key[KEY_x]==0) // Run button not pressed
{
    x+=4; // Walking speed
    ChangeAnimation("Event Actor", "walk_right", NO_CHANGE);
}
else if(key[KEY_x]==1)
{
    x+=7; // Running speed
    ChangeAnimation("Event Actor", "run_right", NO_CHANGE);
}


To allow your actor to duck, you would add another keydown event changing the animation to that of the actor ducking. At this point, it becomes necessary to introduce a direction variable, as when pressing down, the actor does not know which way it is facing. So to do this, add a variable named dir, Creating variables. This variable will only hold two values, 0 and 1. To implement this, add in the keydown event left script

dir=1; // signifies left

And for the keydown event right, add

dir=0;

This way, when you add the keydown down script, it has a way of knowing which animation to choose from.

Main Character -> KeyDown event -> Down (Enabled) -> Script Editor

switch(dir)
{
    case 0: // right
    ChangeAnimation("Event Actor", "crouch_right", NO_CHANGE);
    break;
    case 1: // left
    ChangeAnimation("Event Actor", "crouch_left", NO_CHANGE);
    break;
}



INCOMPLETE---- will finish later