How do I make my platformer game, act like a platformer game?

In traditional platformer games you would have a rectangular room where the player can move left or right. And depending on which direction you move in, more of the level will be revealed to you, as you go. How do I do that in gamemaker? As of right now, I just have a square room for a level. Where the player will fall to her death, if she gets too close to the edge. Thanks in advance! Can't wait to get to know you all. :D
 

Niels

Member
Easiest way is to make the room 1 screen high and multiple screens wide, then activate a viewport and keep the camera centered on the players x position
 

Joe Ellis

Member
Moving the view is the key and there are alot of ways you can deal with it.
Alot of platformer games have a smoothness of the view, basically moving with the player but gradually,
normally using lerp. eg. view_x = lerp(view_x, player.x + x_offset, 0.2)
Some even switch the x offset depending which direction the player is facing.
Some have border points, like if the player moves upwards to a certain part of the screen the view will move up with it.

Once you get used to moving the view you should be able to achieve whatever you're thinking of doing..

You can also do it manually without using the built-in view variables by creating & setting the view & projection matrices:

GML:
//At start of game

global.matrix_projection = matrix_build_projection_ortho(screen_width, screen_height, znear(1), zfar(10000))
Then in the step event update the view matrix:

GML:
global.view_matrix = matrix_build_lookat(global.view_x, global.view_y, -1, global.view_x, global.view_y, 1, 0, -1, 0)
Then in the draw begin event set the two matrices before anything is drawn:

GML:
matrix_set(matrix_projection, global.projection_matrix)
matrix_set(matrix_view, global.view_matrix)
 
Top