GAME:IT JuniorBreakOut
Objectives: • Using old and new skills, develop a game similar to the original “BreakOut”
• Destroy blocks and gain points.
• Create a game that transitions from room to room, once all the blocks are gone.
• After 3 balls are lost, the game will end.
Create 11 sprites for Game4. They are located in the Game4 Resources folder. NAME THEM AS INSTRUCTED.
spr_paddle spr_ball spr_block_yellowspr_block_blue spr_block_green spr_block_hotpinkspr_block_orange spr_block_purple spr_block_red spr_wall spr_miss
*All sprites should have the Precise Collision Checked
Before you start, you must go into “Advanced Mode”.
We are just going to learn a few basic “BreakOut” skills and the assignment will be for you to expand these skills.
Start by creating these 11 objects:
1)obj_paddle – Visible and Solid should be checked
2)obj_wall - Visible and Solid should be checked
3)obj_ball - Visible and Solid should be checked
4)obj_block_yellow - Visible and Solid should be checked
5)obj_block_blue – Visible and Solid should be checked
6)obj_block_green – Visible and Solid should be checked
7)obj_block_orange – Visible and Solid should be checked
8)obj_block_hotpink – Visible and Solid should be checked
9)obj_block_purple – Visible and Solid should be checked
10)obj_block_red – Visible and Solid should be checked
11)obj_miss - Only Solid should be checked
Create a simple room using only the blue and yellow blocks at first. Later you will be able to start adding the other color blocks to every room, but for now use only those colors. You can use as many of those as you would like in this first room It does NOT have to look like this one:
The paddle, wall and miss are programmed similar to the skills you learned in paddle ball and ping pong.
obj_miss: No programming
obj_wall: No programming
obj_block_yellow: No programming
obj_block_blue: No programming
obj_block_purple: No programming
obj_block_red: No programming
obj_block_green: No programming
obj_block_hotpink: No programming
Event 2: Keyboard Event - Select <No Key>
Action: Move FixedApplies to: SelfSelect center button only Speed = 0Relative is NOT checked
Event 1: Collision with obj_wall
Action: Move FixedApplies to: SelfSelect center button only Speed = 0Relative is NOT checked
obj_paddle:
Add 4 Events
obj_paddle (continued):
Event 4: Keyboard Event - Select <Right>
Action: Move FixedApplies to: SelfSelect Right Arrow only Speed = 5Relative is NOT checked
Event 3: Keyboard Event - Select <Left>
Action: Move FixedApplies to: SelfSelect Left Arrow only Speed = 5Relative is NOT checked
obj_ball:
Event 1: Create
Action 1: Move FixedApplies to: SelfSelect the Up Arrow, Upper Left Corner & Upper Right Corner Arrows Speed = 7Relative is NOT checked
This object will need 8 Events:
obj_ball (continued):
Event 2: Collision with obj_paddle
Action 1: Bounce against solid objectsApplies to: SelfPrecise = PreciselyAgainst = Solid Objects
Action 2: Set VariableApplies to: SelfVariable: SpeedValue: .2Relative IS checked
What does the Set Variable action do?
It increases ball speed each time it collides with paddle by a speed of .2
obj_ball (continued):
Event 3: Collision with obj_wall
Action 1: Bounce against solid objectsApplies to: SelfPrecise = PreciselyAgainst = Solid Objects
Event 4: Collision with obj_block_blue
Action 1: Bounce against solid objectsApplies to: SelfPrecise = PreciselyAgainst = Solid Objects
Action 2: Set ScoreNew Score: 10Relative IS checked
obj_ball (continued):
Event 4: Collision with obj_block_blue (continued)
Action 3: Destroy InstanceApplies to: Other
If you selected Applies to: Self, the ball would be destroyed.
If you selected Applies to: Object and select obj_block_blue from the drop down, all instances of that object in the room will be destroyed.
Selecting Applies to: Other destroys only the block that the ball collides with.
obj_ball (continued):
Event 5: Collision with obj_block_yellow
Action 1: Bounce against solid objectsApplies to: SelfPrecise = PreciselyAgainst = Solid Objects
Action 2: Set ScoreNew Score: 15Relative IS checked
Action 3: Destroy InstanceApplies to: Other
How do you program the game to move to a 2nd or 3rd room when all blocks are gone?
The key is a new action we haven’t used calledTest Instance Count:
When this action is true, it acts as a gateway to allow you change something within the game. If it comes back false, it just continues on with the original program.
Test Instance Count
TrueFalse
Continue with what you are doing!
Go to a New Room
But how do you get it to check it—and check it continuously?
A new Event called Step.
Step allows something to be checked every step (or millisecond)—continuously.
The only way it could be stopped is if the item is destroyed, so don’t attach the Step Event to the blocks.
So what we want to check is if there are any blocks left in the room. Because there are multiple items that need to be checked (different colored blocks), you will need to create what is called a “nested” loop.
See the next page for an example.
Are there any yellow blocks?
NOTE: Each of the “loops” contains a Start block and an End block
When all Test Instance Counts come back true, it checks If next room exists—if it does—it will Go to next room!
Are there any blue blocks?
This will check to see if the number of obj_block_blue is equal to 0.
If this is true (it equals 0), it will check the next Test Instance Count (which will be for obj_block_yellow).
obj_ball (continued):
Event 6: Step
Action 1: Test Instance Countobject: obj_block_blue (select from dropdown)number: 0operation: Equal to (select from dropdown)
Action 2: Start Block
Action 3: Test Instance Countobject: obj_block_yellow (select from dropdown)number: 0operation: Equal to (select from dropdown)
Action 4: Start Block
obj_ball (continued):
Event 6: Step (continued)
Action 5: Check Next
Action 6: Next Room
Action 7: End Block.
Action 8: End Block (to close the check blue blocks loop)
This will require 2 more events.
Event 7: Other > Game start
Action 1: Set Score New Score = 0Relative is NOT checked
Action 2: Set livesLives: 3Relative is NOT checked
“After 3 balls are lost, the game will end and the score will be displayed on the high score table.”
FYI - Balls equates to “lives”
obj_ball (continued):
Event 8: Collision with obj_missThere are 9 Actions for this object
Action 1: Set lives Lives: -1Relative IS checked(this reduces the lives as balls are lost)
Action 2: Test livesValue: 0Operation: equal to(this checks to see if there are any remaining lives)
Action 3: Start Block
obj_ball (continued):
Event 8: Collision with obj_miss (continued)
Action 4: End Game
Action 5: End Block(remember, every timethere is a Start Block, you will need an End Block)
Event 8: Collision with obj_miss (continued)Action 6: Jump to Start PositionApplies to: Object - select obj_paddle from menu
Action 7: Jump to Start PositionApplies to: Self
These two actions put the paddle and ball back to the start position once the ball is lost if there are any lives remaining.
Action 8: Execute a piece of code This will be typed into the /// Create the pause object, pausing the gameinstance_create(0,0,obj_pause);
Copy and paste this into the box that pops up
Action 9: Move FixedApplies to: SelfDirections: the 3 up arrowsSpeed: 7Relative is NOT checked
Event 9: Draw GUI
Action 1: Draw the Value of Score. X value of 200 and Y value of 20. Caption is Score:
Action 2: Draw the number of lives. X value is 40 and the Y value is 20. Caption is Lives:
obj_ball (continued):
Create obj_pause – will have four events
1st – Create Event -
– Action: Execute a piece of code – (type this into the script)
– If you forget this action gor to slide 22 to find it
/// Create surface, draw everything to it, deactivate all other objects
surf = surface_create( room_width, room_height );
surface_set_target(surf);
draw_clear_alpha(c_black, 0); // Clears surface.
with(all) { if (visible == true) { event_perform(ev_draw,0); } } // Draws every visible object to surface.
surface_reset_target();
instance_deactivate_all(true);
visible = true;
2nd Event – Draw
Action – Execute a piece of code (type this into the script)
/// Draw the surface to the screen
draw_surface(surf, 0, 0);
3rd Event – Draw GUI
Action 1 – Draw Text
Applies to self
X = 200
Y = 100
Action 2 – Set the color
Select a color that stands out (like blue)
obj_pause (continued)
4th Event – Keyboard– Space Bar
Action 1 – Execute a piece of code (type this into the script)
/// Unpause, clear surface, re-activate all objects.
surface_free(surf);
instance_activate_all(); // Activate all the objects again
Action 2 – Destroy the instance
Applies to Object: obj_pause
This object makes a pause in between each ball you miss. First event keeps everything the same. Second event draws a pause scree. Third event gives you the text saying press the space bar. And the fourth event gets rid of the pause on the ball and making the game resume.
obj_pause (continued):
Assignment
Complete this game to play as described:
The game has at least 3 rooms. When you destroy all blocks from Room 1, you go to Room 2 and then onto Room 3 etc. It has to test all the color blocks
Utilize all color blocks (total of 7) – each with a different point value
Remember the shortcut for the collision with the blocks. There should be a collision event with every block. After 3 balls are lost, the game ends.
Save as Game4