Results 1 to 19 of 19

Thread: Can some one help me

  1. #1

    Default Can some one help me

    First i know this is in the wrong place and I am sorry but im stumped

    I took a class in intro to game programing and we have started to program our first text base adventure game using Python 2.6 . For some weird reason i cant get this dame program to recognize my choices as actions .

    for example
    def gamestart():
    start_text = """
    Your a hamster about to start on a great adventure.
    You are tired with you life in the cage and want to explore so you plan to escape
    and start on your great adventure

    """
    print start_text
    global choice
    select = raw_input("Choose 'w' to wait for nightfall or 'e' to escape in bawd daylight or 'r' to run on your hamster wheel and discover the hamster power !!! : ")
    if select == "e":
    choice = "escape"
    elif select == "w":
    choice = "wait"
    elif select == "r":
    choice = "run"
    else:
    print "thats not a good choice lets look at other options"
    gamestart()
    """
    Escape: Your owner sees you pull this stunt seals the hole back in the cage you go.
    """
    def escape(escape):
    escape = """
    escape:you attempt to sneak out of a fresh gnawed hole in an attempt to escape the confines of your cage
    whoops your owner sees you back in the cage you go.

    """

    if escape == "escape":
    print escape1
    global lifenumber
    lifenumber -= 1
    print "You only have %d lives left!" % lifenumber
    gamestart()


    Any of my choices causes it to go to this
    you chose blah
    you chose blah
    you chose blah
    you chose blah
    you chose blah
    you chose blah
    you chose blah
    you chose blah
    you chose blah
    you chose blah
    you chose blah

    There is something i am missing i get that i just don't know what and my teacher said in class He don't work on weekends we will not respond to e-mail or phone calls

    so im hitting the forms in hopes some one will help/ teach me what the beep im doing wrong this issue is driving me insane!!!!


    Ill admit, The first issue I had took me , the teacher and 2 different debuggers and still nothing. Late at night I pulled up an example text and realized the error fixed it and now i got this and the format is identical to a working program so its got to be a space or something i am missing Please help

    Devs ?
    any one ?
    Face forward and you should be able to hear it now the only thing plugging your ears is your own fear. There is only one enemy and one of you so what is there to be afraid of ? Abandon your fear turn and face him, Don't give an inch. Now advance Never stop If you retreat you will age Be afraid and you'll die NOW SHOUT OUT YOUR NAME !!!

  2. #2

    Default Re: Can some one help me

    Probably the wrong sub-forum for this to be in (Edit: Now in the right one. x3), but to try answering the question..

    I havn't programmed in Python at all but my programmer's instincts are still telling me there are a few things missing / wrong with the code you posted.

    I don't see the variable 'choice' being compared with anything, it's simply being set to "escape", "wait", or "run" but doesn't appear to be used for anything after that.

    Also, these lines don't make much sense to me:
    if escape == "escape":
    print escape1

    For one the variable 'escape1' doesn't seem to be declared anywhere, and I'm not seeing anywhere that the variable 'escape' will ever become equal to "escape" .. Do you mean: if choice == "escape" perhaps?

    These are the things that immediately pop out at me even though I'm currently only making educated guesses at the syntax. Hopefully someone who actually has Python experience lurks the forums. x3
    Last edited by Akrion; September 23rd, 2011 at 10:15 PM.
    Avatar is of my character Akrion, snipped from Hrae's Hoard of Creatures by the excellent moss loving artist Nambroth. <3

  3. #3

    Default Re: Can some one help me

    I'll back up Akrion... And add that I don't see the line "you chose " anywhere in the code you posted which makes me think perhaps the whole code isn't there for us to see.
    "Alea iacta est" -- Julius Caesar

    Toot shouted, voice shrill, "In the name of the Pizza Lord! Charge!" (Jim Butcher's Dresden Files)

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will spends it whole life believing that it is stupid." -- Albert Einstein

  4. #4

    Default Re: Can some one help me

    Ill post the hole thing


    """ Hamsters run free.py
    A text based style adventure game
    Your a cute furry hamster way to smart for his own good your trying to escape from your cage and get across the street in to a garden
    where you can live your happy life munching on fresh home grown veggies.
    Do not get cough by your owner or the farmer additional resources are available for you in game .
    """


    """
    Start game: Describe Rules, Escape from cage, Present first choices,
    find an open box of food or find a way down from the cage
    """
    def gamestart():
    start_text = """
    Your a hamster about to start on a great adventure.
    You are tired with you life in the cage and want to explore so you plan to escape
    and start on your great adventure

    """
    print start_text
    global choice
    select = raw_input("Choose 'w' to wait for nightfall or 'e' to escape in bawd daylight or 'r' to run on your hamster wheel and discover the hamster power !!! : ")
    if select == "e":
    choice = "escape"
    elif select == "w":
    choice = "wait"
    elif select == "r":
    choice = "run"
    else:
    print "thats not a good choice lets look at other options"
    gamestart()
    """
    escape: Your owner sees you pull this stunt seals the hole back in the cage you go.
    """
    def escape(escape):
    escape = """
    escape:
    you attempt to sneak out of a fresh gnawed hole in an attempt to escape the confines of your cage
    whoops your owner sees you back in the cage you go.

    """

    if escape == "escape":
    print escape1
    global lifenumber
    lifenumber -= 1
    print "You only have %d lives left!" % lifenumber
    gamestart()


    """ Its nightfall
    time for hamsters to become active and make there escape you begin gnawing at the cage and sneak out of your fresh hole.
    """
    def wait():
    wait_text = """wait:
    you sneak out of your cage and look around on the dresser you see a strange tall box
    and you also see a tricky way down .
    """
    print wait_text
    global choice
    select = raw_input(" 'e' to explore your surroundings , or 'd' for down and go to the hallway: ")
    if select == "e":
    choice = "explore"
    elif select == "d":
    choice = "to go down"
    else:
    print "Thats not a smart option lets consitter something else "
    explore()



    def explore():
    explore_text = """
    explore:You sneak around the dresser and cautiously approach the strange tall box
    that smells good you think to yourself it might be food
    you knock over the box with a big clang good thing your owners a heavy sleeper
    you begin to gather the pellets of food and store them in your pouches

    """
    print explore_text
    global choice
    select = raw_input(" 'd' to leave the dresser , or 's ' to fall asleep ")
    if select == "d":
    choice = "down"
    elif select == "s":
    choice = "sleep"
    else:
    print "That is not a valid choice"
    ()

    """
    go down : you land on the floor
    choices: leave room or hide under the bed
    """

    """
    go down :land on the floor
    choices: hide under the bed or escape into the hallway
    """


    """
    Main Game Loop
    """
    keepgoing = True
    totallives = 3
    lifenumber = 3
    choice = "start"
    sockcount = 0

    while keepgoing:
    print "You chose:", choice
    if lifenumber > 0 :
    if choice == "start":
    gamestart()
    elif choice == "sock1":
    getsock("sock1")
    elif choice == "godoor":
    1()
    elif choice == """tograge""":
    togarage()
    else:
    print "Sorry you only get 3 chances to gain your freedom ."
    keepgoing = False




    Edit thanks a lot guys for posting ill look back at it at least i now have a ballpark area of where the issue is
    Last edited by lightning claw; September 23rd, 2011 at 10:25 PM.
    Face forward and you should be able to hear it now the only thing plugging your ears is your own fear. There is only one enemy and one of you so what is there to be afraid of ? Abandon your fear turn and face him, Don't give an inch. Now advance Never stop If you retreat you will age Be afraid and you'll die NOW SHOUT OUT YOUR NAME !!!

  5. #5

    Default Re: Can some one help me

    Yeah, I can see 'choice' being used for some comparisons in the Main Game Loop, but still no comparisons for choices such as "escape", "wait", "run", "explore", "to go down", "down", or "sleep" .. Also is """tograge""" meant to have so many quotation marks? Finally I'm still not seeing 'escape1' declared anywhere.
    Avatar is of my character Akrion, snipped from Hrae's Hoard of Creatures by the excellent moss loving artist Nambroth. <3

  6. #6

    Default Re: Can some one help me

    Ok fixed the cutesy choice but now its saying the main choices are not defined

    got a feeling i am going to either get this soon or im going to go bald

    Wait is not defined

    escape is not defined when they are might just need to retype throws i think
    Face forward and you should be able to hear it now the only thing plugging your ears is your own fear. There is only one enemy and one of you so what is there to be afraid of ? Abandon your fear turn and face him, Don't give an inch. Now advance Never stop If you retreat you will age Be afraid and you'll die NOW SHOUT OUT YOUR NAME !!!

  7. #7

    Default Re: Can some one help me

    Indenting affects program execution flow in Python. The formatting features of this forum will squash indenting, which will make the above code difficult to understand and probably introduce ambiguities.

    I suggest posting and editing your code using a more appropriate tool, like pastebin. Discussion is fine here, but put the code somewhere where it won't get mangled.
    You can get anything you want in life -- just make a lot of noise and bite the right people.

  8. #8

    Default Re: Can some one help me

    Code:
    double v3d::Vector::Dot(v3d::Vector v)
    {
        return (
            this->m_x * v.GetX() +
            this->m_y * v.GetY() +
            this->m_z * v.GetZ()
            );
    }
    Maybe code tags will work? The above was copy/pasted directly from visual studios and seem to match the formatting exactly. Push the # button when posting a message.
    Avatar is of my character Akrion, snipped from Hrae's Hoard of Creatures by the excellent moss loving artist Nambroth. <3

  9. #9

    Default Re: Can some one help me

    That works too, though editing becomes troublesome. Speaking from experience, you'll hurt a lot less using a pastebin instead of a forum if you need to do collaborative editing.
    You can get anything you want in life -- just make a lot of noise and bite the right people.

  10. #10

    Default Re: Can some one help me

    Quote Originally Posted by Steelclaw View Post
    That works too, though editing becomes troublesome. Speaking from experience, you'll hurt a lot less using a pastebin instead of a forum if you need to do collaborative editing.
    Editing is a good point actually, considering the 30 minute edit limitation. You can also do collaborative editing? I didn't know that (Havn't heard of pastebin until now), yeah, that would probably be better then.
    Avatar is of my character Akrion, snipped from Hrae's Hoard of Creatures by the excellent moss loving artist Nambroth. <3

  11. #11

    Default Thank you all !!!

    I just wanted to take the time to thank everyone for the friendly advice they gave me. It was much appreciated and I think I finally understand the scripting language of python. Because I have developed that critical eye you need for any scripting language, I am catching my own errors and able to resolve most them , and even if I don’t catch them in the code when I run the game and it gives me an error message I am now able to figure it out thanks to your guys es help My adventure game is nearly completed and if you guys want to run it after its graded Ill post it on the link If not again thank you very much !!!

    Special thanks to AmonGwareth and Akrion for Immediately jumping in and taking the time to read the numerous errors in the original code
    Face forward and you should be able to hear it now the only thing plugging your ears is your own fear. There is only one enemy and one of you so what is there to be afraid of ? Abandon your fear turn and face him, Don't give an inch. Now advance Never stop If you retreat you will age Be afraid and you'll die NOW SHOUT OUT YOUR NAME !!!

  12. #12

    Default Re: Can some one help me

    You're welcome. The ability to find a problem then come up with solutions to said problem is more useful than just understanding the syntax of a language (Amon probably has to use such a skill just about every hour of every day he works on Istaria xD). I definitely recommend working on honing that ability.
    Avatar is of my character Akrion, snipped from Hrae's Hoard of Creatures by the excellent moss loving artist Nambroth. <3

  13. #13

    Default Re: Can some one help me

    Quote Originally Posted by Akrion View Post
    You're welcome. The ability to find a problem then come up with solutions to said problem is more useful than just understanding the syntax of a language (Amon probably has to use such a skill just about every hour of every day he works on Istaria xD). I definitely recommend working on honing that ability.
    And on my regular full-time job as well.

    Python is a powerful language, but it definitely has its quirks. Course, I guess they all do.
    "Alea iacta est" -- Julius Caesar

    Toot shouted, voice shrill, "In the name of the Pizza Lord! Charge!" (Jim Butcher's Dresden Files)

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will spends it whole life believing that it is stupid." -- Albert Einstein

  14. #14

    Default Re: Can some one help me

    Quote Originally Posted by AmonGwareth View Post
    And on my regular full-time job as well.
    You mean that you've got a life beyond Istaria? :O .. Kidding ofcourse. x3 What do you do for that job, if you don't mind my asking?
    Avatar is of my character Akrion, snipped from Hrae's Hoard of Creatures by the excellent moss loving artist Nambroth. <3

  15. #15

    Default Re: Can some one help me

    Quote Originally Posted by Akrion View Post
    You mean that you've got a life beyond Istaria? :O .. Kidding ofcourse. x3 What do you do for that job, if you don't mind my asking?
    Game development
    "Alea iacta est" -- Julius Caesar

    Toot shouted, voice shrill, "In the name of the Pizza Lord! Charge!" (Jim Butcher's Dresden Files)

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will spends it whole life believing that it is stupid." -- Albert Einstein

  16. #16

    Default Re: Can some one help me

    I remember basic python in class... but I think the quirkier language of any I learned in school was LUA. LUA is eeeeeeevil for quirks.

    ... Of course because I never used it, I lost it all. Oh well.


  17. #17

    Default Re: Can some one help me

    Quote Originally Posted by RuneDragoon View Post
    I remember basic python in class... but I think the quirkier language of any I learned in school was LUA. LUA is eeeeeeevil for quirks.

    ... Of course because I never used it, I lost it all. Oh well.
    I like Lua quite a bit. More than python in fact. Though Python was good for having lots of things already written so you didn't have to do it yourself. Lua is super-easy to extend into your c++ or c# apps and there's even a way with Lua to expose all of your classes and functions directly to Lua from .NET.
    "Alea iacta est" -- Julius Caesar

    Toot shouted, voice shrill, "In the name of the Pizza Lord! Charge!" (Jim Butcher's Dresden Files)

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will spends it whole life believing that it is stupid." -- Albert Einstein

  18. #18

    Default Re: Can some one help me

    My only experiences so far are primarly with C++, I've been self-learning it for just under a year now and I have to say I rather enjoy its complexity. Part of the reason for why I chose C++ to be my first true programming language was because I felt that all the possible pitfalls such as pointers, pointer arithmetic, memory management, etc. that could/would be taken for granted in other languages would sort of force me to really understand some of the core concepts of working with a computer lest I continue to be at risk of making huge errors in my code all the time.
    Avatar is of my character Akrion, snipped from Hrae's Hoard of Creatures by the excellent moss loving artist Nambroth. <3

  19. #19

    Default Re: Can some one help me

    Ok Program Complete

    Its soo cool doing something like this so with out further adu im going to do something i rarely do and that to link something

    Kinda how i felt when i final finished it

    http://www.youtube.com/watch?v=Y6ljFaKRTrI (AKA Portal Still alive )


    Yes some times i wanted to brake python heart and kill it


    Ps Ill post the py file when i i clean up the text a bit some times in the code the line gose on and chops a word in half ect but thats easy fixed


    /n" Is your friend
    Face forward and you should be able to hear it now the only thing plugging your ears is your own fear. There is only one enemy and one of you so what is there to be afraid of ? Abandon your fear turn and face him, Don't give an inch. Now advance Never stop If you retreat you will age Be afraid and you'll die NOW SHOUT OUT YOUR NAME !!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •