From ecb02b8542373c8c6084094f189f78a2a20037c7 Mon Sep 17 00:00:00 2001 From: awesomeisfree <49553413+awesomeisfree@users.noreply.github.com> Date: Fri, 6 Mar 2020 12:55:19 -0500 Subject: [PATCH 1/3] SM Condense condenses the sprite management steps --- web/dino-hunter.html | 74 ++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/web/dino-hunter.html b/web/dino-hunter.html index 09df9fa6..cf6cacfa 100644 --- a/web/dino-hunter.html +++ b/web/dino-hunter.html @@ -65,60 +65,48 @@
5. Create a constructor that creates a "Raptor." It should have all the 2D properties like x, y, width, and height, and also an Image property that links to the Raptor Spritesheet. Create one and assign it to a variable.
+5. Create a constructor that creates a "Raptor." It should have all the 2D properties like x, y, width, and height. Create one and assign it to a variable.
6. Independently try drawing the Raptor Spritesheet onto the Background. Give your raptor constructor another property, a "draw" function. When you call this function, the game should draw the Raptor Spritesheet onto the background.
+6. Give your raptor constructor another property, a "draw" function. When you call this function, the game should draw a red rectangle at the location of the Raptor onto the background.
7. Research the drawImage function. Find and learn about the override that allows you to draw a cut portion of an image called a 'clip.' It's the override with nine arguments. Using your understanding of the override, upgrade your draw function to draw only a specific 'frame' of the raptor, the first downward facing one, at the raptor's x and y position.
-8. We are going to move our 'clip' around to simulate animation. Use the image below as a reference for what we are trying to accomplish. Note that the only value that is changing is X because we are simply moving our clip to the right. Upgrade your draw function to switch to the next downward facing raptor sprite every second, eventually cycling back to the first.
-
- 9. Give your raptor constructor another property, a "move" function. When you call this function, your raptor should take a step down the screen. Upgrade it to include that if it touches the bottom of the screen, it should reduce your health.
+7. Give your raptor constructor another property, a "move" function. When you call this function, your raptor should take a step down the screen.
10. Make an array and add your current testing Raptor to it. I'm going to refer to the array as the 'live' array but call it whatever is useful to you. Make a function called movement that runs on an interval. It loops through the array and calls the move function of every dino in the array. Your dino should walk to the bottom of the screen.
- +8. Make an array and add your current testing Raptor to it. I'm going to refer to the array as the 'live' array but call it whatever is useful to you. Make a function called movement that runs on an interval. It loops through the array and calls the move function of every dino in the array. Your dino should move slowly to the bottom of the screen.
11. Make another function on an interval called spawner. This function should continuously create raptors at random locations along the top of the screen. Add them to your array of dinos to move.
-Click here to view fullscreen example.
+ +9. When your raptor reaches the bottom, it should reduce your health and be removed from the array. It should no longer be drawn or moved.
12. Don't draw or move Raptors that have reached the bottom. You can do this by integrating the 'live' array into your animation function and by removing them from that array when they reach the bottom
+10. Make another function on an interval called spawner. This function should continuously create raptors at random locations along the top of the screen. Add them to your array of dinos to move.
+13. Play the bite sound when a raptor reaches the bottom. Note: Most browsers block sound until you click or press a button in the window, so make sure you click on your screen after refreshing or else you might accidentally think it's broken. The same is true with the link below. It won't make the bite noise until you click inside.
+11. Play the bite sound when a raptor reaches the bottom. Note: Most browsers block sound until you click or press a button in the window, so make sure you click on your screen after refreshing or else you might accidentally think it's broken. The same is true with the link below. It won't make the bite noise until you click inside.
14. Repeat all the previous steps for the Triceratops. Make another constructor for the Triceratops, wire up its sprite sheet, write draw and move functions, and add them to the spawner.
+12. Repeat all the previous steps for the Triceratops. Make another constructor for the Triceratops, write draw (make it a bigger blue rectangle) and move functions, and add them to the spawner.
15. Repeat all the previous steps for the Compys. Make another constructor for the Compys, wire up its sprite sheet, write draw and move functions, and add them to the spawner.)
+13. Repeat all the previous steps for the Compys. Make another constructor for the Compys, write draw (make it a small green rectangle) and move functions, and add them to the spawner.)
16. Change the Triceratops to make it different than the Raptor. I recommend:
--> Make the Triceratops much bigger on screen
+14. Change the Triceratops to make it different than the Raptor. I recommend:
-> Make it roar when it spawns
-> Make it a much rarer spawn
-> Make it bite for more damage when it reaches the bottom
@@ -126,52 +114,56 @@17. Now make the Compy different too! I recommend:
+15. Now make the Compy different too! I recommend:
-> Make the Compy move randomly, but never backwards and never off screen
--> Give the Compy unique animation frames for moving diagonally
-> Make the Compy spawn much more commonly
--> Make the Compy much smaller on screen
18. Add Background Music to the game. Remember that browsers will block sound until you click or otherwise interact with the screen.
+16. Add Background Music to the game. Remember that browsers will block sound until you click or otherwise interact with the screen.
19. Okay! It's finally time to introduce... Typing! Research the Fetch function. Use it to retrieve the dictionary asset included above, split it on newline characters, and store it in a variable as an array.
+17. Okay! It's finally time to introduce... Typing! Research the Fetch function. Use it to retrieve the dictionary asset included above, split it on newline characters, and store it in a variable as an array.
20. Each Dino should add another property to their constructor, word! Raptors should be assigned a random word on construction from your dictionary array. Triceratops should be assigned three words, and Compys should be assigned a random letter instead.
+18. Each Dino should add another property to their constructor, word! Raptors should be assigned a random word on construction from your dictionary array. Triceratops should be assigned three words, and Compys should be assigned a random letter instead.
21. Upgrade your Dino draw functions to draw their individual words above their heads. You have already used the drawText function all the way back in step 4.
+19. Upgrade your Dino draw functions to draw their individual words above them. You have already used the drawText function all the way back in step 4. Give the text a background so as to be easier to see.
22. On key press, check every Dino's word to see if its first letter matches. If it does, delete it from the word. If the Dino's word is gone, kill it and get a point! Finally!
+20. On key press, check every Dino's word to see if its first letter matches. If it does, delete it from the word.
23. Now you need to work with the Dino deaths. Create a new property in all the Dino constructors, a function called "kill." This function should handle playing the death animation, removing the Dino from the 'live' array, giving you points, and playing the death sounds in the assets above. Call it when a Dino's word is empty.
+21. Now you need to work with the Dino deaths. Create a new property in all the Dino constructors, a function called "kill." This function should remove the Dino from the 'live' array, give you points, and play the death sounds in the assets above.
24. Give all the Dinos death animations. You've done this before. You got this. Most of the death sprites are on the right side of the sprite sheets and are vertical instead of horizontal. Don't let that intimidate you! Note that the Triceratops doesn't have a death sprite in its spritesheet. Either make one yourself (explosion!) or be creative. I just made my Triceratops back up right back into the trees.
-Click here to view fullscreen example.
+22. If the Dino's word is gone, kill it! Finally!
25. The Raptors have a unique ability too! When they reach half-health (read: their word is half gone), they leap towards you! Focus on changing their move function to make them faster at half health or less for now.
+23. The Raptors have a unique ability too! When they reach half-health (read: their word is half gone), they leap towards you! Focus on changing their move function to make them faster at half health or less for now.
26. Now give the Raptors a unique movement animation for when they are leaping. You'll find leaping sprites in their spritesheet.
-Click here to view fullscreen example.
+24. Now it's time to integrate the sprite assets. Research the drawImage function and try drawing the Raptor spritesheet onto the game. Find and learn about the override that allows you to draw a clipped portion of an image. It's the override with nine arguments. Using your understanding of the drawImage function and it's clipping override, upgrade your draw functions to draw the first frame of each Dino's downward facing walking frames.
+ +25. Upgrade your draw function to animate your dinos:
+-> Switch to the next downward facing dino walk sprite every second, eventually cycling back to the first. Try moving your 'clip' around.
+-> Give all the Dinos death animations that play when they die. You can find death sprites on the right side of the sprite sheets, except for the Triceratops. Either make one yourself or just make it back up into the trees.
+-> Give your Compys unique animation frames based on what direction they are traveling.
+-> Give your Raptors unique animation frames for leaping at you.
27. Show a Title Screen at the start. This can be as simple as showing some introductory message before the game begins.
+26. Show a Title Screen at the start. This can be as simple as showing some introductory message before the game begins.
28. Aaaand finally, add a Game Over Screen when your health reaches zero. This should remove all the current dinos and stop the spawner. It should also show your score. Wow. Congratulations, you just completed a massive project. Go ring that gong FIVE TIMES.
+27. Aaaand finally, add a Game Over Screen when your health reaches zero. This should remove all the current dinos and stop the spawner. It should also show your score. Wow. Congratulations, you just completed a massive project. Go ring that gong FIVE TIMES.
6. Give your raptor constructor another property, a "draw" function. When you call this function, the game should draw a red rectangle at the location of the Raptor onto the background.
-
7. Give your raptor constructor another property, a "move" function. When you call this function, your raptor should take a step down the screen.
+8. Make an array and add your current testing Raptor to it. I'm going to refer to the array as the 'live' array but call it whatever is useful to you. Make a function called movement that runs on an interval. It loops through the array and calls the move function of every dino in the array. Your dino should move slowly to the bottom of the screen.
-Click here to view full screen example +

11. Play the bite sound when a raptor reaches the bottom. Note: Most browsers block sound until you click or press a button in the window, so make sure you click on your screen after refreshing or else you might accidentally think it's broken. The same is true with the link below. It won't make the bite noise until you click inside.
- +D$JjjlyE|ef@Qf9lR5x
zd}ERo)SgF``}gz?C7@$nqm#^{ w&`CP-A))F8-zXm~&gzDtV=y}Se*l~rOuDe=tD
z^iajCl2H*nf8)r#FwqIBJV^n84ro=9WV1Wd7&=3^gu64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