├── 9781430247166.jpg
├── Code - Published
├── chapter01
│ ├── absolutePositioning
│ │ └── absolutePositioning.html
│ ├── backgroundImages
│ │ ├── backgroundImages.html
│ │ └── cat.png
│ ├── class
│ │ └── class.html
│ ├── classAndId
│ │ └── classAndId.html
│ ├── floatingElements
│ │ ├── cat.png
│ │ ├── floatingElements.html
│ │ ├── hedgehog.png
│ │ └── tiger.png
│ ├── floatingElementsFinished
│ │ ├── cat.png
│ │ ├── floatingElementsFinished.html
│ │ ├── hedgehog.png
│ │ └── tiger.png
│ ├── id
│ │ └── id.html
│ ├── organizingFiles
│ │ ├── newStyle.css
│ │ └── simpleDocument.html
│ ├── projectFolder
│ │ ├── images
│ │ │ └── photo.jpg
│ │ ├── sounds
│ │ │ └── song.mp3
│ │ ├── src
│ │ │ ├── main.html
│ │ │ └── style.css
│ │ └── videos
│ │ │ └── movie.mp4
│ ├── simpleWebPage
│ │ ├── ocean.jpg
│ │ └── simpleWebpage.html
│ └── styledWebPage
│ │ ├── ocean.jpg
│ │ └── styledWebpage.html
├── chapter02
│ ├── 01_displayConsoleOutput.html
│ ├── 02_numberVariables.html
│ ├── 03_addingNumbers.html
│ ├── 04_mathmaticalOperations.html
│ ├── 05_stringVariables.html
│ ├── 06_combiningStrings.html
│ ├── 07_trueAndFalse.html
│ ├── 08_comparingValues.html
│ ├── 09_greaterOrLesser.html
│ ├── 10_comparingStrings.html
│ ├── 11_compoundIfStatements.html
│ ├── 12_switchStatement.html
│ ├── 13_usingAnd.html
│ ├── 14_usingOr.html
│ ├── 15_functions.html
│ ├── 16_functionsWithArguments.html
│ ├── 17_functionsWithMultipleArguments.html
│ ├── 18_calculator.html
│ ├── 19_returnFunctionCalculator.html
│ ├── 20_returningValues.html
│ ├── 21_functionExpressions.html
│ ├── 22_displayHTMLText.html
│ ├── 23_changeCSS.html
│ ├── 24_creatingHTMLElements.html
│ ├── 25_eventListener.html
│ ├── 26_removeEventListener.html
│ ├── 27_counting.html
│ ├── 28_enterKey.html
│ ├── 29_enteringText.html
│ └── organizingFiles
│ │ ├── main.html
│ │ └── program.js
├── chapter03
│ ├── alienAttack
│ │ ├── images
│ │ │ ├── alien.png
│ │ │ ├── background.png
│ │ │ ├── cannon.png
│ │ │ └── missile.png
│ │ └── src
│ │ │ └── alienAttack.html
│ ├── alienAttackFinished
│ │ ├── fonts
│ │ │ └── emulogic.ttf
│ │ ├── images
│ │ │ ├── alien.png
│ │ │ ├── background.png
│ │ │ ├── cannon.png
│ │ │ ├── explosion.png
│ │ │ └── missile.png
│ │ └── src
│ │ │ ├── alienAttack.css
│ │ │ ├── alienAttackFinished.html
│ │ │ └── emulogic.ttf
│ ├── alienExplosion
│ │ ├── images
│ │ │ ├── alien.png
│ │ │ ├── background.png
│ │ │ ├── cannon.png
│ │ │ ├── explosion.png
│ │ │ └── missile.png
│ │ └── src
│ │ │ └── alienExplosion.html
│ ├── customButton.html
│ ├── numberGameWithButton.html
│ ├── numberGameWithGraphics
│ │ ├── images
│ │ │ ├── arrow.png
│ │ │ └── scale.png
│ │ └── src
│ │ │ └── numberGameWithGraphics.html
│ ├── numberGame_1.html
│ ├── numberGame_2.html
│ ├── numberGame_3.html
│ ├── numberGame_4.html
│ ├── randomNumbers.html
│ └── usingParseint.html
├── chapter04
│ ├── Forest of Lyrica
│ │ ├── fonts
│ │ │ ├── Ginga.ttf
│ │ │ ├── Merriweather-Bold.ttf
│ │ │ └── Merriweather.ttf
│ │ ├── images
│ │ │ ├── bench.png
│ │ │ ├── cottage.png
│ │ │ ├── dragon.png
│ │ │ ├── gate.png
│ │ │ ├── glade.png
│ │ │ ├── keep.png
│ │ │ ├── paper.png
│ │ │ ├── path.png
│ │ │ ├── river.png
│ │ │ └── well.png
│ │ └── src
│ │ │ ├── forestOfLyrica.html
│ │ │ ├── lyrica.css
│ │ │ ├── lyrica1.html
│ │ │ ├── lyrica2.html
│ │ │ ├── lyrica3.html
│ │ │ ├── lyrica4.html
│ │ │ ├── lyrica5.html
│ │ │ └── lyrica6.html
│ ├── arrayLoop.html
│ ├── arraySearch.html
│ ├── artificialLife.html
│ ├── basicArray.html
│ ├── database.html
│ ├── forLoop.html
│ ├── usingIndexOf.html
│ ├── usingPop.html
│ ├── usingPush.html
│ └── usingSplice.html
├── chapter05
│ ├── islandAdventure
│ │ ├── fonts
│ │ │ └── PiratesWriters.ttf
│ │ ├── images
│ │ │ ├── background.png
│ │ │ ├── home.png
│ │ │ ├── island.png
│ │ │ ├── monster.png
│ │ │ ├── pirate.png
│ │ │ ├── ship.png
│ │ │ └── water.png
│ │ └── src
│ │ │ ├── islandAdventure1.html
│ │ │ ├── islandAdventure2.html
│ │ │ ├── islandAdventure3.html
│ │ │ ├── islandAdventure4.html
│ │ │ ├── islandAdventure5.html
│ │ │ ├── islandAdventure6.html
│ │ │ └── islandAdventureFinished.html
│ ├── looping2DArrays.html
│ ├── loopingThroughObjects.html
│ ├── twoDimensionalArrays.html
│ └── visualizing2DArrays.html
├── chapter06
│ ├── 10_stateChangeTimer.html
│ ├── 11_animationObject.html
│ ├── 12_tilesheetWithRows.html
│ ├── 13_animationLoop.html
│ ├── 14_randomAnimation.html
│ ├── 1_displayingWithCanvas.html
│ ├── 2_robotObject.html
│ ├── 3_loopingThroughObjects.html
│ ├── 4_changingStates.html
│ ├── 5_renderingStates.html
│ ├── 6_usingSetTimeout.html
│ ├── 7_usingSetInterval.html
│ ├── 8_usingClearInterval.html
│ ├── 9_timerObject.html
│ ├── frames.png
│ ├── monster.png
│ ├── monsterSmash
│ │ ├── fonts
│ │ │ └── Vanilla.ttf
│ │ ├── images
│ │ │ └── monsterTileSheet.png
│ │ └── src
│ │ │ ├── monsterSmash.css
│ │ │ ├── monsterSmash1.html
│ │ │ ├── monsterSmash2.html
│ │ │ └── monsterSmashFinished.html
│ ├── monsterStates.png
│ └── monsterTileSheet.png
├── chapter07
│ ├── 10_screenBoundaries.html
│ ├── 11_screenWrapping.html
│ ├── 12_basicScrolling.html
│ ├── 13_betterScrolling.html
│ ├── 14_parallaxScrolling.html
│ ├── 15_mouseControl.html
│ ├── 16_touchControl.html
│ ├── 1_basicSprite.html
│ ├── 2_manySprites.html
│ ├── 3_manyImageFiles.html
│ ├── 4_interactiveSprite.html
│ ├── 5_interactiveSpriteWithRotation.html
│ ├── 6_interactiveSpriteWithTransparency.html
│ ├── 7_interactiveSpriteWithShadows.html
│ ├── 8_interactiveSpriteHTML.html
│ ├── 9_keyboardControl.html
│ ├── background.png
│ ├── basicScrolling_Old.html
│ ├── betterScrolling_Old.html
│ ├── cat.png
│ ├── keyboardControl_KeyArray.html
│ ├── parallaxScrollingTileSheet.png
│ ├── phobosTileSheet.png
│ ├── requestAnimationFramePolyfill.js
│ ├── tiger.png
│ └── tileSheetWithBackground.png
├── chapter08
│ ├── 1_pointCollision.html
│ ├── 2_canvasText.html
│ ├── 3_circleCollision.html
│ ├── 4_blockingCircles.html
│ ├── 5_rectangleCollision.html
│ ├── 6_changingStates.html
│ ├── 7_healthMeter.html
│ ├── 8_updateScore.html
│ ├── 9_blockingRectangles.html
│ ├── catAndBox.png
│ ├── catAndMonster.png
│ ├── circles.png
│ ├── collision.js
│ ├── collisionTileSheet.png
│ ├── requestAnimationFramePolyfill.js
│ └── squares.png
├── chapter09
│ └── alienArmada
│ │ ├── fonts
│ │ └── emulogic.ttf
│ │ ├── images
│ │ └── alienArmada.png
│ │ ├── sounds
│ │ ├── explosion.mp3
│ │ ├── explosion.ogg
│ │ ├── music.mp3
│ │ ├── music.ogg
│ │ ├── shoot.mp3
│ │ └── shoot.ogg
│ │ └── src
│ │ ├── alienArmada.css
│ │ ├── alienArmada.html
│ │ ├── alienArmada1.js
│ │ ├── alienArmada2.js
│ │ ├── alienArmada3.js
│ │ ├── alienArmada4.js
│ │ ├── alienArmada5.js
│ │ ├── alienArmada6.js
│ │ ├── alienArmadaFinished.js
│ │ ├── collision.js
│ │ ├── objects.js
│ │ └── requestAnimationFramePolyfill.js
├── chapter10
│ ├── monsterMayhem
│ │ ├── images
│ │ │ └── monsterMayhem.png
│ │ └── src
│ │ │ ├── collision.js
│ │ │ ├── monsterMayhem.html
│ │ │ ├── monsterMayhem.js
│ │ │ ├── objects.js
│ │ │ └── requestAnimationFramePolyfill.js
│ ├── monsterMaze
│ │ ├── images
│ │ │ └── monsterMaze.png
│ │ └── src
│ │ │ ├── collision.js
│ │ │ ├── monsterMaze.html
│ │ │ ├── monsterMaze.js
│ │ │ ├── objects.js
│ │ │ └── requestAnimationFramePolyfill.js
│ ├── movingMonster
│ │ ├── movingMonster.html
│ │ ├── movingMonster.png
│ │ └── requestAnimationFramePolyfill.js
│ ├── timeBombPanic
│ │ ├── images
│ │ │ └── timeBombPanic.png
│ │ └── src
│ │ │ ├── collision.js
│ │ │ ├── objects.js
│ │ │ ├── requestAnimationFramePolyfill.js
│ │ │ ├── timeBombPanic.html
│ │ │ └── timeBombPanic.js
│ └── timeBombScroll
│ │ ├── images
│ │ └── timeBombPanic.png
│ │ └── src
│ │ ├── collision.js
│ │ ├── objects.js
│ │ ├── requestAnimationFramePolyfill.js
│ │ ├── timeBombScroll.html
│ │ └── timeBombScroll.js
├── chapter11
│ ├── 1_acceleration.html
│ ├── 2_friction.html
│ ├── 3_bounce.html
│ ├── 4_rectangleBounce.html
│ ├── 5_circleBounce.html
│ ├── 6_gravity.html
│ ├── 7_jumping.html
│ ├── 8_platforms.html
│ ├── cat.png
│ ├── catAndBox.png
│ ├── circles.png
│ ├── collision.js
│ ├── hedgehogApocalypse
│ │ ├── images
│ │ │ └── hedgehogApocalypse.png
│ │ └── src
│ │ │ ├── collision.js
│ │ │ ├── hedgehogAplocalypse.html
│ │ │ ├── hedgehogApocalypse.js
│ │ │ ├── objects.js
│ │ │ └── requestAnimationFramePolyfill.js
│ └── requestAnimationFramePolyfill.js
└── chapter12
│ ├── constructorFunction.html
│ ├── dragAndDrop
│ ├── dragAndDrop.png
│ ├── dragAndDropMouse.html
│ ├── dragAndDropTouch.html
│ └── requestAnimationFramePolyfill.js
│ ├── hedgehogMouse
│ ├── images
│ │ └── hedgehogApocalypse.png
│ └── src
│ │ ├── collision.js
│ │ ├── hedgehogAplocalypse.html
│ │ ├── hedgehogApocalypse.js
│ │ ├── objects.js
│ │ └── requestAnimationFramePolyfill.js
│ ├── images
│ ├── bee.png
│ ├── buttonFairy.png
│ ├── catAndBox.png
│ └── vehicles.png
│ ├── keyboard
│ ├── carKeyboard.html
│ ├── requestAnimationFramePolyfill.js
│ ├── rocketKeyboard.html
│ └── tank.html
│ ├── killerBeePandemonium
│ ├── images
│ │ └── killerBeePandemonium.png
│ └── src
│ │ ├── collision.js
│ │ ├── killerBeeMouse.html
│ │ ├── killerBeeMouse.js
│ │ ├── killerBeeTouch.html
│ │ ├── killerBeeTouch.js
│ │ ├── objects.js
│ │ └── requestAnimationFramePolyfill.js
│ ├── mouse
│ ├── beeFollowMouse.html
│ ├── beeRotateAndShootMouse.html
│ ├── buttonFairyMouse.html
│ ├── carMouse.html
│ ├── clickToMove.html
│ ├── easingMouse.html
│ ├── followMouse.html
│ ├── platformsMouse.html
│ ├── requestAnimationFramePolyfill.js
│ └── rocketMouse.html
│ └── touch
│ ├── beeFollowTouch.html
│ ├── beeRotateAndShootTouch.html
│ ├── buttonFairyTouch.html
│ ├── carTouch.html
│ ├── easingTouch.html
│ ├── followTouch.html
│ ├── platformsTouch.html
│ ├── requestAnimationFramePolyfill.js
│ ├── rocketTouch.html
│ └── tapToMove.html
├── LICENSE.txt
├── README.md
└── contributing.md
/9781430247166.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/9781430247166.jpg
--------------------------------------------------------------------------------
/Code - Published/chapter01/absolutePositioning/absolutePositioning.html:
--------------------------------------------------------------------------------
1 |
2 |
Absolute positioning
3 |
4 |
27 |
28 |
--------------------------------------------------------------------------------
/Code - Published/chapter01/backgroundImages/backgroundImages.html:
--------------------------------------------------------------------------------
1 |
2 | Background images
3 |
4 |
14 |
15 |
--------------------------------------------------------------------------------
/Code - Published/chapter01/backgroundImages/cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter01/backgroundImages/cat.png
--------------------------------------------------------------------------------
/Code - Published/chapter01/class/class.html:
--------------------------------------------------------------------------------
1 |
2 | Using a class
3 |
4 |
13 |
14 | Cat
15 | Tiger
16 | Hedgehog
--------------------------------------------------------------------------------
/Code - Published/chapter01/classAndId/classAndId.html:
--------------------------------------------------------------------------------
1 |
2 | Using a class and id together
3 |
4 |
28 |
29 | Cat
30 | Tiger
31 | Hedgehog
--------------------------------------------------------------------------------
/Code - Published/chapter01/floatingElements/cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter01/floatingElements/cat.png
--------------------------------------------------------------------------------
/Code - Published/chapter01/floatingElements/floatingElements.html:
--------------------------------------------------------------------------------
1 |
2 | Floating elements
3 |
19 |
20 |
--------------------------------------------------------------------------------
/Code - Published/chapter01/floatingElements/hedgehog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter01/floatingElements/hedgehog.png
--------------------------------------------------------------------------------
/Code - Published/chapter01/floatingElements/tiger.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter01/floatingElements/tiger.png
--------------------------------------------------------------------------------
/Code - Published/chapter01/floatingElementsFinished/cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter01/floatingElementsFinished/cat.png
--------------------------------------------------------------------------------
/Code - Published/chapter01/floatingElementsFinished/floatingElementsFinished.html:
--------------------------------------------------------------------------------
1 |
2 | Floating elements
3 |
4 |
56 |
57 |
58 |
59 |
60 |
61 |
Dangerous Animals!
62 |
--------------------------------------------------------------------------------
/Code - Published/chapter01/floatingElementsFinished/hedgehog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter01/floatingElementsFinished/hedgehog.png
--------------------------------------------------------------------------------
/Code - Published/chapter01/floatingElementsFinished/tiger.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter01/floatingElementsFinished/tiger.png
--------------------------------------------------------------------------------
/Code - Published/chapter01/id/id.html:
--------------------------------------------------------------------------------
1 |
2 | Using an id
3 |
4 |
14 |
15 |
--------------------------------------------------------------------------------
/Code - Published/chapter01/organizingFiles/newStyle.css:
--------------------------------------------------------------------------------
1 | h1
2 | {
3 | font-size: 40px;
4 | }
5 |
6 | p
7 | {
8 | font-family: Helvetica, Verdana, Arial, sans-serif;
9 | }
10 |
--------------------------------------------------------------------------------
/Code - Published/chapter01/organizingFiles/simpleDocument.html:
--------------------------------------------------------------------------------
1 |
2 | A simple document
3 |
4 |
5 | Page Heading
6 | A bit of text.
--------------------------------------------------------------------------------
/Code - Published/chapter01/projectFolder/images/photo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter01/projectFolder/images/photo.jpg
--------------------------------------------------------------------------------
/Code - Published/chapter01/projectFolder/sounds/song.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter01/projectFolder/sounds/song.mp3
--------------------------------------------------------------------------------
/Code - Published/chapter01/projectFolder/src/main.html:
--------------------------------------------------------------------------------
1 |
2 | Organizing project folders
3 |
4 |
5 | Organizing project folders
6 |
7 | Images
8 |
9 |
10 | Video
11 |
12 |
13 |
14 |
15 | Audio
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Code - Published/chapter01/projectFolder/src/style.css:
--------------------------------------------------------------------------------
1 | h1, h2
2 | {
3 | font-family: Monaco, Courier, monospace;
4 | }
5 |
6 | h1
7 | {
8 | font-size: 20px;
9 | }
10 |
11 | h2
12 | {
13 | font-size: 16px;
14 | }
--------------------------------------------------------------------------------
/Code - Published/chapter01/projectFolder/videos/movie.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter01/projectFolder/videos/movie.mp4
--------------------------------------------------------------------------------
/Code - Published/chapter01/simpleWebPage/ocean.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter01/simpleWebPage/ocean.jpg
--------------------------------------------------------------------------------
/Code - Published/chapter01/simpleWebPage/simpleWebpage.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | A web page
6 |
7 |
8 |
9 |
10 | A simple web page
11 | Everything you see on this page was made using basic HTML tags.
12 |
13 | This is a sub-heading
14 | You use HTML tags to structure information . This is a paragraph of text structured with a p tag.
15 |
16 | Making lists
17 | You can also use tags to make a list of things.
18 |
19 | First item
20 | Second item
21 | Third item
22 |
23 |
24 | Adding links
25 | Its easy to create hyperlinks to other web pages, or to create a link to generate an email. Here's how:
26 |
30 |
31 | Add a photo with an img tag, like this:
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Code - Published/chapter01/styledWebPage/ocean.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter01/styledWebPage/ocean.jpg
--------------------------------------------------------------------------------
/Code - Published/chapter01/styledWebPage/styledWebpage.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | A web page
5 |
71 |
72 |
73 |
74 | A simple web page
75 | Everything you see on this page was made using basic HTML tags.
76 |
77 | This is a sub-heading
78 | You use HTML tags to structure information . This is a paragraph of text structured with a p tag.
79 |
80 | Making lists
81 | You can also use tags to make a list of things.
82 |
83 | First item
84 | Second item
85 | Third item
86 |
87 |
88 |
89 |
90 | Adding links
91 | Its easy to create hyperlinks to other web pages, or to create a link to generate an email. Here's how:
92 |
96 |
97 | Add a photo with an img tag, like this:
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/01_displayConsoleOutput.html:
--------------------------------------------------------------------------------
1 |
2 | Display console output
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/02_numberVariables.html:
--------------------------------------------------------------------------------
1 |
2 | Number variables
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/03_addingNumbers.html:
--------------------------------------------------------------------------------
1 |
2 | Adding numbers
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/04_mathmaticalOperations.html:
--------------------------------------------------------------------------------
1 |
2 | Math operations
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/05_stringVariables.html:
--------------------------------------------------------------------------------
1 |
2 | String variables
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/06_combiningStrings.html:
--------------------------------------------------------------------------------
1 |
2 | Combining strings
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/07_trueAndFalse.html:
--------------------------------------------------------------------------------
1 |
2 | True and false variable
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/08_comparingValues.html:
--------------------------------------------------------------------------------
1 |
2 | Comparing values
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/09_greaterOrLesser.html:
--------------------------------------------------------------------------------
1 |
2 | Greater or lesser
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/10_comparingStrings.html:
--------------------------------------------------------------------------------
1 |
2 | Comparing strings
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/11_compoundIfStatements.html:
--------------------------------------------------------------------------------
1 |
2 | Compound if statements
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/12_switchStatement.html:
--------------------------------------------------------------------------------
1 |
2 | Compound if statements
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/13_usingAnd.html:
--------------------------------------------------------------------------------
1 |
2 | Switch statement
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/14_usingOr.html:
--------------------------------------------------------------------------------
1 |
2 | Using and
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/15_functions.html:
--------------------------------------------------------------------------------
1 |
2 | Functions with arguments
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/16_functionsWithArguments.html:
--------------------------------------------------------------------------------
1 |
2 | Functions with arguments
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/17_functionsWithMultipleArguments.html:
--------------------------------------------------------------------------------
1 |
2 | Functions with multiple arguments
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/18_calculator.html:
--------------------------------------------------------------------------------
1 |
2 | Calculator
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/19_returnFunctionCalculator.html:
--------------------------------------------------------------------------------
1 |
2 | Return function calculator
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/20_returningValues.html:
--------------------------------------------------------------------------------
1 |
2 | Returning values
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/21_functionExpressions.html:
--------------------------------------------------------------------------------
1 |
2 | Function expressions
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/22_displayHTMLText.html:
--------------------------------------------------------------------------------
1 |
2 | Display HTML text
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/23_changeCSS.html:
--------------------------------------------------------------------------------
1 |
2 | Change CSS
3 |
4 | Hello World!
5 |
6 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/24_creatingHTMLElements.html:
--------------------------------------------------------------------------------
1 |
2 | Creating HTML elements
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/25_eventListener.html:
--------------------------------------------------------------------------------
1 |
2 | Event listener
3 |
4 | click me
5 |
6 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/26_removeEventListener.html:
--------------------------------------------------------------------------------
1 |
2 | Remove an event listener
3 |
4 | click me
5 |
6 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/27_counting.html:
--------------------------------------------------------------------------------
1 |
2 | Event listener
3 |
4 | click me
5 |
6 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/28_enterKey.html:
--------------------------------------------------------------------------------
1 |
2 | Enter key
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/29_enteringText.html:
--------------------------------------------------------------------------------
1 |
2 | Entering and displaying text
3 |
4 |
5 | enter
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/organizingFiles/main.html:
--------------------------------------------------------------------------------
1 |
2 | Organizing files
3 |
--------------------------------------------------------------------------------
/Code - Published/chapter02/organizingFiles/program.js:
--------------------------------------------------------------------------------
1 | (function(){
2 |
3 | window.alert("The JavaScript program has loaded!");
4 |
5 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienAttack/images/alien.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienAttack/images/alien.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienAttack/images/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienAttack/images/background.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienAttack/images/cannon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienAttack/images/cannon.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienAttack/images/missile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienAttack/images/missile.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienAttackFinished/fonts/emulogic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienAttackFinished/fonts/emulogic.ttf
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienAttackFinished/images/alien.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienAttackFinished/images/alien.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienAttackFinished/images/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienAttackFinished/images/background.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienAttackFinished/images/cannon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienAttackFinished/images/cannon.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienAttackFinished/images/explosion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienAttackFinished/images/explosion.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienAttackFinished/images/missile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienAttackFinished/images/missile.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienAttackFinished/src/alienAttack.css:
--------------------------------------------------------------------------------
1 | *
2 | {
3 | font-family: emulogic;
4 | padding: 0px;
5 | margin: 0px;
6 | }
7 |
8 | @font-face
9 | {
10 | font-family: emulogic;
11 | src: url("../fonts/emulogic.ttf");
12 |
13 | /*
14 |
15 | Note: Firefox requires that the font file
16 | be in the same folder as the CSS file.
17 | If you are using Firefox, copy the emulogic.ttf font
18 | into the src folder and use this src property:
19 |
20 | src: url("../fonts/emulogic.ttf");
21 |
22 | */
23 |
24 | }
25 |
26 |
27 | h1
28 | {
29 | text-align: center;
30 | font-size: 24px;
31 | color: #FFBF00;
32 | padding-bottom: 20px;
33 |
34 | text-shadow: 3px 3px lime;
35 |
36 | -webkit-text-stroke: 1px #000;
37 | -moz-text-stroke: 1px #000;
38 | text-stroke: 1px #000;
39 | }
40 |
41 | p
42 | {
43 | text-align: center;
44 | font-size: 12px;
45 | padding-bottom: 20px;
46 | color: #FFBF00;
47 | }
48 |
49 | input
50 | {
51 | font-size: 15px;
52 | background-color: black;
53 | color: #FFBF00;
54 | width: 75px;
55 | padding: 5px 10px;
56 | border: 1px solid lime;
57 | -webkit-border-radius: 10px;
58 | -moz-border-radius: 10px;
59 | border-radius: 10px;
60 | }
61 |
62 | button
63 | {
64 | font-size: 15px;
65 | color: #FFBF00;
66 | padding: 5px 10px;
67 | border: 2px solid lime;
68 |
69 | -webkit-border-radius: 10px;
70 | -moz-border-radius: 10px;
71 | border-radius: 10px;
72 | background: black;
73 |
74 | -webkit-user-select: none;
75 | -moz-user-select: none;
76 | user-select: none;
77 | }
78 |
79 | button:hover
80 | {
81 | background-color: #FFBF00;
82 | color: #000;
83 | }
84 |
85 | button:active
86 | {
87 | background-color: #9e7606;
88 | color: #000;
89 | }
90 |
91 | #game
92 | {
93 | margin: 0px auto;
94 | width: 330px;
95 | height: auto;
96 | padding: 15px;
97 | border: black;
98 |
99 | background:-webkit-linear-gradient(300deg, #588063, #000);
100 | background:-moz-linear-gradient(top, #588063, #000);
101 | background: linear-gradient(top, #588063, #000);
102 |
103 | -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
104 | -moz-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
105 | box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
106 |
107 | -webkit-border-radius: 10px;
108 | -moz-border-radius: 10px;
109 | border-radius: 10px;
110 | }
111 |
112 | #stage
113 | {
114 | margin: 0px auto;
115 | width: 300px;
116 | height: 300px;
117 | position: relative;
118 |
119 | -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
120 | -moz-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
121 | box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
122 |
123 | margin-bottom: 20px;
124 | border: 1px solid lime;
125 | }
126 |
127 | #background
128 | {
129 | width: 300px;
130 | height: 300px;
131 | position: absolute;
132 | top: 0px;
133 | left: 0px;
134 | background-image: url(../images/background.png);
135 | }
136 |
137 | #cannon
138 | {
139 | width: 20px;
140 | height: 20px;
141 | position: absolute;
142 | top: 270px;
143 | left: 140px;
144 | background-image: url(../images/cannon.png);
145 | }
146 |
147 | #alien
148 | {
149 | width: 20px;
150 | height: 20px;
151 | position: absolute;
152 | top: 20px;
153 | left: 80px;
154 | background-image: url(../images/alien.png);
155 | }
156 |
157 | #missile
158 | {
159 | width: 10px;
160 | height: 10px;
161 | position: absolute;
162 | top: 240px;
163 | left: 145px;
164 | background-image: url(../images/missile.png);
165 | }
166 |
167 | #explosion
168 | {
169 | width: 20px;
170 | height: 20px;
171 | position: absolute;
172 | top: 0px;
173 | left: 0px;
174 | background-image: url(../images/explosion.png);
175 | display: none;
176 | }
177 |
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienAttackFinished/src/emulogic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienAttackFinished/src/emulogic.ttf
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienExplosion/images/alien.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienExplosion/images/alien.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienExplosion/images/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienExplosion/images/background.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienExplosion/images/cannon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienExplosion/images/cannon.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienExplosion/images/explosion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienExplosion/images/explosion.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/alienExplosion/images/missile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/alienExplosion/images/missile.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/customButton.html:
--------------------------------------------------------------------------------
1 |
2 | Custom button
3 |
4 |
47 |
48 | guess
49 |
--------------------------------------------------------------------------------
/Code - Published/chapter03/numberGameWithGraphics/images/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/numberGameWithGraphics/images/arrow.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/numberGameWithGraphics/images/scale.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter03/numberGameWithGraphics/images/scale.png
--------------------------------------------------------------------------------
/Code - Published/chapter03/numberGameWithGraphics/src/numberGameWithGraphics.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Number guessing game with graphics
4 |
5 |
40 |
41 |
45 |
46 | I am thinking of a number between 0 and 99.
47 |
48 | guess
49 |
50 |
--------------------------------------------------------------------------------
/Code - Published/chapter03/numberGame_1.html:
--------------------------------------------------------------------------------
1 |
2 | Number guessing game
3 |
4 | I am thinking of a number between 0 and 99.
5 |
6 | guess
7 |
8 |
--------------------------------------------------------------------------------
/Code - Published/chapter03/numberGame_2.html:
--------------------------------------------------------------------------------
1 |
2 | Number guessing game
3 |
4 | I am thinking of a number between 0 and 99.
5 |
6 | guess
7 |
8 |
--------------------------------------------------------------------------------
/Code - Published/chapter03/numberGame_3.html:
--------------------------------------------------------------------------------
1 |
2 | Number guessing game
3 |
4 | I am thinking of a number between 0 and 99.
5 |
6 | guess
7 |
8 |
--------------------------------------------------------------------------------
/Code - Published/chapter03/numberGame_4.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Number guessing game
4 |
5 | I am thinking of a number between 0 and 99.
6 |
7 | guess
8 |
9 |
--------------------------------------------------------------------------------
/Code - Published/chapter03/randomNumbers.html:
--------------------------------------------------------------------------------
1 |
2 | Random numbers
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter03/usingParseint.html:
--------------------------------------------------------------------------------
1 |
2 | Comparing strings
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/fonts/Ginga.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/fonts/Ginga.ttf
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/fonts/Merriweather-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/fonts/Merriweather-Bold.ttf
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/fonts/Merriweather.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/fonts/Merriweather.ttf
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/images/bench.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/images/bench.png
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/images/cottage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/images/cottage.png
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/images/dragon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/images/dragon.png
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/images/gate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/images/gate.png
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/images/glade.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/images/glade.png
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/images/keep.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/images/keep.png
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/images/paper.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/images/paper.png
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/images/path.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/images/path.png
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/images/river.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/images/river.png
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/images/well.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter04/Forest of Lyrica/images/well.png
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/src/lyrica.css:
--------------------------------------------------------------------------------
1 | *
2 | {
3 | font-family: Merriweather;
4 | color: #000;
5 | font-size: 16px;
6 | padding: 0px;
7 | margin: 0px;
8 | }
9 |
10 | @font-face
11 | {
12 | font-family: Merriweather;
13 | src: url("../fonts/Merriweather.ttf");
14 | }
15 |
16 | @font-face
17 | {
18 | font-family: Merriweather-Bold;
19 | src: url("../fonts/Merriweather-Bold.ttf");
20 | }
21 |
22 | @font-face
23 | {
24 | font-family: Ginga;
25 | src: url("../fonts/Ginga.ttf");
26 | }
27 |
28 | h1
29 | {
30 | text-align: center;
31 | font-family: Ginga;
32 | font-size: 80px;
33 | padding-bottom: 10px;
34 | padding-top: 80px;
35 | font-weight: normal;
36 | }
37 | em
38 | {
39 | font-size: 14px;
40 | }
41 | p
42 | {
43 | width: 300px;
44 | margin: 0px auto;
45 | }
46 |
47 | img
48 | {
49 | margin: 0px auto;
50 | display: block;
51 | margin-bottom: 20px;
52 | }
53 |
54 | input
55 | {
56 | position: absolute;
57 | bottom: 30px;
58 | left: 135px;
59 | width: 160px;
60 | padding: 2px 2px 2px 5px;
61 | border: 1px solid black;
62 | background-color: rgba(255,255,255,0.3);
63 | -webkit-box-shadow: 5px 5px 3px rgba(0,0,0,0.5);
64 | -moz-box-shadow: 5px 5px 3px rgba(0,0,0,0.5);
65 | box-shadow: 3px 3px 5px rgba(0,0,0,0.4);
66 | }
67 |
68 | button
69 | {
70 | position: absolute;
71 | bottom: 30px;
72 | left: 310px;
73 | height: 25px;
74 | width: 50px;
75 |
76 | font-family: Merriweather;
77 | font-size: 14px;
78 | color: #000;
79 | border: 1px solid #000;
80 |
81 | -webkit-border-radius: 10px;
82 | -moz-border-radius: 10px;
83 | border-radius: 10px;
84 |
85 | background:-webkit-linear-gradient(top, rgba(255,255,255,0.6), rgba(0,0,0,0.2));
86 | background:-moz-linear-gradient(top, #a3a3a3, rgba(0,0,0,0.2));
87 | background: linear-gradient(top, #a3a3a3, rgba(0,0,0,0.2));
88 |
89 | -webkit-box-shadow: 5px 5px 3px rgba(0,0,0,0.5);
90 | -moz-box-shadow: 5px 5px 3px rgba(0,0,0,0.5);
91 | box-shadow: 3px 3px 5px rgba(0,0,0,0.4);
92 |
93 | -webkit-user-select: none;
94 | -moz-user-select: none;
95 | user-select: none;
96 | }
97 |
98 |
99 | #stage
100 | {
101 | width: 500px;
102 | height: 648px;
103 | background-color: gray;
104 | position: relative;
105 | background-image: url("../images/paper.png");
106 | }
107 |
108 |
109 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/src/lyrica1.html:
--------------------------------------------------------------------------------
1 |
2 | The Forest of Lyrica - 1
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/src/lyrica2.html:
--------------------------------------------------------------------------------
1 |
2 | The Forest of Lyrica - 2
3 |
4 |
5 |
6 | enter
7 |
8 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/Forest of Lyrica/src/lyrica3.html:
--------------------------------------------------------------------------------
1 |
2 | The Forest of Lyrica - 3
3 |
4 |
5 |
6 |
7 | enter
8 |
9 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/arrayLoop.html:
--------------------------------------------------------------------------------
1 |
2 | For loop
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/arraySearch.html:
--------------------------------------------------------------------------------
1 |
2 | Array search
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/artificialLife.html:
--------------------------------------------------------------------------------
1 |
2 | Artificial life
3 |
4 | Hi! How are you today?
5 |
6 | enter
7 |
8 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/basicArray.html:
--------------------------------------------------------------------------------
1 |
2 | For loop
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/database.html:
--------------------------------------------------------------------------------
1 |
2 | Database
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/forLoop.html:
--------------------------------------------------------------------------------
1 |
2 | For loop
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/usingIndexOf.html:
--------------------------------------------------------------------------------
1 |
2 | Using indexOf
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/usingPop.html:
--------------------------------------------------------------------------------
1 |
2 | Using pop
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/usingPush.html:
--------------------------------------------------------------------------------
1 |
2 | Using push
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter04/usingSplice.html:
--------------------------------------------------------------------------------
1 |
2 | Using splice
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter05/islandAdventure/fonts/PiratesWriters.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter05/islandAdventure/fonts/PiratesWriters.ttf
--------------------------------------------------------------------------------
/Code - Published/chapter05/islandAdventure/images/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter05/islandAdventure/images/background.png
--------------------------------------------------------------------------------
/Code - Published/chapter05/islandAdventure/images/home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter05/islandAdventure/images/home.png
--------------------------------------------------------------------------------
/Code - Published/chapter05/islandAdventure/images/island.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter05/islandAdventure/images/island.png
--------------------------------------------------------------------------------
/Code - Published/chapter05/islandAdventure/images/monster.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter05/islandAdventure/images/monster.png
--------------------------------------------------------------------------------
/Code - Published/chapter05/islandAdventure/images/pirate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter05/islandAdventure/images/pirate.png
--------------------------------------------------------------------------------
/Code - Published/chapter05/islandAdventure/images/ship.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter05/islandAdventure/images/ship.png
--------------------------------------------------------------------------------
/Code - Published/chapter05/islandAdventure/images/water.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter05/islandAdventure/images/water.png
--------------------------------------------------------------------------------
/Code - Published/chapter05/islandAdventure/src/islandAdventure1.html:
--------------------------------------------------------------------------------
1 |
2 | Island Adventure 1
3 |
4 |
28 |
29 |
30 |
31 |
32 |
119 |
120 |
--------------------------------------------------------------------------------
/Code - Published/chapter05/islandAdventure/src/islandAdventure2.html:
--------------------------------------------------------------------------------
1 |
2 | Island Adventure 2
3 |
4 |
28 |
29 |
30 |
31 |
32 |
155 |
156 |
--------------------------------------------------------------------------------
/Code - Published/chapter05/looping2DArrays.html:
--------------------------------------------------------------------------------
1 |
2 | Looping through 2D arrays
3 |
4 |
51 |
52 |
--------------------------------------------------------------------------------
/Code - Published/chapter05/loopingThroughObjects.html:
--------------------------------------------------------------------------------
1 |
2 | Robot
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter05/twoDimensionalArrays.html:
--------------------------------------------------------------------------------
1 |
2 | 2D arrays
3 |
4 |
48 |
--------------------------------------------------------------------------------
/Code - Published/chapter05/visualizing2DArrays.html:
--------------------------------------------------------------------------------
1 |
2 | Visualizing 2D arrays
3 |
4 |
21 |
22 |
23 |
24 |
74 |
75 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/10_stateChangeTimer.html:
--------------------------------------------------------------------------------
1 |
2 | State change timer
3 |
4 |
5 |
6 |
66 |
67 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/11_animationObject.html:
--------------------------------------------------------------------------------
1 |
2 | Animation object
3 |
4 |
5 |
6 |
85 |
86 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/12_tilesheetWithRows.html:
--------------------------------------------------------------------------------
1 |
2 | Tilesheet with rows
3 |
4 |
5 |
6 |
87 |
88 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/13_animationLoop.html:
--------------------------------------------------------------------------------
1 |
2 | Animation loop
3 |
4 |
5 |
6 |
104 |
105 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/14_randomAnimation.html:
--------------------------------------------------------------------------------
1 |
2 | Random animation
3 |
4 |
5 |
6 |
147 |
148 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/1_displayingWithCanvas.html:
--------------------------------------------------------------------------------
1 |
2 | Displaying an image with canvas
3 |
4 |
12 |
13 |
14 |
15 |
88 |
89 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/2_robotObject.html:
--------------------------------------------------------------------------------
1 |
2 | Robot
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/3_loopingThroughObjects.html:
--------------------------------------------------------------------------------
1 |
2 | Looping through objects
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/4_changingStates.html:
--------------------------------------------------------------------------------
1 |
2 | Changing states
3 |
4 |
32 |
33 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/5_renderingStates.html:
--------------------------------------------------------------------------------
1 |
2 | Rendering states
3 |
4 |
5 |
6 |
85 |
86 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/6_usingSetTimeout.html:
--------------------------------------------------------------------------------
1 |
2 | Using setTimeout
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/7_usingSetInterval.html:
--------------------------------------------------------------------------------
1 |
2 | Using setInterval
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/8_usingClearInterval.html:
--------------------------------------------------------------------------------
1 |
2 | Using clearInterval
3 |
4 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/9_timerObject.html:
--------------------------------------------------------------------------------
1 |
2 | Timer object
3 |
4 |
22 |
23 |
--------------------------------------------------------------------------------
/Code - Published/chapter06/frames.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter06/frames.png
--------------------------------------------------------------------------------
/Code - Published/chapter06/monster.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter06/monster.png
--------------------------------------------------------------------------------
/Code - Published/chapter06/monsterSmash/fonts/Vanilla.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter06/monsterSmash/fonts/Vanilla.ttf
--------------------------------------------------------------------------------
/Code - Published/chapter06/monsterSmash/images/monsterTileSheet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter06/monsterSmash/images/monsterTileSheet.png
--------------------------------------------------------------------------------
/Code - Published/chapter06/monsterSmash/src/monsterSmash.css:
--------------------------------------------------------------------------------
1 | *
2 | {
3 | padding: 0px;
4 | margin: 0px;
5 | -webkit-user-select: none;
6 | -moz-user-select: none;
7 | user-select: none;
8 | }
9 |
10 | #stage
11 | {
12 | position: relative;
13 | width: 552px;
14 | height: 414px;
15 | }
16 |
17 | canvas
18 | {
19 | display: block;
20 | position: absolute;
21 | width: 128px;
22 | height: 128px;
23 |
24 | -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
25 | -moz-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
26 | box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
27 |
28 | -webkit-border-radius: 10px;
29 | -moz-border-radius: 10px;
30 | border-radius: 10px;
31 |
32 | cursor: pointer;
33 | }
34 |
35 | @font-face
36 | {
37 | font-family: Vanilla;
38 | src: url("../fonts/Vanilla.ttf");
39 | }
40 |
41 | p
42 | {
43 | font-family: Vanilla;
44 | font-size: 20px;
45 | padding: 20px;
46 | }
--------------------------------------------------------------------------------
/Code - Published/chapter06/monsterStates.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter06/monsterStates.png
--------------------------------------------------------------------------------
/Code - Published/chapter06/monsterTileSheet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter06/monsterTileSheet.png
--------------------------------------------------------------------------------
/Code - Published/chapter07/11_screenWrapping.html:
--------------------------------------------------------------------------------
1 |
2 | Screen wrapping
3 |
4 |
5 |
6 |
7 |
194 |
--------------------------------------------------------------------------------
/Code - Published/chapter07/15_mouseControl.html:
--------------------------------------------------------------------------------
1 |
2 | Mouse control
3 |
4 |
19 |
20 |
21 |
22 |
23 |
163 |
--------------------------------------------------------------------------------
/Code - Published/chapter07/16_touchControl.html:
--------------------------------------------------------------------------------
1 |
2 | Touch control
3 |
4 |
19 |
20 |
21 |
22 |
23 |
24 |
175 |
--------------------------------------------------------------------------------
/Code - Published/chapter07/1_basicSprite.html:
--------------------------------------------------------------------------------
1 |
2 | Basic sprite
3 |
4 |
5 |
6 |
7 |
95 |
--------------------------------------------------------------------------------
/Code - Published/chapter07/2_manySprites.html:
--------------------------------------------------------------------------------
1 |
2 | Many sprites
3 |
4 |
5 |
6 |
7 |
116 |
--------------------------------------------------------------------------------
/Code - Published/chapter07/3_manyImageFiles.html:
--------------------------------------------------------------------------------
1 |
2 | Many Image files
3 |
4 |
5 |
6 |
7 |
148 |
--------------------------------------------------------------------------------
/Code - Published/chapter07/9_keyboardControl.html:
--------------------------------------------------------------------------------
1 |
2 | Keyboard control
3 |
4 |
5 |
6 |
7 |
176 |
--------------------------------------------------------------------------------
/Code - Published/chapter07/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter07/background.png
--------------------------------------------------------------------------------
/Code - Published/chapter07/basicScrolling_Old.html:
--------------------------------------------------------------------------------
1 |
2 | Basic scrolling
3 |
4 |
5 |
6 |
158 |
--------------------------------------------------------------------------------
/Code - Published/chapter07/cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter07/cat.png
--------------------------------------------------------------------------------
/Code - Published/chapter07/parallaxScrollingTileSheet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter07/parallaxScrollingTileSheet.png
--------------------------------------------------------------------------------
/Code - Published/chapter07/phobosTileSheet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter07/phobosTileSheet.png
--------------------------------------------------------------------------------
/Code - Published/chapter07/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter07/tiger.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter07/tiger.png
--------------------------------------------------------------------------------
/Code - Published/chapter07/tileSheetWithBackground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter07/tileSheetWithBackground.png
--------------------------------------------------------------------------------
/Code - Published/chapter08/1_pointCollision.html:
--------------------------------------------------------------------------------
1 |
2 | Point collision
3 |
4 |
5 |
6 |
7 |
8 |
165 |
--------------------------------------------------------------------------------
/Code - Published/chapter08/2_canvasText.html:
--------------------------------------------------------------------------------
1 |
2 | Canvas text
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Code - Published/chapter08/catAndBox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter08/catAndBox.png
--------------------------------------------------------------------------------
/Code - Published/chapter08/catAndMonster.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter08/catAndMonster.png
--------------------------------------------------------------------------------
/Code - Published/chapter08/circles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter08/circles.png
--------------------------------------------------------------------------------
/Code - Published/chapter08/collisionTileSheet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter08/collisionTileSheet.png
--------------------------------------------------------------------------------
/Code - Published/chapter08/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter08/squares.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter08/squares.png
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/fonts/emulogic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter09/alienArmada/fonts/emulogic.ttf
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/images/alienArmada.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter09/alienArmada/images/alienArmada.png
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/sounds/explosion.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter09/alienArmada/sounds/explosion.mp3
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/sounds/explosion.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter09/alienArmada/sounds/explosion.ogg
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/sounds/music.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter09/alienArmada/sounds/music.mp3
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/sounds/music.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter09/alienArmada/sounds/music.ogg
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/sounds/shoot.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter09/alienArmada/sounds/shoot.mp3
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/sounds/shoot.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter09/alienArmada/sounds/shoot.ogg
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/src/alienArmada.css:
--------------------------------------------------------------------------------
1 | @font-face
2 | {
3 | font-family: emulogic;
4 | src: url("../fonts/emulogic.ttf");
5 | }
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/src/alienArmada.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Alien Armada!
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/src/alienArmada1.js:
--------------------------------------------------------------------------------
1 | (function(){
2 |
3 | //The canvas
4 | var canvas = document.querySelector("canvas");
5 |
6 | //Create the drawing surface
7 | var drawingSurface = canvas.getContext("2d");
8 |
9 | //Arrays to store the game objects and assets to load
10 | var sprites = [];
11 | var assetsToLoad = [];
12 |
13 | //Create the background
14 | var background = Object.create(spriteObject);
15 | background.x = 0;
16 | background.y = 0;
17 | background.sourceY = 32;
18 | background.sourceWidth = 480;
19 | background.sourceHeight = 320;
20 | background.width = 480;
21 | background.height = 320;
22 | sprites.push(background);
23 |
24 | //Create the cannon and center it
25 | var cannon = Object.create(spriteObject);
26 | cannon.x = canvas.width / 2 - cannon.width / 2;
27 | cannon.y = 280;
28 | sprites.push(cannon);
29 |
30 | //Load the tilesheet image
31 | var image = new Image();
32 | image.addEventListener("load", loadHandler, false);
33 | image.src = "../images/alienArmada.png";
34 | assetsToLoad.push(image);
35 |
36 | //Variable to count the number of assets the game needs to load
37 | var assetsLoaded = 0;
38 |
39 | //Game states
40 | var LOADING = 0
41 | var PLAYING = 1;
42 | var OVER = 2;
43 | var gameState = LOADING;
44 |
45 | //Arrow key codes
46 | var RIGHT = 39;
47 | var LEFT = 37;
48 |
49 | //Directions
50 | var moveRight = false;
51 | var moveLeft = false;
52 |
53 | //Add keyboard listeners
54 | window.addEventListener("keydown", function(event)
55 | {
56 | switch(event.keyCode)
57 | {
58 | case LEFT:
59 | moveLeft = true;
60 | break;
61 |
62 | case RIGHT:
63 | moveRight = true;
64 | }
65 | }, false);
66 |
67 | window.addEventListener("keyup", function(event)
68 | {
69 | switch(event.keyCode)
70 | {
71 | case LEFT:
72 | moveLeft = false;
73 | break;
74 |
75 | case RIGHT:
76 | moveRight = false;
77 | }
78 | }, false);
79 |
80 | //Start the game animation loop
81 | update();
82 |
83 | function update()
84 | {
85 | //The animation loop
86 | requestAnimationFrame(update, canvas);
87 |
88 | //Change what the game is doing based on the game state
89 | switch(gameState)
90 | {
91 | case LOADING:
92 | console.log("loading…");
93 | break;
94 |
95 | case PLAYING:
96 | playGame();
97 | break;
98 |
99 | case OVER:
100 | endGame();
101 | break;
102 | }
103 |
104 | //Render the game
105 | render();
106 | }
107 |
108 | function loadHandler()
109 | {
110 | assetsLoaded++;
111 | if(assetsLoaded === assetsToLoad.length)
112 | {
113 | //Remove the load event listener
114 | image.removeEventListener("load", loadHandler, false);
115 |
116 | //Start the game
117 | gameState = PLAYING;
118 | }
119 | }
120 |
121 | function playGame()
122 | {
123 | //Left
124 | if(moveLeft && !moveRight)
125 | {
126 | cannon.vx = -8;
127 | }
128 | //Right
129 | if(moveRight && !moveLeft)
130 | {
131 | cannon.vx = 8;
132 | }
133 |
134 | //Set the cannon's velocity to zero if none of the keys are being pressed
135 | if(!moveLeft && !moveRight)
136 | {
137 | cannon.vx = 0;
138 | }
139 |
140 | //Move the cannon and keep it within the screen boundaries
141 | cannon.x = Math.max(0, Math.min(cannon.x + cannon.vx, canvas.width - cannon.width));
142 | }
143 |
144 | function endGame()
145 | {
146 | //Empty for now
147 | }
148 |
149 | function render()
150 | {
151 | drawingSurface.clearRect(0, 0, canvas.width, canvas.height);
152 |
153 | //Display the sprites
154 | if(sprites.length !== 0)
155 | {
156 | for(var i = 0; i < sprites.length; i++)
157 | {
158 | var sprite = sprites[i];
159 | drawingSurface.drawImage
160 | (
161 | image,
162 | sprite.sourceX, sprite.sourceY,
163 | sprite.sourceWidth, sprite.sourceHeight,
164 | Math.floor(sprite.x), Math.floor(sprite.y),
165 | sprite.width, sprite.height
166 | );
167 | }
168 | }
169 | }
170 |
171 | }());
172 |
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/src/objects.js:
--------------------------------------------------------------------------------
1 | //--- The sprite object
2 |
3 | var spriteObject =
4 | {
5 | sourceX: 0,
6 | sourceY: 0,
7 | sourceWidth: 32,
8 | sourceHeight: 32,
9 | width: 32,
10 | height: 32,
11 | x: 0,
12 | y: 0,
13 | vx: 0,
14 | vy: 0,
15 | visible: true,
16 |
17 | //Getters
18 | centerX: function()
19 | {
20 | return this.x + (this.width / 2);
21 | },
22 | centerY: function()
23 | {
24 | return this.y + (this.height / 2);
25 | },
26 | halfWidth: function()
27 | {
28 | return this.width / 2;
29 | },
30 | halfHeight: function()
31 | {
32 | return this.height / 2;
33 | }
34 | };
35 |
36 | //--- The alien object
37 |
38 | var alienObject = Object.create(spriteObject);
39 | alienObject.NORMAL = 1;
40 | alienObject.EXPLODED = 2;
41 | alienObject.state = alienObject.NORMAL;
42 | alienObject.update = function()
43 | {
44 | this.sourceX = this.state * this.width;
45 | };
46 |
47 | //--- The message object
48 |
49 | var messageObject =
50 | {
51 | x: 0,
52 | y: 0,
53 | visible: true,
54 | text: "Message",
55 | font: "normal bold 20px Helvetica",
56 | fillStyle: "red",
57 | textBaseline: "top"
58 | };
59 |
60 |
--------------------------------------------------------------------------------
/Code - Published/chapter09/alienArmada/src/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter10/monsterMayhem/images/monsterMayhem.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter10/monsterMayhem/images/monsterMayhem.png
--------------------------------------------------------------------------------
/Code - Published/chapter10/monsterMayhem/src/monsterMayhem.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Monster Mayhem
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Code - Published/chapter10/monsterMayhem/src/objects.js:
--------------------------------------------------------------------------------
1 | //--- The sprite object
2 |
3 | var spriteObject =
4 | {
5 | sourceX: 0,
6 | sourceY: 0,
7 | sourceWidth: 64,
8 | sourceHeight: 64,
9 | width: 64,
10 | height: 64,
11 | x: 0,
12 | y: 0,
13 | vx: 0,
14 | vy: 0,
15 | visible: true,
16 | scrollable: true,
17 |
18 | //Getters
19 | centerX: function()
20 | {
21 | return this.x + (this.width / 2);
22 | },
23 | centerY: function()
24 | {
25 | return this.y + (this.height / 2);
26 | },
27 | halfWidth: function()
28 | {
29 | return this.width / 2;
30 | },
31 | halfHeight: function()
32 | {
33 | return this.height / 2;
34 | },
35 | };
36 |
37 | //--- The monster object
38 |
39 | monsterObject = Object.create(spriteObject);
40 | monsterObject.sourceX = 128;
41 |
42 | //The monster's states
43 | monsterObject.NORMAL = [2,0];
44 | monsterObject.SCARED = [2,1];
45 | monsterObject.state = monsterObject.NORMAL;
46 |
47 | monsterObject.update = function()
48 | {
49 | this.sourceX = this.state[0] * this.width;
50 | this.sourceY = this.state[1] * this.height;
51 | };
52 |
53 | //The monster's allowed speed
54 | monsterObject.speed = 1;
55 |
56 | //Properties to help the monster change direction
57 | monsterObject.NONE = 0;
58 | monsterObject.UP = 1;
59 | monsterObject.DOWN = 2;
60 | monsterObject.LEFT = 3;
61 | monsterObject.RIGHT = 4;
62 | monsterObject.validDirections = [];
63 | monsterObject.direction = monsterObject.NONE;
64 | monsterObject.hunt = false;
--------------------------------------------------------------------------------
/Code - Published/chapter10/monsterMayhem/src/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter10/monsterMaze/images/monsterMaze.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter10/monsterMaze/images/monsterMaze.png
--------------------------------------------------------------------------------
/Code - Published/chapter10/monsterMaze/src/monsterMaze.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Monster Maze
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Code - Published/chapter10/monsterMaze/src/objects.js:
--------------------------------------------------------------------------------
1 | //--- The sprite object
2 |
3 | var spriteObject =
4 | {
5 | sourceX: 0,
6 | sourceY: 0,
7 | sourceWidth: 64,
8 | sourceHeight: 64,
9 | width: 64,
10 | height: 64,
11 | x: 0,
12 | y: 0,
13 | vx: 0,
14 | vy: 0,
15 | visible: true,
16 |
17 | //Getters
18 | centerX: function()
19 | {
20 | return this.x + (this.width / 2);
21 | },
22 | centerY: function()
23 | {
24 | return this.y + (this.height / 2);
25 | },
26 | halfWidth: function()
27 | {
28 | return this.width / 2;
29 | },
30 | halfHeight: function()
31 | {
32 | return this.height / 2;
33 | },
34 | };
35 |
36 | //--- The monster object
37 |
38 | monsterObject = Object.create(spriteObject);
39 | monsterObject.sourceX = 128;
40 |
41 | //The monster's states
42 | monsterObject.NORMAL = [2,0];
43 | monsterObject.SCARED = [2,1];
44 | monsterObject.state = monsterObject.NORMAL;
45 |
46 | monsterObject.update = function()
47 | {
48 | this.sourceX = this.state[0] * this.width;
49 | this.sourceY = this.state[1] * this.height;
50 | };
51 |
52 | //The monster's allowed speed
53 | monsterObject.speed = 1;
54 |
55 | //Properties to help the monster change direction
56 | monsterObject.NONE = 0;
57 | monsterObject.UP = 1;
58 | monsterObject.DOWN = 2;
59 | monsterObject.LEFT = 3;
60 | monsterObject.RIGHT = 4;
61 | monsterObject.validDirections = [];
62 | monsterObject.direction = monsterObject.NONE;
63 | monsterObject.hunt = true;
--------------------------------------------------------------------------------
/Code - Published/chapter10/monsterMaze/src/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter10/movingMonster/movingMonster.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter10/movingMonster/movingMonster.png
--------------------------------------------------------------------------------
/Code - Published/chapter10/movingMonster/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter10/timeBombPanic/images/timeBombPanic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter10/timeBombPanic/images/timeBombPanic.png
--------------------------------------------------------------------------------
/Code - Published/chapter10/timeBombPanic/src/objects.js:
--------------------------------------------------------------------------------
1 | //--- The sprite object
2 |
3 | var spriteObject =
4 | {
5 | sourceX: 0,
6 | sourceY: 0,
7 | sourceWidth: 64,
8 | sourceHeight: 64,
9 | width: 64,
10 | height: 64,
11 | x: 0,
12 | y: 0,
13 | vx: 0,
14 | vy: 0,
15 | visible: true,
16 |
17 | //Getters
18 | centerX: function()
19 | {
20 | return this.x + (this.width / 2);
21 | },
22 | centerY: function()
23 | {
24 | return this.y + (this.height / 2);
25 | },
26 | halfWidth: function()
27 | {
28 | return this.width / 2;
29 | },
30 | halfHeight: function()
31 | {
32 | return this.height / 2;
33 | },
34 | };
35 |
36 | //--- The message object
37 |
38 | var messageObject =
39 | {
40 | x: 0,
41 | y: 0,
42 | visible: true,
43 | text: "Message",
44 | font: "normal bold 20px Helvetica",
45 | fillStyle: "red",
46 | textBaseline: "top"
47 | };
48 |
49 | //--- The gameTimer object
50 |
51 | var gameTimer =
52 | {
53 | time: 0,
54 | interval: undefined,
55 |
56 | start: function()
57 | {
58 | var self = this;
59 | this.interval = setInterval(function(){self.tick();}, 1000);
60 | },
61 | tick: function()
62 | {
63 | this.time--;
64 | },
65 | stop: function()
66 | {
67 | clearInterval(this.interval);
68 | },
69 | reset: function()
70 | {
71 | this.time = 0;
72 | }
73 | };
74 |
75 |
--------------------------------------------------------------------------------
/Code - Published/chapter10/timeBombPanic/src/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter10/timeBombPanic/src/timeBombPanic.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Time Bomb Panic
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Code - Published/chapter10/timeBombScroll/images/timeBombPanic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter10/timeBombScroll/images/timeBombPanic.png
--------------------------------------------------------------------------------
/Code - Published/chapter10/timeBombScroll/src/objects.js:
--------------------------------------------------------------------------------
1 | //--- The sprite object
2 |
3 | var spriteObject =
4 | {
5 | sourceX: 0,
6 | sourceY: 0,
7 | sourceWidth: 64,
8 | sourceHeight: 64,
9 | width: 64,
10 | height: 64,
11 | x: 0,
12 | y: 0,
13 | vx: 0,
14 | vy: 0,
15 | visible: true,
16 | scrollable: true,
17 |
18 | //Getters
19 | centerX: function()
20 | {
21 | return this.x + (this.width / 2);
22 | },
23 | centerY: function()
24 | {
25 | return this.y + (this.height / 2);
26 | },
27 | halfWidth: function()
28 | {
29 | return this.width / 2;
30 | },
31 | halfHeight: function()
32 | {
33 | return this.height / 2;
34 | },
35 | };
36 |
37 | //--- The message object
38 |
39 | var messageObject =
40 | {
41 | x: 0,
42 | y: 0,
43 | visible: true,
44 | text: "Message",
45 | font: "normal bold 20px Helvetica",
46 | fillStyle: "red",
47 | textBaseline: "top"
48 | };
49 |
50 | //--- The gameTimer object
51 |
52 | var gameTimer =
53 | {
54 | time: 0,
55 | interval: undefined,
56 |
57 | start: function()
58 | {
59 | var self = this;
60 | this.interval = setInterval(function(){self.tick();}, 1000);
61 | },
62 | tick: function()
63 | {
64 | this.time--;
65 | },
66 | stop: function()
67 | {
68 | clearInterval(this.interval);
69 | },
70 | reset: function()
71 | {
72 | this.time = 0;
73 | }
74 | };
75 |
76 |
--------------------------------------------------------------------------------
/Code - Published/chapter10/timeBombScroll/src/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter10/timeBombScroll/src/timeBombScroll.html:
--------------------------------------------------------------------------------
1 |
2 | Time Bomb Scroll
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Code - Published/chapter11/cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter11/cat.png
--------------------------------------------------------------------------------
/Code - Published/chapter11/catAndBox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter11/catAndBox.png
--------------------------------------------------------------------------------
/Code - Published/chapter11/circles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter11/circles.png
--------------------------------------------------------------------------------
/Code - Published/chapter11/hedgehogApocalypse/images/hedgehogApocalypse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter11/hedgehogApocalypse/images/hedgehogApocalypse.png
--------------------------------------------------------------------------------
/Code - Published/chapter11/hedgehogApocalypse/src/hedgehogAplocalypse.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hedgehog Apocalypse
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Code - Published/chapter11/hedgehogApocalypse/src/objects.js:
--------------------------------------------------------------------------------
1 | //--- The sprite object
2 |
3 | var spriteObject =
4 | {
5 | sourceX: 0,
6 | sourceY: 0,
7 | sourceWidth: 64,
8 | sourceHeight: 64,
9 | width: 64,
10 | height: 64,
11 | x: 0,
12 | y: 0,
13 | vx: 0,
14 | vy: 0,
15 | visible: true,
16 |
17 | //Physics properties
18 | accelerationX: 0,
19 | accelerationY: 0,
20 | speedLimit: 5,
21 | friction: 0.96,
22 | bounce: -0.7,
23 | gravity: 0.3,
24 |
25 | //Platform game properties
26 | isOnGround: undefined,
27 | jumpForce: -10,
28 |
29 | //Getters
30 | centerX: function()
31 | {
32 | return this.x + (this.width / 2);
33 | },
34 | centerY: function()
35 | {
36 | return this.y + (this.height / 2);
37 | },
38 | halfWidth: function()
39 | {
40 | return this.width / 2;
41 | },
42 | halfHeight: function()
43 | {
44 | return this.height / 2;
45 | }
46 | };
47 |
48 | //--- The hedgehog object
49 | hedgehogObject = Object.create(spriteObject);
50 |
51 | //The hedgehog's states
52 | hedgehogObject.NORMAL = [1,0];
53 | hedgehogObject.SQUASHED = [2,0];
54 | hedgehogObject.state = hedgehogObject.NORMAL;
55 |
56 | hedgehogObject.update = function()
57 | {
58 | this.sourceX = this.state[0] * this.sourceWidth;
59 | this.sourceY = this.state[1] * this.sourceHeight;
60 | };
61 |
62 | //The hedgehog's allowed speed
63 | hedgehogObject.speed = 1;
64 |
65 | //--- The message object
66 |
67 | var messageObject =
68 | {
69 | x: 0,
70 | y: 0,
71 | visible: true,
72 | text: "Message",
73 | font: "normal bold 20px Helvetica",
74 | fillStyle: "red",
75 | textBaseline: "top"
76 | };
--------------------------------------------------------------------------------
/Code - Published/chapter11/hedgehogApocalypse/src/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter11/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter12/constructorFunction.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Constructor function
4 |
5 |
--------------------------------------------------------------------------------
/Code - Published/chapter12/dragAndDrop/dragAndDrop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter12/dragAndDrop/dragAndDrop.png
--------------------------------------------------------------------------------
/Code - Published/chapter12/dragAndDrop/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter12/hedgehogMouse/images/hedgehogApocalypse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter12/hedgehogMouse/images/hedgehogApocalypse.png
--------------------------------------------------------------------------------
/Code - Published/chapter12/hedgehogMouse/src/hedgehogAplocalypse.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hedgehog Apocalypse
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Code - Published/chapter12/hedgehogMouse/src/objects.js:
--------------------------------------------------------------------------------
1 | //--- The sprite object
2 |
3 | var spriteObject =
4 | {
5 | sourceX: 0,
6 | sourceY: 0,
7 | sourceWidth: 64,
8 | sourceHeight: 64,
9 | x: 0,
10 | y: 0,
11 | vx: 0,
12 | vy: 0,
13 | height: 64,
14 | width: 64,
15 | visible: true,
16 |
17 | //Physics properties
18 | accelerationX: 0,
19 | accelerationY: 0,
20 | speedLimit: 5,
21 | friction: 0.96,
22 | bounce: -0.7,
23 | gravity: 0.3,
24 |
25 | //Platform game properties
26 | isOnGround: undefined,
27 | jumpForce: -10,
28 |
29 | //Getters
30 | centerX: function()
31 | {
32 | return this.x + (this.width / 2);
33 | },
34 | centerY: function()
35 | {
36 | return this.y + (this.height / 2);
37 | },
38 | halfWidth: function()
39 | {
40 | return this.width / 2;
41 | },
42 | halfHeight: function()
43 | {
44 | return this.height / 2;
45 | }
46 | };
47 |
48 | //--- The hedgehog object
49 | hedgehogObject = Object.create(spriteObject);
50 |
51 | //The hedgehog's states
52 | hedgehogObject.NORMAL = [1,0];
53 | hedgehogObject.SQUASHED = [2,0];
54 | hedgehogObject.state = hedgehogObject.NORMAL;
55 |
56 | hedgehogObject.update = function()
57 | {
58 | this.sourceX = this.state[0] * this.sourceWidth;
59 | this.sourceY = this.state[1] * this.sourceHeight;
60 | };
61 |
62 | //The hedgehog's allowed speed
63 | hedgehogObject.speed = 1;
64 |
65 | //--- The message object
66 |
67 | var messageObject =
68 | {
69 | x: 0,
70 | y: 0,
71 | visible: true,
72 | text: "Message",
73 | font: "normal bold 20px Helvetica",
74 | fillStyle: "red",
75 | textBaseline: "top"
76 | };
--------------------------------------------------------------------------------
/Code - Published/chapter12/hedgehogMouse/src/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter12/images/bee.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter12/images/bee.png
--------------------------------------------------------------------------------
/Code - Published/chapter12/images/buttonFairy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter12/images/buttonFairy.png
--------------------------------------------------------------------------------
/Code - Published/chapter12/images/catAndBox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter12/images/catAndBox.png
--------------------------------------------------------------------------------
/Code - Published/chapter12/images/vehicles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter12/images/vehicles.png
--------------------------------------------------------------------------------
/Code - Published/chapter12/keyboard/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter12/killerBeePandemonium/images/killerBeePandemonium.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/Code - Published/chapter12/killerBeePandemonium/images/killerBeePandemonium.png
--------------------------------------------------------------------------------
/Code - Published/chapter12/killerBeePandemonium/src/killerBeeMouse.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Killer Bee Pandemonium - Mouse Controlled
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Code - Published/chapter12/killerBeePandemonium/src/killerBeeTouch.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Killer Bee Pandemonium - Touch Controlled
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Code - Published/chapter12/killerBeePandemonium/src/objects.js:
--------------------------------------------------------------------------------
1 | //--- The sprite object
2 |
3 | var spriteObject =
4 | {
5 | sourceX: 0,
6 | sourceY: 0,
7 | sourceWidth: 64,
8 | sourceHeight: 64,
9 | width: 64,
10 | height: 64,
11 | x: 0,
12 | y: 0,
13 | vx: 0,
14 | vy: 0,
15 | visible: true,
16 | rotation: 0,
17 |
18 | //Physics properties
19 | accelerationX: 0,
20 | accelerationY: 0,
21 | speed: 3,
22 | rotationSpeed: 0.3,
23 | speedLimit: 5,
24 | friction: 0.96,
25 |
26 | //Getters
27 | centerX: function()
28 | {
29 | return this.x + (this.width / 2);
30 | },
31 | centerY: function()
32 | {
33 | return this.y + (this.height / 2);
34 | },
35 | halfWidth: function()
36 | {
37 | return this.width / 2;
38 | },
39 | halfHeight: function()
40 | {
41 | return this.height / 2;
42 | }
43 | };
44 |
45 | //--- The message object
46 |
47 | var messageObject =
48 | {
49 | x: 0,
50 | y: 0,
51 | visible: true,
52 | text: "Message",
53 | font: "normal bold 20px Helvetica",
54 | fillStyle: "red",
55 | textBaseline: "top"
56 | };
--------------------------------------------------------------------------------
/Code - Published/chapter12/killerBeePandemonium/src/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter12/mouse/easingMouse.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Easing
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Code - Published/chapter12/mouse/followMouse.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Follow
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Code - Published/chapter12/mouse/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/Code - Published/chapter12/touch/followTouch.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Follow
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Code - Published/chapter12/touch/requestAnimationFramePolyfill.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 |
4 | // requestAnimationFrame polyfill by Erik Möller
5 | // fixes from Paul Irish and Tino Zijdel
6 |
7 | (function() {
8 |
9 | var lastTime = 0;
10 | var vendors = ['ms', 'moz', 'webkit', 'o'];
11 |
12 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x)
13 | {
14 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
15 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
16 | window[vendors[x]+'CancelRequestAnimationFrame'];
17 | }
18 |
19 | if (!window.requestAnimationFrame)
20 | window.requestAnimationFrame = function(callback, element) {
21 | var currTime = new Date().getTime();
22 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
23 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
24 | lastTime = currTime + timeToCall;
25 | return id;
26 | };
27 |
28 | if (!window.cancelAnimationFrame)
29 | {
30 | window.cancelAnimationFrame = function(id)
31 | {
32 | clearTimeout(id);
33 | };
34 | }
35 |
36 | }());
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Apress/foundation-game-design-w-html5-javascript/ba65a24f4143488fb44bd9b7a1598a832de54b5d/LICENSE.txt
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Apress Source Code
2 |
3 | This repository accompanies [*Foundation Game Design with HTML5 and JavaScript*](http://www.apress.com/9781430247166) by Rex van der Spuy (Apress, 2012).
4 |
5 | 
6 |
7 | Download the files as a zip using the green button, or clone the repository to your machine using Git.
8 |
9 | ## Releases
10 |
11 | Release v1.0 corresponds to the code in the published book, without corrections or updates.
12 |
13 | ## Contributions
14 |
15 | See the file Contributing.md for more information on how you can contribute to this repository.
16 |
--------------------------------------------------------------------------------
/contributing.md:
--------------------------------------------------------------------------------
1 | # Contributing to Apress Source Code
2 |
3 | Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers.
4 |
5 | ## How to Contribute
6 |
7 | 1. Make sure you have a GitHub account.
8 | 2. Fork the repository for the relevant book.
9 | 3. Create a new branch on which to make your change, e.g.
10 | `git checkout -b my_code_contribution`
11 | 4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted.
12 | 5. Submit a pull request.
13 |
14 | Thank you for your contribution!
--------------------------------------------------------------------------------