Chapter 2: A Vivid Description Printing Out a Scene Description Open up your tool of choice (see Chapter 1 for download assistance) and stretch your fingers, it’s time to embark on a journey of creation. First thing you’ll want to do, in order to make sure your environment is properly set up is type this out:
>>> print("Hello, World!") Figure 2.01
If everything is in order, this should display to the screen (wherever your output is going) the words
Hello, World! If it doesn’t, you’ll want to figure out what’s wrong before moving forward. What, you might be asking, are we going to do with the ability to display these very specific words to the screen? We can actually write any characters we want, arranged in any order. Such is the benefit of programming: almost complete freedom. Freedom to, say, print out a description of a scene for the player to read. In order to display something else, we’ll have to see within Figure 2.01 what to change. Taking the print statement, we are able to replace those words encased by “” with what we want to print. For instance:
>>> print("You wake up in a cave, to your right is a door. It’s dark brown wood, moldy and surrounded by a rusted metal outline.") Figure 2.02
If you type this out, the interpreter will respond to you by displaying that exact description from “you wake up...” to “...outline”. So you’ve probably guessed the format here, you can use print("_") to display whatever you desire, just typing the characters inside of the quotations. The print() is what we call a function, it’s named “print” and it performs the specific task of displaying whatever we need to the screen. The quotations around the words simply means “these are characters” and not, say, a variable. We call this printing a string, or a grouping of characters. We’ll talk more about these concepts later in Chapter 3. Main Ideas: