Breakout. Level 3 Extended Diploma Unit 22 Developing Computer Games

Similar documents
Assignment #3 Breakout! Due: 12pm on Wednesday, February 6th This assignment should be done individually (not in pairs)

Step 1. CoderDojo Milltown Exercise 1 Pong Page 1 of 13

Based on a handout by Eric Roberts

Assignment 3: Breakout!

Lab 4 VGA Display Snake Game

Assignment #3 Breakout!

SCRATCH CHALLENGE #3

Start a new Scratch project. Delete the cat by right-clicking it and selecting Delete.

Assignment A7 BREAKOUT CS1110 Fall 2011 Due Sat 3 December 1

LEO SEM SOP Page 1 of 9 Revision 1.4 LEO 440 SEM SOP. Leica Leo Stereoscan 440i

SmartMan Code User Manual Section 5.0 Results

3. Select a colour and then use the Rectangle drawing tool to draw a rectangle like the one below.

Table Football. Introduction. Scratch. Let s make a world cup football game in Scratch! Activity Checklist. Test your Project.

You are going to learn how to make a game, in which you ll use the mouse to navigate a boat to a desert island.

Area, Volume, and Center of Mass

Hitting Your Marks on the Drag Strip

Get it here. Page 1 of 7 Date:Jan 8, 2014

Organizing Quantitative Data

In this project you ll learn how to create a football game in which you have to score as many goals as you can in 30 seconds.

ROSE-HULMAN INSTITUTE OF TECHNOLOGY Department of Mechanical Engineering. Mini-project 3 Tennis ball launcher

Technology. Using Bluetooth

The ICC Duckworth-Lewis Calculator. Professional Edition 2008

Lesson 2.1 Frequency Tables and Graphs Notes Stats Page 1 of 5

CS Problem Solving and Object-Oriented Programming Lab 2 - Methods, Variables and Functions in Alice Due: September 23/24

Sinclair QL retro gaming

LX Compass module 3 Electronic compass device User manual

Bachelor of Computer Applications (Semester-2) Subject Name: Project in C Subject Code: BCA 205. General Guidelines for Project in C

Boat Race. Introduction. Scratch. You are going to learn how to make a game, in which you ll use the mouse to navigate a boat to a desert island.

Law 1 The Field of Play

Robocup 2010 Version 1 Storyboard Prototype 13 th October 2009 Bernhard Hengst

Write Your Own Twine Adventure!

SENSUS PRO MANAGER (for SENSUS or SENSUS PRO devices) User s Guide -- Windows. Version 2.0 Published October 17, ReefNet Inc.

LESSON 5: THE BOUNCING BALL

survey/doa5lr/

Technology. Using Bluetooth

Background Information. Project Instructions. Problem Statement. EXAM REVIEW PROJECT Microsoft Excel Review Baseball Hall of Fame Problem

Pedestrian Scenario Design and Performance Assessment in Driving Simulations

National Curriculum Statement: Determine quartiles and interquartile range (ACMSP248).

Virtual Fishing Tournament Mode English Translations

Describing a journey made by an object is very boring if you just use words. As with much of science, graphs are more revealing.

Perimeter. Perimeter is the distance around a shape. You can use grid. Step 1 On grid paper, draw a rectangle that has a length

Hydrus 1D Tutorial. Example: Infiltration and drainage in a large caisson. 1) Basic model setup. Sebastian Bauer Geohydromodellierung

The ICC Duckworth-Lewis-Stern calculator. DLS Edition 2016

Boyle s Law: Pressure-Volume Relationship in Gases

Project: Tanks CSE/IT 107. NMT Department of Computer Science and Engineering. Intro to Tank! Tank! Tank!, Bandai Namco

2013 Excellence in Mathematics Contest Team Project Level I (Precalculus and above) School Name: Group Members:

Northern SC U12 Playing Formats 8v8 (7 field players + 1 GK)

Horse Farm Management s Report Writer. User Guide Version 1.1.xx

Phet Wave on a String Simulation!

FF Chartwell User Manual. FontFont.com

Figure 1 Example feature overview.

Northern SC U6 Playing Format 3v3

Wiimote in Physical Etoys

Dive Planet. Manual. Rev Basic User Interface. 2 How to organize your dives. 3 Statistics. 4 Location Service and Map View.

Prerequisite skills: The students need have a basic understanding of scatter plots.

Race Area Analyzer Solent

Math 116 Practice for Exam 1

MoLE Gas Laws Activities

2015 FHSPS Playoff May 16, 2015 Online

HOW TO CREATE PHOTO TWIRLS

BBoard PONG game. Creative Computing #1

Gas Pressure and Volume Relationships *

Jeddah Knowledge International School. Science Revision Pack Answer Key Quarter 3 Grade 10

Race Screen: Figure 2: Race Screen. Figure 3: Race Screen with Top Bulb Lock

Experiment 11: The Ideal Gas Law

C# Tutorial - Create a Pong arcade game in Visual Studio

MEMORANDUM. Stefanie Sparks Smith, Secretary-Rules Editor NCAA Women s Lacrosse Rules Committee.

Robot Soccer Challenge

Lab 5: Forces on Submerged Objects

CITY OF MISSION VIEJO BUILDING SERVICES DIVISON 200 CIVIC CENTER MISSION VIEJO, CA (949)

TECHNICAL NOTE HOW TO USE LOOPERS. Kalipso_TechDocs_Loopers. Revision: 1.0. Kalipso version: Date: 16/02/2017.

How-to Edit/Delete a Score

Darts CHAPTER 6. Next are seven sounds: snd_double_points snd_triple_points snd_take_cover snd_perfect snd_thud_1 snd_thud_2 snd_thud_3

Appendix C. TRAFFIC CALMING PROGRAM TOOLBOX

Boyle s Law: Pressure-Volume Relationship in Gases

User Guide. Two-Wheeled Add-on. Created By: A-Lab Software Limited. Date Created: Feb Date Modified: Feb Revision: 1.

TANDRIDGE CANOE POLO REFEREE RULES For current National League Rules, visit

Boat Race. Introduction. Scratch

BEFORE YOU OPEN ANY FILES:

CONSUMER MODEL INSTALLATION GUIDE

A Study of Olympic Winning Times

AIR FLOW ANEMOMETER INSTRUCTION MANUAL

Two-Dimensional Motion and Vectors

MoLE Gas Laws Activities

Cricket umpire assistance and ball tracking system using a single smartphone camera

How long would it take to escape from the pendulum?

Statistical Process Control Basics. LeanSix LLC

E/ECE/324/Rev.1/Add.47/Rev.9/Amend.2 E/ECE/TRANS/505/Rev.1/Add.47/Rev.9/Amend.2

If you need to reinstall FastBreak Pro you will need to do a complete reinstallation and then install the update.

Side Length, Perimeter, and Area of a Rectangle

Learning to Interpret My GPS Files

2.6 Related Rates Worksheet Calculus AB. dy /dt!when!x=8

2. A homemade car is capable of accelerating from rest to 100 km hr 1 in just 3.5 s. Assuming constant acceleration, find:

Date: December 2014 Staff: T Millington, A Hooper Equipment used: Leica AT401 Laser Tracker, 1.5 SMR, Spatial Analyzer software

OFFICIAL VOLLEYBALL RULES

Survey Technical Support Notes October 2015

Mission Statement. To deliver the highest standards of excellence in soccer development to everyone.

XC2 Client/Server Installation & Configuration

THE DIGI LOGO BRAND ELEMENTS. The new Digi logo is based on precision, technology, and connection.

Cover Page for Lab Report Group Portion. Head Losses in Pipes

Transcription:

Breakout Level 3 Extended Diploma Unit 22 Developing Computer Games

Currently... To make the ball move we had 3 files: MoveRect.html MoveRect.js MoveRect.css We also know how to make a bouncing ball Our aim is to make a game where a bouncing ball is directed by a moving paddle to break down a wall of bricks - Breakout

Rename the files Start by copying and renaming: MoveRect.html to Breakout.html MoveRect.js to Breakout.js MoveRect.css to Breakout.css Modify Breakout.html so that it calls the Breakout files instead of the MoveRect files Check that it works as expected

Make the ball bounce Take this code from the bouncing ball example if( x<0 x>300) dx=-dx; if( y<0 y>300) dy=-dy; x+=dx y+=dy And paste it below circle(x, y, 10); in the draw function in Breakout.js Check that the ball now bounces

Change the boundaries The ball is constrained to a 300 x 300 rectangle Replace the values of 300 with canvas.width and canvas.height if( x<0 x>canvas.width) dx=-dx; if( y<0 y>canvas.height) dy=-dy; The ball will now bounce in the rectangle

Use of variables If canvas.width is too much to type you can create a new variable and use that E.g. var width = canvas.width; // width of canvas etc

Add a paddle Declare variables and initialise the paddle: Add these in the declarations var paddlex; (initial position) var paddleh; (height) var paddlew; (width) Initialise the paddle by adding this function function init_paddle() { } paddlex = canvas.width/2; // Center of canvas paddleh = 10; paddlew = 75;

Initialise and draw the paddle Add this line after the init(); init_paddle(); // Initialise the Paddle Add this line after the circle(x, y, 10); in the draw function rect (paddlex, canvas.heightpaddleh,paddlew, paddleh); This should draw a red rectangle 75 x 10 pixels starting halfway along the bottom

Screenshot

Bouncing off the paddle We want the ball to only bounce off the paddle. If it misses the paddle the game should end. We can do this by: If the ball y position is greater than the height { If the ball x position is greater than paddle x and less than paddlex + paddlew then bounce; Else game over } pseudocode

Paddle bounce code Add this after the if( y<0 y>canvas.height) dy=-dy; in the draw function else if (y + dy > HEIGHT) { if (x > paddlex && x < paddlex + paddlew) dy = -dy; else //game over, so stop the animation clearinterval(intervalid); } The game will now stop every time as the ball misses the paddle

Test the bounce Change the initial value of paddlex so that it is positioned at the right paddlex = WIDTH/1.2;

Moving the paddle We need a variable to set the amount the paddle will move by var paddledx = 5 We already have a function which detects key presses, but we only need horizontal movement, so delete the cases for the up and down arrow keys We now replace the code which varied x and y with code to vary paddlex

Varying paddlex function dokeydown(evt){ switch (evt.keycode) { case 37: /* Left arrow was pressed */ paddlex -= paddledx; break; case 39: /* Right arrow was pressed */ paddlex += paddledx; break; } }

Results The paddle should move left and right The ball should bounce off the paddle The game should stop when the ball misses the paddle

Problems! The ball is too fast The paddle is too slow The paddle restarts the game The paddle disappears off screen Change the variables paddledx and the value of setinterval(draw, 10) to make the game playable

Prevent restarts The code to stop the game is: clearinterval(intervalid); But the variable intervalid does not exist So we need to modify the code in the init function from: To return setinterval(draw, 20); intervalid = setinterval(draw, 10); return intervalid;

Next lesson we add the bricks In the meantime see if you can prevent the paddle from disappearing off the screen

Paddle and Ball - data Width 0,0 Width,0 x,y Height radius 0,height Paddlex/paddley Paddlex+paddlew /HEIGHT-paddleh Width/height paddledx paddlew

Comment your code Comments provide Identifies Author. Provides a date stamp Provides a history of changes and by whom. explanation of functions. what lines of code do. Help with code structure. Should be used in conjunction with meaningful names.

Comment your code Should NOT be overused, could make code flow more difficult to follow. Can help identify areas of code to be re-factored. You can use // and or /*..*/ or <!-- --> Activity Add appropriate comments to your Breakout.js file. Make sure your code still runs.

Comments Example // Breakout Game // Written by your name Date Feb/March 2013 // Uses the HTML5 Canvas // List of Variables var dx = 5; /* horizontal move speed of the ball */ var dy = 5; /* vertical move speed of the ball */ var x = 150; /* Center position of ball on the horizontal axis */ etc // Initialise the Paddle // at the bottom of the game window function init_paddle() { etc

Refactor the Ball Collision Take the code that does the ball collision and move it into a new function called ballcollision. Test your code still works.