123 = raw_input("Tell me your name and press ENTER ")
print "Once I had a cat named " + 123
In order to build your game, you'll need to know a few programming basics. Let's learn about them now. The three things you'll need to know are:
1. How to ask a player for information
2. How to store that information
3. How to write a sentence using the player's information
Let's start with #1: Asking a player for information.
- Open Wing IDE, and in the top-left corner, type the following:
first_name = raw_input("Tell me your name, and click enter. ")
- Find the green "play" arrow. Click it. (This starts your game.)
- In the bottom-right corner, play your game.
There! You just figured out how to ask a player for information.
Now, let's figure out how we can store that information. The good news is that we're halfway done. Because you replied with your name, it has been stored as the variable "first_name". You can imagine that we have a jar called "first_name" and your name is inside it. Now, let's figure out how we can tell the computer to tell us what's in the "first_name" jar.
- In the top-left corner of Wing IDE, keep the line you just typed. Click "enter" so that you're on a new line. Type the following:
- Click the green "play" arrow again. Play your game in the lower-right corner. Note what happens.
Now, we're on to Step 3: displaying a sentence that uses the player's information.
Instead of just displaying your name when you play the game, imagine we wanted the computer to say, "Thanks! Your name is [your name here]." How would we do that?
- Go back to Wing IDE. On the line where you have the word "print", we're going to add some words. Change that line so that it looks like this:
print "Thanks! Your name is " + first_name
- Click the green "play" arrow. Play your game in the lower-right corner. Note what happens.
- Change the sentence you are "printing". Make it more fun! Copy and paste your code into the discussion below.
You now know the programming basics you'll need in order to build your first game!