O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3D Game Programming for Kids, 2nd Edition

Book Description

You know what's even better than playing games? Programming your own! Make your own online games, even if you're an absolute beginner. Let your imagination come to 3D life as you learn real-world programming skills with the JavaScript programming language - the language used everywhere on the web. This new edition is completely revised, and takes advantage of new programming features to make game programming even easier to learn. Plus, new effects make your games even cooler. When you're done, you're going to be amazed at what you can create.

Jump right in! Start programming cool stuff on page 1. Keep building new and different things until the very last page. This book wants you to play. Not just play games, but play with code. Play with programming. Because the best way to learn something is to have fun with it!

This second edition is updated from start to finish to make it even easier to get started programming in JavaScript. Every example has been updated to make it easier, with new example games to explore and new 3D effects that make your games even more fun! Want a red donut? You can make hundreds of them, spinning around like mad. Want to create a star field? Make a hundred or a thousand stars. Make them red, green, or blue. Explosions? Fireworks? Planets? It's up to you. And, using a code editor created especially for this book, you'll program right in your web browser. You'll see the results of your work and imagination right away - right next to the code that you just typed! Along the way, you'll pick up a ton of programming knowledge, and dive in even deeper with some more advanced chapters.

Whatever you want to do, this book has your back. Best of all, you get to create awesome games and say, "I made this!"

What You Need:

You need the latest version of the Google Chrome Web browser, available for free from https://chrome.google.com. You also need an Internet connection to access the ICE Code Editor the first time. ICE Code Editor will be loaded onto your computer, so you won't need Internet access for later projects.

Table of Contents

  1.  Acknowledgments
  2.  Introduction
    1. How I Learned to Program (and Why That Matters to You)
    2. How YOU Can Learn to Program
    3. Getting Help
    4. What You Need for This Book
    5. What Is JavaScript?
    6. What’s New in the Second Edition?
    7. What This Book Is Not
    8. Let’s Get Started!
  3. 1. Project: Creating Simple Shapes
    1. Programming with the 3DE Code Editor
    2. Making Shapes with JavaScript
    3. Creating Spheres
    4. Making Boxes with the Cube Shape
    5. Using Cylinders for All Kinds of Shapes
    6. Building Flat Surfaces with Planes
    7. Rendering Donuts (Not the Kind You Eat) with Torus
    8. Animating the Shapes
    9. The Code So Far
    10. What’s Next
  4. 2. Debugging: Fixing Code When Things Go WrongDebugging: Fixing Code When Things Go Wrong
    1. Getting Started
    2. Debugging in 3DE: The Red X
    3. Debugging in 3DE: The Yellow Triangle
    4. Opening and Closing the JavaScript Console
    5. Debugging in the Console
    6. Common 3D Programming Errors
    7. Recovering When 3DE Is Broken
    8. What’s Next
  5. 3. Project: Making an Avatar
    1. Getting Started
    2. Smooth Chunkiness
    3. Making a Whole from Parts
    4. Breaking It Down
    5. Adding Feet for Walking
    6. Challenge: Make the Avatar Your Own
    7. Doing Cartwheels
    8. The Code So Far
    9. What’s Next
  6. 4. Project: Moving Avatars
    1. Getting Started
    2. Building Interactive Systems with Keyboard Events
    3. Converting Keyboard Events into Avatar Movement
    4. Challenge: Start/Stop Animation
    5. Building a Forest with Functions
    6. Moving the Camera with the Avatar
    7. The Code So Far
    8. What’s Next
  7. 5. Functions: Use and Use Again
    1. Getting Started
    2. Basic Functions
    3. Functions that Return Values
    4. Using Functions
    5. Breaking Functions
    6. Bonus #1: Random Colors
    7. Bonus #2: Flight Controls
    8. The Code So Far
    9. What’s Next
  8. 6. Project: Moving Hands and Feet
    1. Getting Started
    2. Moving a Hand
    3. Swinging Hands and Feet Together
    4. Walking When Moving
    5. The Code So Far
    6. What’s Next
  9. 7. A Closer Look at JavaScript Fundamentals
    1. Getting Started
    2. Describing Things in JavaScript
    3. Numbers, Words, and Other Things in JavaScript
    4. Control Structures
    5. What’s Next
  10. 8. Project: Turning Our Avatar
    1. Getting Started
    2. Facing the Proper Direction
    3. Breaking It Down
    4. Animating the Spin
    5. The Code So Far
    6. What’s Next
  11. 9. What’s All That Other Code? What’s All That Other Code?
    1. Getting Started
    2. A Quick Introduction to HTML
    3. Setting the Scene
    4. Using Cameras to Capture the Scene
    5. Using a Renderer to Project What the Camera Sees
    6. Exploring Different Cameras
    7. What’s Next
  12. 10. Project: Collisions
    1. Getting Started
    2. Rays and Intersections
    3. The Code So Far
    4. What’s Next
  13. 11. Project: Fruit Hunt
    1. Getting Started
    2. Starting a Scoreboard at Zero
    3. Giving Trees a Little Wiggle
    4. Jumping for Points
    5. Making Our Games Even Better
    6. The Code So Far
    7. What’s Next
  14. 12. Working with Lights and Materials
    1. Getting Started
    2. Emitting Light
    3. Ambient Light
    4. Point Light
    5. Shadows
    6. Spotlights and Sunlight
    7. Texture
    8. Further Exploration
    9. The Code So Far
    10. What’s Next
  15. 13. Project: Phases of the Moon
    1. Getting Started
    2. The Sun at the Center
    3. Game and Simulation Logic
    4. Local Coordinates
    5. Multi-Camera Action!
    6. Bonus #1: Stars
    7. Bonus #2: Flying Controls
    8. Understanding the Phases
    9. Not Perfect, But Still a Great Simulation
    10. The Code So Far
    11. What’s Next
  16. 14. Project: The Purple Fruit Monster Game
    1. Getting Started
    2. Outline the Game
    3. Adding Ground for the Game
    4. Build a Simple Avatar
    5. Add Scoring
    6. Gameplay
    7. Improvements
    8. The Code So Far
    9. What’s Next
  17. 15. Project: Tilt-a-Board
    1. Getting Started
    2. Outline the Game
    3. Bonus #1: Add a Background
    4. Bonus #2: Make Fire!
    5. Challenge
    6. The Code So Far
    7. What’s Next
  18. 16. Learning about JavaScript Objects
    1. Getting Started
    2. Simple Objects
    3. Properties and Methods
    4. Copying Objects
    5. Constructing New Objects
    6. The Worst Thing in JavaScript: Losing this
    7. Challenge
    8. The Code So Far
    9. What’s Next
  19. 17. Project: Ready, Steady, Launch
    1. Getting Started
    2. The Launcher
    3. Scoreboard
    4. Baskets and Goals
    5. Wind!
    6. The Code So Far
    7. What’s Next
  20. 18. Project: Two-Player Games
    1. Getting Started
    2. Two Launchers
    3. Two Scoreboards
    4. Teaching Baskets to Update the Correct Scoreboard
    5. Sharing a Keyboard
    6. A Complete Reset
    7. The Code So Far
    8. What’s Next
  21. 19. Project: River Rafter
    1. Getting Started
    2. Pushing and Pulling Shapes
    3. Rough Terrain
    4. Digging a River
    5. Scoreboard
    6. Build a Raft for Racing
    7. Resetting the Game
    8. Keyboard Controls
    9. The Finish Line
    10. Bonus: Keeping Score
    11. The Code So Far
    12. What’s Next
  22. 20. Getting Code on the Web
    1. The Mighty, Mighty Browser
    2. Free Websites
    3. Putting Your Code on Another Site
    4. The Code So Far
    5. What’s Next
  23. A1. Project Code
    1. Code: Creating Simple Shapes
    2. Code: Playing with the Console and Finding What’s Broken
    3. Code: Making an Avatar
    4. Code: Moving Avatars
    5. Code: Functions: Use and Use Again
    6. Code: Moving Hands and Feet
    7. Code: A Closer Look at JavaScript Fundamentals
    8. Code: Turning Our Avatar
    9. Code: What’s All That Other Code?
    10. Code: Collisions
    11. Code: Fruit Hunt
    12. Code: Working with Lights and Materials
    13. Code: Phases of the Moon
    14. Code: The Purple Fruit Monster Game
    15. Code: Tilt-a-Board
    16. Code: Learning about JavaScript Objects
    17. Code: Ready, Steady, Launch
    18. Code: Two-Player Ready, Steady, Launch
    19. Code: River Rafter
    20. Code: Getting Code on the Web
  24. A2. JavaScript Code Collections Used in This Book
    1. Three.js
    2. Physijs
    3. Controls
    4. Noise
    5. Scoreboard.js
    6. Shader Particle Engine
    7. Sounds.js
    8. Tween.js
  25.  Bibliography