In the first part of this course we will be making a simplified version of the game which allows the player to move and to collect coins
Here is a video of the project after completing Lesson 3 of this course
In this game the player (blue circle) attempts to hover without exiting the screen, while collecting gold coins
Part of the fun is the difficulty of controlling the player.
We're going to make a simple "You lose" screen which pauses the game when it comes up
If the player goes off the screen,
crashed is set to
movePlayer() function will only run if
crashed is set to
Of course, clicking to restart doesn't work. So we'll make that happen next.
Take a moment to think about how we will make the game play again when the user clicks on the screen.
Here's how it will look:
The coin will start at a the right side of the screen, at a random y coordinate
If you do not have this yet, keep trying for a bit longer! We will go over the solution in the next step.
If we look at the processing.js reference we can see how to use the
try to add this functionality to
We're going to use a new data type called an array.
Arrays are variables that can hold multiple values:
We can't use the entire array in individual statements.
For example we can't just say:
//This would result in an error ellipse(coins.x, coins.y, coins.size, coins.size);
We need to still draw each coin one at a time...
Notice after I collect the first coin, all of the coins stop showing up...
Next we'll make the game continuously create new coins randomly.
Right now there is a 10% chance of creating a new coin every frame
(60 chances per second means about 6 new coins a second)...
Here is how it will look after Lesson 2
This will incorporate a bunch of the ideas we briefly covered in this lesson and will be a bit more advanced