Breakout extension - Sticky paddle

Stats

1,208 visits, 2,070 views

Translations

This tutorial hasn't been translated.

Tools

This is my first tutorial so I hope you like it

Haven't you played some breakout-style game which have a power up to make the ball stick to the paddle? Of course you do. Some breakout games like Brick Breaker Revolution (Digital Chocolate), Block Breaker Deluxe (Gameloft) or Smash Frenzy (Alawar) use the feature.

It's really simple to make the feature in Construct 2.

Key for the feature

The key for make the sticky paddle is the instance variables.

Resources

Maybe you have seen stemkoski's breakout tutorial, right? Use the graphics given by the tutorial. You can also make your own paddle and ball.

Workflow

Basic breakout movement

1.Create a new project.

2.Create a sprite, this will be our paddle. (Or drag and drop the paddle you have downloaded from stemkoski's tutorial.) Move it to the bottom of the layout.

3.Set the paddle's behavior with "8Direction" and "Solid". Set the directions to "Left & right". Also, set the "Set angle" to "No".

4.Preview the layout, you'll see that the paddle is moving sideways when you press the Left or Right key.

5.Create another sprite, this will be the ball. (Or drag and drop the ball you have downloaded from stemkoski's tutorial.) Move it to the center.

6.Set the ball's behavior with "Bullet". Set the "Bounce off solid" to "True" and "Set angle" to "False".

7.Preview the layout again, now you can see the ball is moving. But the ball is moving to the right.

8.Create a tiled background, this will be the wall. Create 3 instances of the wall, resize 2 of the walls to fit the layout's height. Resize the another wall to fit the layout's width. Align the walls to specific positions.

9.Set it's behavior to "Solid".

10.Preview again, the ball still goes to the right. But it will reflected when it collides the wall.

11.Now set the ball's angle to 45 degrees. This will make the ball goes to the bottom.

12.Preview again, the ball will go to the bottom. But with the paddle, you can rebound the ball back to the layout.

13.If the ball falls, it doesn't come back. So we add these events in the event sheet.

-Ball: Is outside layout

--Ball: Set position to (320,240)

--Ball: Set Bullet angle of motion to 280 degrees

These methods are the basics to breakout. But the method needs more improvements. Such as:

Precise rebound

Go to the event sheet and add this event.

-Ball: On collision with Paddle

--Ball: Set Bullet angle of motion to 270 + 75 * ( Ball.X - Paddle.X ) / (Paddle.Width / 2) degrees

This will make the ball rebound to the desired angle from the paddle.

Ball stick

1.Add instance variables to the ball.

-Boolean 1 - stick

--Value: true

-Number variable 1 - offset_x

--Value: 0

2.Next, add these events for the ball stick.

-Ball: Is stick

--Ball: Set position to (Paddle.X+Ball.offset_x, Paddle.Y-24 (ball height))

--Ball: Set Bullet Disabled

3.If you have a Keyboard plugin in the project, add these events to release the ball and deactivate the stick.

-Ball: Is stick

--Keyboard: On Shift pressed

---Ball: Set Bullet Enabled

---Ball: Set Bullet angle of motion to 270 + 75 * ( Ball.X - Paddle.X ) / (Paddle.Width / 2) degrees

---Ball: Set stick to False

Now, if you preview the project, you'll see the ball stick to the paddle. And if you press the Shift button on your keyboard, the ball releases from the paddle and move as usual.

Now for our target, sticky paddle!

Sticky paddle

1.Now we add a boolean to the paddle, name it as magnet (a good name for sticky paddle, I think), set the value to true.

2. Now update this event:

-Ball: On collision with Paddle

--Ball: Set Bullet angle of motion to 270 + 75 * ( Ball.X - Paddle.X ) / (Paddle.Width / 2) degrees

--Paddle: Is magnet NEW

---Ball: Set stick to true NEW

---Ball: Set offset_x to Ball.X-Paddle.X NEW

Preview the layout, now release the ball, and move your paddle until the ball collides the paddle. Now the ball was stick to the paddle.

You're done!

Now you can set the paddle's magnet boolean to false. Now you know how to make a sticky paddle, so how about a falling power up to make the paddle sticky?

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!