coding your first html5 game
play

Coding Your First HTML5 Game Randy Hoyt @randyhoyt - PowerPoint PPT Presentation

Coding Your First HTML5 Game Randy Hoyt @randyhoyt randyhoyt.com/launchgame @randyhoyt Overview Code HTML5 Games @randyhoyt Overview Games HTML5 Code @randyhoyt Games Games Games are fun ! s e m a g e v


  1. Coding Your First HTML5 Game Randy Hoyt @randyhoyt

  2. randyhoyt.com/launchgame @randyhoyt

  3. Overview • Code • HTML5 • Games @randyhoyt

  4. Overview • Games • HTML5 • Code @randyhoyt

  5. Games

  6. Games • Games are fun ! s e m a g e v o l I @randyhoyt

  7. A Theory of Fun (2004), by Ralph Koster

  8. Games • Games are fun • Games are everywhere ! s e m a g e v o l I @randyhoyt

  9. Homo Ludens (1938), by Johan Huizinga

  10. Games • Games are fun • Games are everywhere • Games exercise the brain ! s e m a g e v o l I @randyhoyt

  11. Play engages the prefrontal cortex, responsible for your highest-level cognitive functions – including self- knowledge, memory, mental imagery, and incentive and reward processing. Brain Workout , Life Optimizer, http://trhou.se/WHkaR7

  12. Brain Workout , Life Optimizer, http://trhou.se/WHkaR7

  13. Games • Games are fun • Games are everywhere • Games exercise the brain • Games are practice for ! the real world s e m a g e v o l I @randyhoyt

  14. 7 TED Talks on Gaming , http://trhou.se/gamesTED

  15. Games And Me @randyhoyt

  16. HTML5

  17. ! t r e l A d r o w z z u B

  18. HTML5 and Related Technologies • Canvas @randyhoyt

  19. HTML5 and Related Technologies • Canvas • WebGL http://trhou.se/whyWebGL @randyhoyt

  20. HTML5 and Related Technologies • Canvas • WebGL http://trhou.se/whyWebGL • WebSocket http://trhou.se/introwebsockets @randyhoyt

  21. HTML5 and Related Technologies • Canvas • WebGL http://trhou.se/whyWebGL • WebSocket http://trhou.se/introwebsockets • SVG @randyhoyt

  22. HTML5 Games

  23. It’s official: with HTML5 today the browser has become a full- fledged gaming platform. HTML5 Gaming , http://html5rocks.com/gaming

  24. Behind the Scenes , http://www.cuttherope.ie/dev/

  25. HTML5 Games • Top 10 HTML5 games of 2012 http://trhou.se/gamesin2012 • Goko • Game Closure Devkit • Famo.us - http://tcrn.ch/ZfCuNh @randyhoyt

  26. Code

  27. Project Structure JavaScript HTML CSS @randyhoyt

  28. Project Structure JavaScript HTML CSS @randyhoyt

  29. Project Structure JavaScript HTML CSS @randyhoyt

  30. Project Structure JavaScript HTML CSS @randyhoyt

  31. HTML

  32. CSS

  33. Canvas Preview

  34. Canvas and Context

  35. Image in JavaScript

  36. requestAnimationFrame

  37. update function

  38. update function

  39. Game Logic: Init (Once), Update (Loop) init update

  40. fillRect

  41. One wall in the browser

  42. fillRect

  43. Five walls in the browser

  44. drawImage

  45. Frog variables

  46. Frog in the browser

  47. Five walls in the browser

  48. clearRect

  49. clearRect

  50. Game Logic: Init (Once), Update (Loop) init update

  51. Game Logic: Move update init

  52. Game Logic: Update, Render, Loop update init render

  53. Game Logic • Init - Place Frog - Place Obstacles • Update - Move • Render @randyhoyt

  54. Game Logic: Bind Events • Init - Bind Events - Place Frog - Place Obstacles • Update - Move • Render @randyhoyt

  55. Game Logic: Place Badges • Init - Bind Events - Place Frog - Place Obstacles - Place Badges • Update ... @randyhoyt

  56. Game Logic: Update ... • Update - Check for Movement - Check for Obstacles - Move - Check for Badges • Render @randyhoyt

  57. Game Logic: Check for Victory ... • Update ... ... • Render • Check for Victory @randyhoyt

  58. Game Preview

  59. HTML5 Game Frameworks • Impact • LimeJS • Crafty • GameClosure ! e r o m y • CocoonJS n a m d n a . . . @randyhoyt

  60. HTML5 Game Frameworks • Impact • LimeJS • Crafty • GameClosure • CocoonJS Game Engine Comparison , http://trhou.se/gamecompare @randyhoyt

  61. LimeJS • Free and Open Source • Uses DOM or Canvas • Built on Google Closure • Requires Python • Incompatible with CocoonJS @randyhoyt

  62. > bin/lime.py create treehouse

  63. HTML

  64. Starting JavaScript File

  65. Create Director

  66. Director Settings

  67. Scene

  68. Blank Canvas

  69. Comments

  70. Game Background Sprite

  71. appendChild

  72. Create Analog Stick Sprite

  73. Preview Game

  74. Preview Game With Inspector

  75. Preview Game With Console

  76. Add Four Button Sprites

  77. Frog Constructor

  78. Frog Properties

  79. Require Frog

  80. > bin/lime.py update

  81. Constants

  82. appendChild Frog

  83. Game Logic: Init, Render init render

  84. Create Walls and Badges

  85. appendChild: Walls and Badges

  86. Game Preview

  87. Add Event for UP Button

  88. Frog: startMovement

  89. Game Logic: Schedule Manager init update render

  90. Schedule Manager

  91. Game Logic: Check Movement update init ? render

  92. Add Events to All Buttons

  93. checkMovement

  94. Game Logic: Check Movement update init ? render

  95. Game Logic: Check Movement update init ? render

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend