Chapter 5. Raspi’s Cave Adventure

 

In this chapter, you’ll create a game to learn new programming techniques:

  • Drawing flow diagrams to map out complex programs
  • Using Boolean operators to check input from users
  • Making code for multiple choices using if, elif, and else statements
  • Creating and using your own functions to organize code and avoid repeating code
  • Nesting if/else statements to create games with complex logic

Like a great book, a game can create an entire imaginary world in your mind. One of the most exciting aspects of games is when you feel like you’re inside the game. This doesn’t require virtual-reality goggles or high-definition graphics. You can create this immersive feeling even in a completely text-based game by connecting with the player’s imagination and creating a world where they can make decisions and determine their own fate. To create games with imaginary worlds, you often have to generate a sense of depth by having the user move from room to room or scene to scene. The game should allow the user to choose their own path and introduce elements of surprise. Finally, you should also have some great descriptions that make the player feel like they’re in the room.

In this chapter, you’ll create just such a game, based on exploring an underground cavern. Along the way, the player will have to make choices, and if they make a wrong decision, the game is over. If they make the right decision, they’ll find untold treasures of gold, rubies, and diamonds!

Project introduction: Raspi’s Cave Adventure

 
 

Hey wait, you need a plan (flow diagrams)

 
 

Which way should Raspi go? (checking input)

 
 
 

Simplify! Making your own functions

 
 
 

Fruit Picker Extra: playing video

 

Challenges

 
 

Summary

 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest