Alright, so far, what I think the problem begins with is not having a full understanding of syntax, and tabs versus spaces. I have my tab set to four spaces. When I run the following code, the Python GUI (the black ms-dos looking thing, right?) flashes for only a few seconds and the program kills itself.
I use Python 2.4.5 i believe, and just downloaded PyGame and Py2exe thinking they could further my ability to produce a decent first time program. Anyways, Many of you already know I am starting off by attempting to write a text based game. I think my only problem is syntax, but no matter how I realign the script, I still get an error. Sometimes in the same place, sometimes another.
Well, here is my script...The majority of it was adapted from other sources I found either on this site or elsewhere online.
# this is supposed to be simple # I am trying to simulate combat # As easy as I can # "Untitled" # By Franki # You find the crystals to destroy the Solomon Terminal import random #!!!!! What does this do anyway? crystals = 0 global gotCrystal_1 global gotCrystal_2 global gotCrystal_3 global gotCrystal_4 gotCrystal_area1 = 0 gotCrystal_area2 = 0 gotCrystal_area3 = 0 gotCrystal_area4 = 0 gold = 0 global gotGold_1 global gotGold_2 global gotGold_3 global gotGold_4 gotGold_area1 = 0 gotGold_area2 = 0 gotGold_area3 = 0 gotgold_area4 = 0 # I am using Classes to make monsters (I don't know why) class Monster(object): #!!!!! Is this right? I found it in a snippet? """Monster""" def __init__(self,name,level): self.name = name self.level = level # The Monsters bad_hunter = Monster("Cavernian Hunter","1") bad_scout = Monster("Cavernian Scout","2") bad_warrior = Monster("Cavernian Warrior","3") bad_commander = Monster("Cavernian Troop Commander","4") def place_monster(): # the integer 1 places Monster, all others place nothing MOnster_in = random.randrange(2) if Monster_in == (0 or 2): return 0 Monster = random.randrange(4) if Monster == 0: Monster = bad_hunter elif Monster == 1: Monster = bad_scout elif Monster == 2: Monster = bad_warrior elif Monster == 3: Monster = bad_commander return Monster # THE AREAS # Only four rooms (areas) in first mission # #------Mission One Map-------- #=============================== #| 4 | 2 | Room 3 has stairs going to upstairs study #| | | Room 1 has exit house/enter town #|-----------|--------------| Room 2 is start point. Has chest full of gold #| 3 | 1 | needed to begin game and buy weapons. #| | | #============================== # # Framework: # room# = Room(name,description,enemies_y_n?) # Next add the coordinates below the room creators # Keep organized # This is the beginning of the game # It might be too long # I don't know how to give a back story # that gives enough information and isn't tediously long def help(): print '''Here is a list of commands. This is not exclusive, new commands will come into availablitly as you progress through the game. Actions: open (object) look at (object), survey, tell (target), go (direction; N,E, S, W,) take (object), drop (object), throw (object), attack (target), avoid (target). EXAMPLES: look at (tree), tell (Mr. Rogers), go (E), take (gold), drop (sword), throw (knife), attack (hunter), avoid (hunter) open (chest). REMEMBER: Enter all commands in lower case letters.''' print def start(): print '''It is the year 2115, over 100 years since the team of scientists discovered advanced foriegn schematics for an alternative energy source. Though the attempt to compress and harness the energy of fledging stars seemed to work rather well, slow and deadly atmospheric changes began to occur, until finally, mere years before the Sun lost 48% of it's energy, along with an estimated 5 out of 7 stars in our solar system losing 26.8% of their's, a great earthquake shook the Earth apart, revealing an underground civilization only 50 years behind Mankind in their technology. These underground dwellers, soon recognized as the long lost ancient man, the Neandrothal, weren't to pleased to have their world destroyed, along with their energy sources. Now, the Earth is a primitive world, and the time became known as The Second Dark Age. The sun no longer provided enough light to give us daytime, so we live in perpetual night.''' print def area1(): global gold global crystals print " You have = ", gold "gold" print " You have = ", crystals "crystals" print ''' You are in your house, in the upstairs study. You hear shouts coming from the village outside. In the study there are STAIRS going down, there is a DESK against the far wall, and a CHEST. Type 'help' for a full list of commands. Your only available exit is DOWN.''' print prompt_ar1() def ar1_desc(): print ''' The walls are made of logs fastened together with rope. Your DESK is cluttered with papers and books. The STAIRS going DOWN are your only exit. ''' print prompt_ar1() def prompt_ar1(): global gold global gotGold_area1 global gold_found1 prompt_a = raw_input("What will you do?").lower() try: if prompt_a == "go down": area2() elif prompt_a == "look at stairs": print "These stairs lead DOWN" elif prompt_a == "look at desk": print "Their is a DIARY on the desk" elif prompt_a == "take diary": print "You have taken the DIARY" elif prompt_a == "look at diary": print '''June 05, 2096, I have failed miserably. My project may very well be the end of the world. The creatures that we awoke from underground are attacking now, and some people started their own armies in an attempt to control what they see as as the best means to gain world power. But I fear there may not be a world to control very soon. I have seen odd Seismic activity in ' -The entry is not finished. Their is blood stained on the page.''' elif prompt_a == "look at chest": print " There is an inscription on it. EMERG. EQUIP." elif prompt_a == "open chest": print "There are 500 GOLD. There is 1 DAGGER. There is 1 SHOTGUN." elif prompt_a == "take gold": gold=gold+500 elif prompt_a == "take dagger": print "You have 1 dagger." elif prompt_a == "take shotgun": print "You have 1 shotgun." elif prompt_a == "survey": ar1_desc() elif prompt_a == "help": help() else: print "You cannot do that."