In this tutorial, we're gonna make a simple amazing bricks clone.
I’ll use “Obstacle” to refer the shorter obstacle, and “Wall” for the two longer obstacles.
1.) First, create the character. I call it “Player” on this tutorial. Add platform behavior to make the gravity effect, and set max speed to 0.
2.) For the obstacles, create another two sprites and name it “LeftWall”,“RightWall”, and “Obstacle” (for the smaller one). Add move to behavior to all of them with max speed = 600.
3.) To move the charater, first add a boolean “isDead” to determine whether the character is dead or not. Then, set it’s platform vector Y to -jump_strength (I use -600) on any touch start.
4.) Add a text global variable “DIRECTION” to set it’s movement.
If Player.X < Touch.X, set it’s movement to “right”. So the game knows that our player wants to move the character right. After that, do the otherwise to move left.
5.) Bound the character to stay inside the screen
6.) To create the obstacles, we’re gonna use function. First create a number local variable “left_wall_width”. This variable will be used to randomize our wall width.
7.) On start of layout, call function “Create()”. Then, whenever this function is called, randomize our wall with random(minimum_width,maximum_width). In this tutorial, I’ll use random(90,350).
8.) Add blank sub event, then create LeftWall at
X = ViewportLeft(0)-7
Y = ViewportTop(0)-100
And set it’s width to left_wall_width we made earlier.
9.) Create RightWall at
X = ViewportRight(0)+7
Y = ViewportTop(0)-100
And set it’s width to (ViewportLeft(0)+ViewportRight(0))-left_wall_width - gap_between_walls
10.) Create two Obstacles with Y = -150px (above) and 150px (below) the walls. Place them between the gap with
X = random(left_wall_width+15,left_wall_width+150)
11.) If Player.Y is almost in the middle of our screen height, move the walls and obstacles down 150px below.
More and More Obstacles!
12.) If LeftWall.Y is now reaching the middle of the screen height, call function Create() again to create another walls and obstacles.
Note that “isNew” boolean is used to make it only trigger one time for each LeftWall
If you try the game now, you’ll realize that the jump strength looks higher when MoveDown() function is called. So reduce it to -300 when it's called, else set it again to -600.
The result will looks like this :
Now you just have to tidy things up, and add another stuff like scoring, etc
The completed game can be played