3D Game Programming

296 Pages · 13.44 mb ·

Programming

Table of contents

- Cover (Page 1)
- Table of Contents (Page 7)
- Acknowledgments (Page 13)
- Introduction (Page 14)
- How I Learned to Program (Page 14)
- What You Need for This Book (Page 14)
- What Is JavaScript? (Page 15)
- How to Read This Book (Page 15)
- Let’s Get Started! (Page 15)
- 1. Project: Creating Simple Shapes (Page 16)
- Programming with the ICE Code Editor (Page 16)
- Making Shapes with JavaScript (Page 19)
- Animating the Shapes (Page 29)
- The Code So Far (Page 30)
- What's Next (Page 30)
- 2. Playing with the Console and Finding What’s Broken (Page 31)
- Getting Started (Page 31)
- Opening and Closing the JavaScript Console (Page 32)
- Debugging in ICE: The Red X (Page 33)
- Debugging in ICE: The Yellow Triangle (Page 33)
- Debugging in the Console (Page 34)
- Recovering When ICE Is Broken (Page 37)
- What’s Next (Page 38)
- 3. Project: Making an Avatar (Page 39)
- Getting Started (Page 40)
- Making a Whole from Parts (Page 40)
- Breaking It Down (Page 42)
- Adding Feet for Walking (Page 43)
- Challenge: Make the Avatar Your Own (Page 45)
- Doing Cartwheels (Page 46)
- The Code So Far (Page 48)
- What’s Next (Page 48)
- 4. Project: Moving Avatars (Page 49)
- Getting Started (Page 49)
- Building Interactive Systems with Keyboard Events (Page 50)
- Converting Keyboard Events into Avatar Movement (Page 51)
- Challenge: Start/Stop Animation (Page 53)
- Building a Forest with Functions (Page 54)
- Moving the Camera with the Avatar (Page 57)
- The Code So Far (Page 61)
- What’s Next (Page 61)
- 5. Functions: Use and Use Again (Page 62)
- Getting Started (Page 62)
- Understanding Simple Functions (Page 66)
- When Things Go Wrong (Page 67)
- Weird Tricks with Functions (Page 70)
- The Code So Far (Page 71)
- What’s Next (Page 71)
- 6. Project: Moving Hands and Feet (Page 72)
- Getting Started (Page 72)
- Moving a Hand (Page 72)
- Swinging Hands and Feet Together (Page 76)
- Walking When Moving (Page 76)
- The Code So Far (Page 79)
- What’s Next (Page 79)
- 7. A Closer Look at JavaScript Fundamentals (Page 80)
- Getting Started (Page 80)
- Describing a Thing in JavaScript (Page 80)
- Changing Things (Page 82)
- Repeating and Skipping Code with while and if (Page 87)
- Listing Things (Page 90)
- What Makes JavaScript Different (Page 91)
- What’s Next (Page 91)
- 8. Project: Turning Our Avatar (Page 92)
- Getting Started (Page 92)
- Facing the Proper Direction (Page 92)
- Breaking It Down (Page 94)
- Animating the Spin (Page 95)
- The Code So Far (Page 97)
- What’s Next (Page 97)
- 9. What's All That Other Code? (Page 98)
- Getting Started (Page 98)
- A Quick Introduction to HTML (Page 98)
- Setting the Scene (Page 100)
- Using Cameras to Capture the Scene (Page 100)
- Using a Renderer to Project What the Camera Sees (Page 101)
- Exploring Different Cameras and Renderers (Page 102)
- What’s Next (Page 104)
- 10. Project: Collisions (Page 105)
- Getting Started (Page 105)
- Rays and Intersections (Page 106)
- The Code So Far (Page 110)
- What’s Next (Page 110)
- 11. Project: Fruit Hunt (Page 111)
- Getting Started (Page 111)
- Starting a Scoreboard at Zero (Page 112)
- Giving Trees a Little Wiggle (Page 113)
- Jumping for Points (Page 115)
- Making Our Games Even Better (Page 117)
- The Code So Far (Page 119)
- What’s Next (Page 119)
- 12. Working with Lights and Materials (Page 120)
- Getting Started (Page 120)
- Changing Color (Page 120)
- Realism: Shininess (Page 122)
- Shadows (Page 124)
- Let’s Animate! (Page 126)
- The Code So Far (Page 127)
- What’s Next (Page 127)
- 13. Project: Build Your Own Solar System (Page 128)
- Getting Started (Page 128)
- The Sun, Earth, and Mars (Page 128)
- Earth-Cam! (Page 132)
- The Code So Far (Page 134)
- What’s Next (Page 134)
- 14. Project: Phases of the Moon (Page 135)
- Getting Started (Page 136)
- Change Mars into the Moon (Page 136)
- The Coolest Trick: Frame of Reference (Page 137)
- Challenge: Create an Earth Orbit Frame of Reference (Page 139)
- Pausing the Simulation (Page 139)
- Understanding the Phases (Page 141)
- The Code So Far (Page 142)
- What’s Next (Page 142)
- 15. Project: The Purple Fruit Monster Game (Page 143)
- Getting Started (Page 143)
- Let’s Make Physics! (Page 143)
- Outline the Game (Page 145)
- The Code So Far (Page 153)
- What’s Next (Page 153)
- 16. Project: Tilt-a-Board (Page 154)
- Getting Started (Page 155)
- Gravity and Other Setup (Page 155)
- Outline the Game (Page 156)
- The Code So Far (Page 166)
- What’s Next (Page 166)
- 17. Project: Learning about JavaScript Objects (Page 167)
- Getting Started (Page 167)
- Simple Objects (Page 168)
- Copying Objects (Page 169)
- Constructing New Objects (Page 170)
- The Code So Far (Page 172)
- What’s Next (Page 172)
- 18. Project: Cave Puzzle (Page 173)
- Getting Started (Page 173)
- Setting the Game’s Boundaries (Page 175)
- Building a Random, Unreachable Goal (Page 178)
- Building Draggable Ramps (Page 179)
- Winning the Game (Page 182)
- The Code So Far (Page 184)
- What’s Next (Page 184)
- 19. Project: Multilevel Game (Page 185)
- Getting Started (Page 185)
- Building Levels (Page 186)
- Adding Finishing Touches to the Game (Page 191)
- The Code So Far (Page 192)
- What’s Next (Page 192)
- 20. Project: River Rafting (Page 193)
- Getting Started (Page 193)
- Organizing Code (Page 194)
- Warping Shapes to Make Unique Things (Page 197)
- Build a Raft for Racing (Page 203)
- Setting the Finish Line (Page 206)
- The Code So Far (Page 213)
- What’s Next (Page 213)
- 21. Getting Code on the Web (Page 214)
- The Mighty, Mighty Browser (Page 215)
- Free Websites (Page 219)
- Putting Your Code on Another Site (Page 220)
- What’s Next (Page 222)
- A1. Project Code (Page 223)
- Code: Creating Simple Shapes (Page 223)
- Code: Playing with the Console and Finding What's Broken (Page 224)
- Code: Making an Avatar (Page 225)
- Code: Moving Avatars (Page 226)
- Code: Functions: Use and Use Again (Page 228)
- Code: Moving Hands and Feet (Page 229)
- Code: A Closer Look at JavaScript Fundamentals (Page 232)
- Code: Turning Our Avatar (Page 232)
- Code: What's All That Other Code? (Page 235)
- Code: Collisions (Page 236)
- Code: Fruit Hunt (Page 240)
- Code: Working with Lights and Materials (Page 246)
- Code: Build Your Own Solar System (Page 247)
- Code: Phases of the Moon (Page 249)
- Code: The Purple Fruit Monster Game (Page 251)
- Code: Tilt-a-Board (Page 255)
- Code: Learning about JavaScript Objects (Page 259)
- Code: Cave Puzzle (Page 261)
- Code: Multilevel Game (Page 265)
- Code: River Rafting (Page 271)
- A2. JavaScript Libraries Used in This Book (Page 279)
- Three.js (Page 279)
- Physijs (Page 279)
- Tween.js (Page 279)
- Scoreboard.js (Page 280)
- Sounds.js (Page 283)
- Index (Page 285)
- – SYMBOLS – (Page 285)
- – DIGITS – (Page 285)
- – A – (Page 285)
- – B – (Page 286)
- – C – (Page 286)
- – D – (Page 287)
- – E – (Page 287)
- – F – (Page 288)
- – G – (Page 288)
- – H – (Page 288)
- – I – (Page 289)
- – J – (Page 289)
- – K – (Page 289)
- – L – (Page 289)
- – M – (Page 289)
- – N – (Page 290)
- – O – (Page 290)
- – P – (Page 290)
- – Q – (Page 291)
- – R – (Page 291)
- – S – (Page 291)
- – T – (Page 292)
- – U – (Page 293)
- – V – (Page 293)
- – W – (Page 293)
- – X – (Page 293)
- – Y – (Page 293)
- – Z – (Page 293)