Results 1 to 9 of 9
Like Tree1Likes
  • 1 Post By Norm

Thread: A "Go back" statement

  1. #1
    awesom is offline Member
    Join Date
    Oct 2011
    Posts
    16
    Rep Power
    0

    Default A "Go back" statement

    Hi,

    I'm making a game with serveral rooms. It is a text game.
    But now i got a problem... How do i manage to take them back to the previous room?
    Example: He was in the kitchen--> he goes to the bathroom. Now i want that he goes back to the bathroom if i enter the command "Back".
    Some idea's?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: A "Go back" statement

    How do i manage to take them back to the previous room?
    Very hard to say without seeing your code structure.
    Typically you go back with a loop.
    Or you could use a Stack.
    When you enter a room push the current location onto the Stack.
    When you exit a room, pop off the previous location to be the current location.

  3. #3
    awesom is offline Member
    Join Date
    Oct 2011
    Posts
    16
    Rep Power
    0

    Default Re: A "Go back" statement

    Oke i managed to make a "stack", now i want to run it, Do i need to save it as a .jar file and how can i run it?

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: A "Go back" statement

    You don't need a jar to run/execute your program. Open a command prompt window, change to the folder with the class files and use the java command to start execution of your program.

  5. #5
    awesom is offline Member
    Join Date
    Oct 2011
    Posts
    16
    Rep Power
    0

    Default Re: A "Go back" statement

    But i want a file so i can excute the game

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: A "Go back" statement

    I thought you'd want to test it before packaging it.
    You do not need to put the files in a jar for testing.

  7. #7
    awesom is offline Member
    Join Date
    Oct 2011
    Posts
    16
    Rep Power
    0

    Default Re: A "Go back" statement

    So i can make of my java files a .exe and can i make of .jar a .exe?

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: A "Go back" statement

    I don't know anything about making a .exe file.
    If you don't know how java programs work, you should read this:
    "Hello World!" for Microsoft Windows (The Java™ Tutorials > Getting Started > The "Hello World!" Application)
    Tolls likes this.

  9. #9
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: A "Go back" statement

    So i can make of my java files a .exe and can i make of .jar a .exe?
    It is possible to bundle java apps into an .exe, but that makes them platform dependent, which defeats the entire point of java. You cannot make a 'jar' of an exe, at least not in the way I think you mean. A jar is basically a zip file with some extra meta information that that JVM understands how to open and execute byte code from. While you could include an exe in a jar file, I don't see why you would, and once again, this would be platform dependent.

Similar Threads

  1. An "if" statement inside a "for" loop?
    By soccermiles in forum New To Java
    Replies: 18
    Last Post: 04-20-2010, 03:44 AM
  2. Simple "if" statement problem....compiling error.
    By CYANiDE in forum New To Java
    Replies: 4
    Last Post: 10-14-2009, 09:56 PM
  3. Replies: 3
    Last Post: 05-25-2009, 08:50 PM
  4. Replies: 0
    Last Post: 03-15-2009, 11:53 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

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