Advertisement
Guest User

Untitled

a guest
Apr 9th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.94 KB | None | 0 0
  1. Assignment 2
  2. GAME1003 – Web Game Development
  3. ** Due Sat, April 08 **
  4. Assignment 2:
  5. The goal of this assignment is to utilize HTML5 canvas technology and
  6. JavaScript to build a simple 2D game. The background will consist of scrolling
  7. tiled images giving the illusion of movement. Player movement and capability to
  8. shoot objects while avoiding collision will also be implemented.
  9.  
  10.  
  11. Game Setup
  12.  
  13. 1) The html file (index.html) will be a simple HTML5 document housing a
  14. single canvas element and a div/paragraph element used for displaying
  15. score. As well it will reference your external JavaScript file. Place the
  16. validation script just before the closing </body> tag:
  17. <script src=http://my.gblearn.com/js/loadscript.js></script>
  18.  
  19. 2) Ensure that the canvas element is in a 2D context (do this in JS) and is
  20. 700 pixels wide by 600 pixels tall and centered in the html page.
  21.  
  22. 3) Use any CSS as you need. Apply any background color to the body of
  23. your HTML document. Up to you if you like to use external CSS file.
  24.  
  25. 4) Store all your images in a separate folder.
  26.  
  27.  
  28. Scrolling Background
  29.  
  30. 1) Your 700x600 scrolling background will be setup as a grid with 6 rows and
  31. 7 columns PLUS an extra row to make the scrolling look seamless.
  32.  
  33. 2) This means each tile should be 100x100 in size. It will scroll vertically
  34. from top to bottom (hence: tiles move down each frame of the game). For
  35. this, you’ll need to increment the y value of each tile. Set the scroll speed
  36. to something reasonable.
  37.  
  38. 3) The background will be made up of two different tile images.
  39. a. The first image is the main safe space, like water or stars or clouds,
  40. or whatever you choose. The player cannot collide with these tiles.
  41. b. The second image is an obstacle that the player is supposed to
  42. avoid, like rocks for example.
  43.  
  44. 4) The background should be made of safe tiles with some obstacle tiles
  45. mixed in. Generation of obstacle tiles can and should be random so each
  46. play through is different. Some considerations are:
  47. 2
  48. a. Start out with all safe tiles when the game begins and when one
  49. row goes off-screen, that’s when you can remove that row and
  50. generate a new row at the top.
  51. b. When coding for a random obstacle generation, ensure that the
  52. player is not blocked by many obstacles that makes it almost
  53. impossible to pass through. The game should not be so difficult
  54. that player constantly crashes into the obstacle nor should be so
  55. easy that obstacles are rarely seen! One recommendation is to
  56. apply 20% obstacle tile, and 80% safe tile for the background for
  57. beginners.
  58. c. Optional challenge: As time goes on in the game you could make
  59. the game more challenging by introducing more obstacles. i.e after
  60. 30 seconds of being alive, increase the number of obstacles by 5%
  61. to 25%. Repeat this incrimination 3 times, to a maximum of 35%
  62. obstacles – 65% safe tiles. 1% bonus mark
  63.  
  64. 5) You’ll have a main setInterval loop controlling everything and thus a
  65. pseudo-engine set up with different functions.
  66.  
  67.  
  68. Player Movement & Collision
  69.  
  70. 1) The player should also be an image, same size as the background tiles
  71. (100x100) pixels.
  72.  
  73. 2) Ensure that your background is initially made up of all safe tiles, so you
  74. can have the player start near the bottom of the game area.
  75.  
  76. 3) Keep in mind, the player is NOT part of the background and should be
  77. rendered AFTER the background, so it appears on top of the tiles.
  78.  
  79. 4) The player should be able to move in all four cardinal directions plus
  80. diagonal. Use the arrow keys and/or wasd to move the player.
  81.  
  82. 5) Use spacebar to shoot down the enemy/alien.
  83.  
  84. 6) Set the player movement speed as you like. Should be slightly higher than
  85. the background scrolling speed.
  86.  
  87. 7) You will need to keep track of the player’s X and Y positions in the canvas
  88. for collision purposes. The width and height (same size) of the player
  89. image will also be used in collision.
  90.  
  91. 8) If the player touches an obstacle tile, stop the scrolling and use a simple
  92. alert dialog box to notify that the player has crashed.
  93.  
  94.  
  95. Shooting enemies (i.e, aliens/birds/planes)
  96.  
  97. 1) An enemy object such as alien appears randomly near the top (one of the
  98. top three rows) of the game area and moves horizontally. Enemy’s speed
  99. is about the same as the background tiles. You can use an array to store
  100. at least 3 or more enemies and recycle each one that moves out of the
  101. game area.
  102.  
  103. 2) Player scores 10 points every time an enemy is shot. Display ongoing
  104. score beside or below the canvas in a div or paragraph element.
  105.  
  106. 3) When an enemy gets shot, the missile and the enemy should disappear.
  107.  
  108. Optional challenge: Obstacles should block the player’s shot, preventing a
  109. missile from reaching the enemy. Missile would disappear when it hits the
  110. obstacles that are part of background tiles. 1% bonus mark
  111. You could store each background tile as an object in a 2 dimensional array to
  112. layout the rows and columns.
  113. Sound effects or music are not required, but if you want to include them you can.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement