Results 1 to 11 of 11
  1. #1
    shookey16 is offline Member
    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    Default JAva 1 Simple Dungeon game need help or will fail...

    I am in Java 1 and with all the work I have I am begging for help writing a program
    The player must take 10 steps to escape the dungeon. On each step, the player might encounter a monster. One third of the time, the player will encounter a gnome. One third of the time, the player will encounter a dragon. One third of the time, there will be no monster.
    If there is a monster, the player can choose to fight or run away. If the player fights and wins, the player gets the monster's gold.
    The player starts with 10 hit points. Each time the player is hit by a monster, the player loses hit points. If the player's hit points reach 0 before escaping the dungeon, the game is over and the player loses.
    The player does 1 to 8 hit points of damage with each hit
    Each gnome encountered starts with 3 hit points, has 1 to 5 gold gold, and does 1 to 2 hit points of damage each time it attacks..
    Each dragon starts with 10 hit points, has 10 to 20 gold, and does 1 to 5 points of damage.

    Each encounter with a monster consists of a series of turns. For each turn, the player can fight, or run away. If the player chooses to fight, damage is calculated for the monster. The monster retaliates and damage is calculated for the player. Then, the next turn starts and the player may choose to fight or run away again. If the player chooses to run away, they move one step closer to the dungeon exit without getting hurt, but without getting any gold.

    When the player escapes, the program displays the total gold collected.

    It's a pain in the butt and I know I'm only in Java 1 but I can't program for crap.

    Any help at all will be much much appreciated

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: JAva 1 Simple Dungeon game need help or will fail...

    What questions do you have? What specifically do you need help with?

  3. #3
    shookey16 is offline Member
    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    Default Re: JAva 1 Simple Dungeon game need help or will fail...

    I don't even know how to start it, I made a bunch of variables for steps, health point, gold damage, etc. but I dont know what to start with the code

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: JAva 1 Simple Dungeon game need help or will fail...

    Have a look at the Java tutorials for info on Java specifics: The Really Big Index

    Then break down your big project into little steps and try to solve each one, one at a time. If you get stuck at a step, come on back with your specific question and your code, and let's see how we can help you.

  5. #5
    Darkzombies is offline Senior Member
    Join Date
    Nov 2012
    Posts
    105
    Rep Power
    0

    Default Re: JAva 1 Simple Dungeon game need help or will fail...

    Quote Originally Posted by shookey16 View Post
    I know I'm only in Java 1 but I can't program for crap.
    I imagine if you paid more attention you could.

    I suggest you make a class for player, monster, and gamemap to start off. You probably get the point, make methods that have to do with the map in the GameMap class, the ones that have to do with the player in the Player class, and the ones that have to do with the monster in the Monster class.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default Re: JAva 1 Simple Dungeon game need help or will fail...

    Not sure a map class is actually needed.
    Seems to me to be a simple loop 1-10 (well, 0-9).
    Each loop consists of a check whether there is a monster.
    If there is then fight.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    shookey16 is offline Member
    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    Default Re: JAva 1 Simple Dungeon game need help or will fail...

    Hopefully you guys can still help
    Again the directions are at the top

    Java Code:
    import java.util.Scanner;
    import java.util.Random;
    public class Dungeon
    {
    	public static void main (String[] args)
    	{
    		Scanner keyboard = new Scanner (System.in);
    		Random rand = new Random();
    		Random rando = new Random();
    
    		int rand.nextInt(3);
    		int rando.nextInt(8);
    
    		int steps = 0;
    		int count = 0;
    		int move = 0;
    
    
    		int fightchoice = 0;
    		int PHP = 10;
    		int GHP = 3;
    		int DHP = 10;
    		int Gold = 0;
    		int PDamage = rando;
    		int DDamage = 0;
    		int GDamage = 0;
    		int GReward = 0;
    		int DReward = 0;
    
    
    		System.out.println("You've entered a dungeon, you must take 10 steps to escape the dungeon. Good luck.");
    
    
    		while(steps != 10)
    		{
    
    			System.out.println("Would you like to move on?");
    				move = keyboard.nextInt();
    
    			if(move == 1)
    			{
    				System.out.println("You've encountered a dragon, Press 1 to fight or 2 to run");
    					fightchoice = keyboard.nextInt();
    
    					if (fightchoice == 1)
    			{
    
    			if (move ==	2)
    			{
    				System.out.println("");
    
    				steps++;
    		}
    
    
    			// game stuff printlines and so forth
    			// after each event, increment steps
    		}
    
    
    	}
    }
    Keep in mind that im in low level and it doesnt get more complex than this

    My questions are how do i make a bunch of random numbers for PDamage, DDamage, GDamage, the rewards and everything else then how do i impliment them in the code? im too lost..
    Last edited by Tolls; 12-07-2012 at 10:43 AM. Reason: Added code tags

  8. #8
    shookey16 is offline Member
    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    Default Jva 1 Simple Dungeon game need help or will fail...

    It's a basic course and Im not picking it up

    The player must take 10 steps to escape the dungeon. On each step, the player might encounter a monster. One third of the time, the player will encounter a gnome. One third of the time, the player will encounter a dragon. One third of the time, there will be no monster.
    If there is a monster, the player can choose to fight or run away. If the player fights and wins, the player gets the monster's gold.
    The player starts with 10 hit points. Each time the player is hit by a monster, the player loses hit points. If the player's hit points reach 0 before escaping the dungeon, the game is over and the player loses.
    The player does 1 to 8 hit points of damage with each hit
    Each gnome encountered starts with 3 hit points, has 1 to 5 gold gold, and does 1 to 2 hit points of damage each time it attacks..
    Each dragon starts with 10 hit points, has 10 to 20 gold, and does 1 to 5 points of damage.

    Each encounter with a monster consists of a series of turns. For each turn, the player can fight, or run away. If the player chooses to fight, damage is calculated for the monster. The monster retaliates and damage is calculated for the player. Then, the next turn starts and the player may choose to fight or run away again. If the player chooses to run away, they move one step closer to the dungeon exit without getting hurt, but without getting any gold.

    When the player escapes, the program displays the total gold collected.



    It's a pain in the butt and I know I'm only in Java 1 but I can't program for crap.

    Any help at all will be much much appreciated

  9. #9
    shookey16 is offline Member
    Join Date
    Dec 2012
    Posts
    5
    Rep Power
    0

    Default Re: Jva 1 Simple Dungeon game need help or will fail...

    import java.util.Scanner;
    import java.util.Random;
    public class Dungeon
    {
    public static void main (String[] args)
    {
    Scanner keyboard = new Scanner (System.in);
    Random rand = new Random();
    Random rando = new Random();

    int rand.nextInt(3);
    int rando.nextInt(8);

    int steps = 0;
    int count = 0;
    int move = 0;


    int fightchoice = 0;
    int PHP = 10;
    int GHP = 3;
    int DHP = 10;
    int Gold = 0;
    int PDamage = rando;
    int DDamage = 0;
    int GDamage = 0;
    int GReward = 0;
    int DReward = 0;


    System.out.println("You've entered a dungeon, you must take 10 steps to escape the dungeon. Good luck.");


    while(steps != 10)
    {

    System.out.println("Would you like to move on?");
    move = keyboard.nextInt();

    if(move == 1)
    {
    System.out.println("You've encountered a dragon, Press 1 to fight or 2 to run");
    fightchoice = keyboard.nextInt();

    if (fightchoice == 1)
    {

    if (move == 2)
    {
    System.out.println("");

    steps++;
    }


    // game stuff printlines and so forth
    // after each event, increment steps
    }


    }
    }

    Keep in mind that im in low level and it doesnt get more complex than this

    My questions are how do i make a bunch of random numbers for PDamage, DDamage, GDamage, the rewards and everything else then how do i impliment them in the code? im too lost..

  10. #10
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: JAva 1 Simple Dungeon game need help or will fail...

    shookey16, please go through the Forum Rules -- particularly the second paragraph.

    I've merged the second thread you started here. Don't double post the same question again.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default Re: JAva 1 Simple Dungeon game need help or will fail...

    Quote Originally Posted by shookey16 View Post
    Keep in mind that im in low level and it doesnt get more complex than this

    My questions are how do i make a bunch of random numbers for PDamage, DDamage, GDamage, the rewards and everything else then how do i impliment them in the code? im too lost..
    I added code tags to the first one above, so it's easier to read.

    A couple of comments, basedd on the requirements.
    You want to increment 'steps' each time round the loop.
    At the moment you only do it if the player does not encounter a monster.

    For the fighting, you only need the one Random object, for starters, and you only need to call nextInt() on it when you need a random number, so these two lines can go:
    Java Code:
    int rand.nextInt(3);
    int rando.nextInt(8);
    There's nothing in the requirements about asking if they want to move on.
    So get rid of the "Do you want to move on" bit.
    At that point you want to get a random number, 1-3, where 1 is a gnome, 2 is a dragon, 3 is move on.

    Get to that point and get it working.
    You can worry about fighting later.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Simple Mastermind Java Game, Please help
    By williamsb14 in forum New To Java
    Replies: 3
    Last Post: 11-24-2012, 09:52 PM
  2. Simple Java Game -- HELP :)
    By Gamersunited22 in forum New To Java
    Replies: 7
    Last Post: 04-04-2012, 07:41 PM
  3. want to make a simple game in java
    By Tarasj in forum New To Java
    Replies: 1
    Last Post: 03-26-2012, 10:54 PM
  4. need a simple java game
    By Shashwat in forum New To Java
    Replies: 1
    Last Post: 01-03-2011, 03:42 PM
  5. Java Dungeon Adventurer Wanted
    By Dungeon Adventurer in forum Jobs Offered
    Replies: 2
    Last Post: 05-11-2008, 09:20 PM

Tags for this Thread

Posting Permissions

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