Snowy States ⭐
- Due Jul 15, 2019 by 11:59pm
- Points 15
- Submitting a file upload
For your second programming assignment, you're going to build upon the demo you made in Making Your First Phaser Game. You will turn that demo into a multi-state game and use a prefab to create a snow storm 🌨.
Grading Criteria
You are graded according to the following rubric (point values in parentheses):
Organization (2.5 points)
- Logically comment your source to demonstrate that you understand how each section works. (0.5)
- Your file structure is organized logically and legibly. (0.5)
- Game runs from localhost (0.5) with no code errors (0.5).
- Submit your project to Canvas as a .zip that includes the framework so the graders can run it. (0.5)
States and Conditions (7 points)
- Your game should have three states (w/ these names): a MainMenu state (0.5), a Playstate (0.5), and a GameOver state (0.5).
- State code should use the structure demonstrated in class examples (i.e., using the state object's .prototype) (0.5).
- Your MainMenu state should preload your assets (0.5), display a title and instructions (0.5), and wait for player input to change to the Play state (0.5). (Don't worry about the text design or placement right now. Just make sure it's legible.)
- The Play state should contain the game you created in your first assignment. However, you need to add a win/lose condition. If the player runs into the baddies (0.5) or collects all the stars (0.5), move to the GameOver state.
- Load and add a (< 1 second) .mp3 sound asset that plays every time you collect a star (0.5). (Feel free to use my pop sound if you don't want to create your own asset.)
- The GameOver state should display text indicating the player's score (0.5) and wait for player input to retry the game (w/ instructions) by going back to the Play state (0.5).
- When the player returns to Play, the stage should be reset (e.g., score, stars, etc.) (0.5).
- Player score should be a local variable passed between states as a parameter using Phaser's init method (0.5).
Snowy Prefabs (5.5 points)
- Using the code syntax shown in class, construct a Snowstorm prefab (in a separate Snowstorm.js file) (0.5) that inherits from Phaser.Sprite (0.5).
- The prefab should create a snow object of a random screen x/y position, rotation, positive x-velocity, and positive y-velocity (2). You may use any asset you like :)
- The snow objects should be semi-transparent so the player can see through them in order to play the game (0.5).
- Use a loop to add 100 snow objects to the screen during the Play state. (0.5)
- Override the prefab's update method to allow the player to reverse all snow objects' horizontal velocities by pressing the 'R' key (0.5).
- The snowflakes should rotate slowly as they fall (0.5).
- Finally, if any snow object reaches the right, left, or bottom edge of the screen, it should wrap to the opposite side cleanly (i.e., it should completely clear the edge of the screen before wrapping to the other side). (0.5)
The net effect should be the appearance of a snow storm "overlaid" atop your game. The snow should be drifting downward and appear to fall endlessly. Here's an example of how mine looks (note that I press the 'R' key near the beginning to shift the snow direction):
You will submit a .zip file containing your project folders, files, and any assets necessary to make your game run from localhost (don't forget the framework!).
Rubric
Criteria | Ratings | Pts |
---|---|---|
Comments
threshold:
pts
|
pts
--
|
|
File organization
threshold:
pts
|
pts
--
|
|
Runs from localhost
threshold:
pts
|
pts
--
|
|
No code errors
threshold:
pts
|
pts
--
|
|
.zip w/ all necessary files
threshold:
pts
|
pts
--
|
|
MainMenu, Play, GameOver states
threshold:
pts
|
pts
--
|
|
Proper state syntax
threshold:
pts
|
pts
--
|
|
Preload in MainMenu
threshold:
pts
|
pts
--
|
|
MainMenu title and instruction text
threshold:
pts
|
pts
--
|
|
MainMenu moves to Play on player input
threshold:
pts
|
pts
--
|
|
Play moves to GameOver when baddies hit
threshold:
pts
|
pts
--
|
|
Play moves to GameOver when ALL stars collected
threshold:
pts
|
pts
--
|
|
Non-looping sound plays on star collision
threshold:
pts
|
pts
--
|
|
GameOver displays score
threshold:
pts
|
pts
--
|
|
GameOver goes back to Play on player input
threshold:
pts
|
pts
--
|
|
Play initialized properly on replay (e.g. score resets)
threshold:
pts
|
pts
--
|
|
Score is local variable passed through state.start and init method
threshold:
pts
|
pts
--
|
|
SnowStorm prefab file
threshold:
pts
|
pts
--
|
|
SnowStorm properly inherits from Phaser.Sprite
threshold:
pts
|
pts
--
|
|
Snow object has random x/y, rotation, x-vel, y-vel
threshold:
pts
|
pts
--
|
|
Snow has alpha <1
threshold:
pts
|
pts
--
|
|
Exactly 100 snow objects
Make sure the for loop counts correctly!
threshold:
pts
|
pts
--
|
|
R key reverses all snowflakes
threshold:
pts
|
pts
--
|
|
Snowflakes rotate
threshold:
pts
|
pts
--
|
|
Snowflakes wrap cleanly across screen edges
threshold:
pts
|
pts
--
|