Introduction: Python Coding

Picture of Python Coding

Today i will show you how to make a simple "ghost game" in python.

I am assuming you have python-if not, click here.

Scroll down and look for "python 3.#.#". The number MUST have a three in front, but the others don't matter.

Then open IDLE (python GUI), open a new file, and save it as ghost game or whatever. All shown above

Note: This is from a book, i am just showing you how to make it on instructables.

Step 1: Game Setup

Picture of Game Setup

Copy in this to the window:

#Ghost Game (not necessary)

from random import randint

print('Ghost Game')

feeling_brave = True

score = 0

Step 2: Main Loop

Picture of Main Loop

This keeps the game going until you guess a "ghost" door

Type in:

while feeling_brave:

ghost_door = randint(1, 3)

print('Three doors ahead...')

print('A ghost behind one...')

print('Which do you open?')

door = input('1, 2, or 3?')

door_num = int(door)

Step 3: Branching Part

Picture of Branching Part

Type in:

if door_num == ghost_door:

print('GHOST!!!!')

feeling_brave = False

else:

print('No ghost!')

print('You enter the next room')

score = score + 1

Step 4: End Thing

Picture of End Thing

Type:

print('Run away!'
print('You scored', score)

Step 5: Done!

Save, hit F5 or run in 'run', and play your game.

I hope you enjoyed this instructable!

Comments

MCoder (author)2015-06-06

It's much simpler, did you try it? If you do, it will show you how it's different/similar

padbravo (author)2015-06-06

Is phyton similar to a "basic" basic?... seems to be?

MCoder (author)2015-06-06

Comment if you have any problems, and I will try and help. Have fun!

About This Instructable

1,199views

12favorites

Bio: I have seen the world grow. And also lasers
More by MCoder:Python coding
Add instructable to: