yay last min uni work part 2.... I need help

the game loop he is describing is as follows.

variable created called gameover - set to false.

then just run a while loop.

while(!gameover){
run game
ask user if wants to replay
set gameover to true if user wants to quit, otherwise keep false
}

game will loop indefinately if the user keeps selecting to continue and the user will play forever!!
 
robmiller said:
guys i've got a 2000 word essay on gibbon's the fall of rome i need it in for next week

12pt times new roman double spaced

thanks guys you'd better make it good

fact is, the fella is learning here as he goes along. I mean I have given him a replay option fully working, but he wants to do it by himself.

A lot different to your approach :rolleyes:
 
Not sure if this will help you or confuse you but here's some code I wrote many years ago while learning to code (So is pretty terrible) It's for a simple text based rpg), however its in C++ so might be kinda confusing. Shows the idea of a game loop though if you can follow the basics.

http://extraball.sunsite.dk/notepad.php?ID=88589


I would worry about actually getting your game working first before you think about replaying/game over etc though. Once your got a working solution it is easy to refactor.
 
Last edited:
Rossmac said:
I mean I have given him a replay option fully working
So have I lol.


@ jcb33,

you can start the game again by calling the game's method, like game.play(); or whatever. To terminate the program, use System.exit(1);.
 
Now there is just one thing left to do.... place my treasure randomly:

Must place no more than 5 to 7 of the 10 avaliable pieces at any one time

Must keep items in tact

This one is still a mystery to me, im guessing I need to use Math.Random somehow but ... urgh
 
jcb33 said:
Now there is just one thing left to do.... place my treasure randomly:

Must place no more than 5 to 7 of the 10 avaliable pieces at any one time

Must keep items in tact

This one is still a mystery to me, im guessing I need to use Math.Random somehow but ... urgh

That one's gonna be quite hard lol....

Good Luck from OcUK!
 
Rossmac said:
fact is, the fella is learning here as he goes along. I mean I have given him a replay option fully working, but he wants to do it by himself.

A lot different to your approach :rolleyes:

He wants it spoonfed to him though.
 
Chrisss said:
He wants it spoonfed to him though.

;) To Be fair I have been editing my posts and updating to myself along the way, it is nice however to get help, and as for random numbers, yes I can generate them... hence why I got the computer to have random guesses for the user, what I dont know how to do is randomly place 3 cells in order without seperating them

Code:
}
 
Last edited:
Code:
  boolean done = false;
   while(!done)
   {
        if((input.equals("exit") || (input.equalsIgnoreCase("E"))
       {
           System.out.println("Closing App..");
            done = true;
      }
}
 
Rossmac said:
fact is, the fella is learning here as he goes along. I mean I have given him a replay option fully working, but he wants to do it by himself.

A lot different to your approach :rolleyes:

Learning by rote as he's spoon-fed a program—not exactly the right attitude for a programmer!
 
robmiller said:
Learning by rote as he's spoon-fed a program—not exactly the right attitude for a programmer!

True, but maybe programming isn't his desired outcome of his degree, and he just needs to pass this module?
 
Hmm if this is coursework etc, I wouldn't be posting it on the internet, esp considering all(?) uni's have special software that searches the net for any matches with the work you hand in.
 
5ingh said:
Hmm if this is coursework etc, I wouldn't be posting it on the internet, esp considering all(?) uni's have special software that searches the net for any matches with the work you hand in.
Would you actualy get in trouble for having the work you have done posted by you on the net?
 
5ingh said:
Hmm if this is coursework etc, I wouldn't be posting it on the internet, esp considering all(?) uni's have special software that searches the net for any matches with the work you hand in.

I concur.
 
Back
Top Bottom