preface - OOP background
please note that i'm from an OOP background and my answers will necessarily reflect that bias. i have no experience with python or any functional languages, so please keep in mind.
far too many if statements in the one block ....an explanation would be very helpful and handy to understand what is going on. if once comes back in 3 months to read the code - it might be difficult for the author to understand
please write use useful names
why do you have so many boolean variables? and they all sound the same: spawnStart, Spawn, SpawnIn, GameStart, wardrobeSpawn please use useful names. I can't emphasise the importance of giving useful names. sometimes i see methods like this: DoStuff(). please don't do things like that.
printing new lines
you can also print a new line with print "\n\nYou wake up in a room you don't recognise....." there's no need to repeat the print method more than once. cleaning up the print statements with \n alone improves the code.
also look up string interpolation in python.
the flow of the program
how will the game ever end: you don't set gamestart to false? also the wakeup statement is run only once so you needn't put it in the loop.
spawn is never set to false either. so you can safely remove this bit from the loop:
if spawn == True:
if spawnStart == True:
print(bcolors.FAIL + "You wake up in a room you don't
recognise, with no idea how you got there")
print(bcolors.ENDC + "You look around and see a wardrobe
and a door")
spawnStart = False
lastly, what is it that you are trying to accomplish with all these booleans: you don't want two actions to be repeated twice? i don't quite understand what's going on here.
It's not very oop
you don't want to see if statements too much. you want to see objects in your code. and you want to see this type of thing:
where Action is an instantiated object. apologies if that's the wrong python syntax - i don't know any python. In other words you want to see objects send "messages" to each other. Please read this:
The only place where you actually want to see if statements are in factory methods (actually this is not true - but you gotta be very skeptical of if statements as a developer starting out). too many of them and it may mean that your code will be very difficult to change and understand.
place code snippets in their own methods
this type of code: can be placed in a method. that way if you need to repeat it, you can do so easily.
print "The wardrobe seems quite empty, but you do
find a coin in the far left corner, you put it in your pocket"
coins += 1
wardrobeSpawn = True
spawnStart = False
Hide Implementation Details
You should hide implementations details to make your code look something like this:
while gameStart == True:
spawnIn = GetAnswer()
if spawnIn == "coins":
elif spawnIn == "wardrobe":
elif wardrobeSpawn == True:
elif spawnIn == "door":
elif spawnIn == "look":
I haven't really changed anything, but noticed how it's much easier to read and understand? Of course you will have to move some code into the new methods i've named above.
testing boolean values
you can do
you don't need to write
if spawn == true they are both the same thing in fact.
Use Case Statements
Case statements are much easier to read than if / else statements. remember your code will be read many times after it is written. make it easy to understand.
make it readable
make the indentations clear so that it's readable. overall i applaud you for posting it on code review and you should be congratulated for your efforts. perhaps revise your code and repost.
anyways, I hope this code review helps.