I know, there are loads and loads of better articles out there about platform engines. But I just cant help myself.




Setting Up

Firstly, create a character. Call it player for now.

Then, make 4 objects. The detectors need to be and names as shown:

Left Detector: 1 x Player Height
Right Detector: 1 x Player Height
Top Detector: Player Length x 1
Bottom Detector: Player Length x 1
(Make sure the hot spots and action points are always on 0)

Next, create a background object and set it as an obstacle. Place the background object around the screen and make a few in mid-air.

Goto the event editor and create these events:

+Always
-Set x(Left Detector) to x left(Player)
-Set y(Left Detector) to y top(Player)
-Set x(Right Detector) to x right(Player)
-Set y(Right Detector) to y top(Player)
-Set x(Top Detector) to x left(Player)
-Set y(Top Detector) to y top(Player)
-Set x(Bottom Detector) to x left(Player)
-Set y(Bottom Detector) to y bottom(Player)

+Start of Frame
-Make Left Detector invisible
-Make Right Detector invisible
-Make Top Detector invisible
-Make Bottom Detector invisible

The first event is to place the detectors to where they need to be in relevance to the Player.
The second one is seperate so we can just delete and make the actions again easily.




Horizontal Movement

For horizontal movement, we will use Alterable Value A.

Add these events:

1)
+Repeat while Right Arrow is pressed
+Alterable Value A (Player) < 5
-Add 1 to Alterable Value A (Player)

2)
+Repeat while Left Arrow is pressed
+Alterable Value A (Player) > 5
-Sub 1 to Alterable Value A (Player)

3)
+Repeat while Right Arrow is pressed (Negate)
+Repeat while Left Arrow is pressed (Negate)
+Alterable Value A (Player) <> 0
-Set Alterable Value A (Player) to 0

4)
+Only one action when event loops
+(Right Detector) is overlapping a backdrop
-Set Alterable Value A (Player) to 0

5)
+Only one action when event loops
+(Left Detector) is overlapping a backdrop
-Set Alterable Value A (Player) to 0

6)
+Alterable Value A (Player) <> 0
-Start loop Horizontal Abs(Alterable Value A (Player))

7)
+On loop* Horizontal
+Alterable Value A (Player) > 0
+(Right Detector) is overlapping obstacle (Negate)
-Set X position (Player) to X position (Player) + 1

8 )
+On loop* Horizontal
+Alterable Value A (Player) < 0
+(Left Detector) is overlapping obstacle (Negate)
-Set X position (Player) to X position (Player) - 1

9)
*After every On loop action, add:
-Set x(Left Detector) to x left(Player)
-Set y(Left Detector) to y top(Player)
-Set x(Right Detector) to x right(Player)
-Set y(Right Detector) to y top(Player)
-Set x(Top Detector) to x left(Player)
-Set y(Top Detector) to y top(Player)
-Set x(Bottom Detector) to x left(Player)
-Set y(Bottom Detector) to y bottom(Player)

Ok, now lets explain.

The first three events control how fast the character moves by adding and subtracting from Alterable Value A.

Number four and five test to see if any detector is overlapping an obstacke and stops the player if it is.

6 tests to see if the player is meant to move. If you are meant to move, it starts Loop Horizontal however many times Alterable Value A is. Abs means that if Alterable Value A is a negative number. It makes the loop loop a positive number because you cant have negative loops.

The 7th & 8th add or subtract the player position depending on what Alterable Value A is.

Lastly, you need to add those positioning actions because the detectors lag behind resulting in you getting stuck in the background.




Jumping and Gravity

Jumping and gravity are easy. Similar to Horizontal. But Alterable Value B is used this time.

+2 new groups
-Jumping
-Gravity


Event:

1)
+Upon pressing Shift
+(Bottom Detector) is overlapping an object
-Set Alterable Value B (Player) to -11

2)
+(Bottom Detector) is overlapping an object (Negate)
-Add 1 to Alterable Value B (Player)

3)
+Alterable Value B (Player) > 0
+(Bottom Detector) is overlapping an object
-Set Alterable Value B (Player) to 0

4)
+Alterable Value B (Player) < 0
+(Top Detector) is overlapping an object
-Set Alterable Value B (Player) to 0

5)
+Alterable Value B <> 0
-Start loop Vertical Abs(Alterable Value B (Player))

6)
+On loop* Vertical
+Alterable Value B (Player) > 0
+(Bottom Detector) is overlapping obstacle (Negate)
-Set Y position (Player) to Y position (Player) + 1

7)
+On loop* Vertical
+Alterable Value B (Player) < 0
+(Top Detector) is overlapping obstacle (Negate)
-Set Y position (Player) to Y position (Player) - 1

If you read the rest of this article, you will know what most of the events mean.

On number 1, you are only able to jump when you are touching the ground. Experament with -Set Alterable Value B to -11 by changing -11 to change the height you jump.

Remember to place events in groups.
I used 5:
Loops
Gravity
Jumping
Horizontal Movement
Misc



The End


Part II:
→Springs
→Water
→Double Jump
→Bounce Jump
→Terminal velocity


Please tell me if you find any spelling errors or mistakes.