Chapter 14. Game Scripting

KEY TOPICS

  • Scripting Cookbook: What You Need

  • Implementing Touch and Release Notifications

  • Game Object Listeners

  • Scripting

  • Delayed Events

  • Putting It All Together

  • Enhancements

  • Summary

You walk into a dark room and flip a switch. A second later, a door opens across the way and light comes pouring in. But you don't get a chance to walk through the door—a couple of seconds later, the door slams shut and the room grows dark again. The trick? The door is only open for a few seconds, so you've got to flip the switch and run to get through the door.

How would you implement something like this in a game? That's what you'll solve in this chapter.

Every level in a typical game has a certain amount of unique code for environment interaction, ...

Get Developing Games in Java™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.