
Apply practical learning tips for this breakout game course, including checking syntax errors, comparing with the finished project, using Google to answer common questions, and leveraging pause, speed, and replay.
Set up a breakout game project with an html boilerplate, a css reset, and a canvas, then draw a red rectangle using the 2d context.
Develop practice drawing shapes on the canvas by using beginPath, arc, fill, and stroke to render a green circle and a semi-transparent rectangle, preparing for movement in the breakout game.
Learn canvas coordinate system with a top-left origin, move the ball by updating x and y with the plus equals operator, and clear the canvas every frame to remove trails.
implement collision detection to bounce a ball off all four canvas edges, using a ball radius and velocity components to reverse direction when hitting boundaries.
Update the collision detection to bounce at the ball's edge, not the center. Subtract the ball radius from height and width checks to stop sinking into walls on both axes.
Draw a paddle on a canvas and move it with left/right arrows, using keydown and keyup to keep it within the game boundaries.
Set up a 3x5 brick field for the breakout game, defining brick size, padding, and offsets, storing bricks in a two-dimensional array and drawing them on the canvas.
Explore brick collision detection for a breakout game by checking the ball center against bricks, bouncing the ball, and deactivating bricks with a status flag for redraw and score.
Track and display the score on the canvas as bricks disappear when the ball hits them, updating the score each frame and declaring a win when all bricks are gone.
Introduce a mouse move listener to control the paddle, compute relative x, center the paddle on the cursor, and keep it within the canvas boundaries.
Set up three player lives and render them on the canvas beside the score. Subtract a life when the ball hits the bottom, using requestAnimationFrame for smooth rendering.
Learn how to add more than 1 level to our game.
In this lecture we will add a pause screen, and more brick rows, and increase the ball speed between levels.
I'll introduce the Math.random() and Math.floor() methods and how we can use them to start our ball in a random position each time the game starts.
In this lecture we will be replacing our regular ball with an image. I use this one here: http://pngimg.com/uploads/football/football_PNG52790.png (the previously mentioned image link, https://s20.postimg.org/cayyuwmal/ball.jpg, is no longer working). However, feel free to find your own image and use that instead.
Take a step-by-step approach to learning how to build a complete JavaScript game. In this course we will cover the basic set up of the HTML and CSS pages and then we will dive right into coding our game! Starting from creating basic shapes on our canvas element to animating a ball, and then finally keeping track of the player's lives and score. We will cover many interesting topics, including:
And much more!
There are only two things that you need to take this course: an internet connection and a computer. There is no need to download any paid software or set up complex development environments.
The course is 1.5 hours long and is structured in a step-by-step manner, from simple to more difficult concepts. We build the JavaScript game from the ground up and cover each game component one at a time - so you will never feel overwhelmed with the content.
With the knowledge gained in this course you can move forward and build more complex JavaScript games, and use the game you created at the end of this course to add to your portfolio or just impress your friends.
The material in this course is adapted from MDN, licensed under CC-BY-SA 2.5.
I hope to hear from you soon, and look forward to having you in my course!