Working On first Text based RPG game.

Quick background: I’ve learned from some books such as head first java. I have a few other books which I’ve started, but I want to try my hand at this again. I’ve only made one application that was all my own and it was a list randomize all other programs I’ve made are out of books.

So please remember I’m still very newbie to all this so yeah.

So I want the game to contain locations, a basic item like a potion, and an enemy with very very simple AI. (i.e attack)
So this is all I understand I would greatly appreciate any advice. One of the biggest issues I’m having a hard time figuring out is how to set up and change button based on what can be done. Does it need to be simplified in some way.

List of known classes that are needed
Escape
-Escape();-“Constructor” constructs gui and basic settings
-main();

  • go(); -starts game
    -battle(); - battle loop
    LifeForm
    holds basic common states of every being

Player (extends LifeForm)
-getItem() - gets a specific item out of ArrayList bag

Baddie (extends LifeForm)
event(); - holds special information for when baddie enters a battle.

Location (holds info about current area)
-Room();-holds info on current room

Room
BaddieList<> holds a list of baddies present in the room
ItemsPresent<> hold list of items in the room for the player to search for.
isExit()- tells if this room is an exit from this floor. (currently game end)
getBaddie(i)- gets a baddie from the arraylist at index i
getItem(i) gets an item at index i to give to player

Item
basic states and information about a given item.

Honestly I’m a little overwhelmed feel already :frowning: am I just not ready yet? Any advice would be greatly appreciated thank-you.

i really dont get what are you asking or saying :S

Seems good, best advice would be to start jamming code.
Its always overwhelming when you start at some new programming techniques, but trail and error is really the best way.
Just make sure you got something what works, architecture comes later, when you’re more advanced.

I’m going too I guess I can ask more specific question as I get stuck.

like RobinB said you’re off to a good start, just remember your structure as you code because if you code the core of your program with everything in mind it’ll be really easy to add extremities :slight_smile:

Strip it down to something simpler to begin with. Just have rooms, and exits (or “portals” if you will) that lead from one room to another. Implement simple navigation between rooms.

If LifeForm defines states it should be an enum :point: but I don’t think that’s what you intended. As a superclass for enemies and the player, just include the stuff that’s common to both - moving, attacking, depends on the game.
Also, what you’ve learned in “Head First Java” is not enough to make a good game without further instruction. It’s a good book, but standard java serves only as the base to learn game development. Beginning java books like that don’t teach essentials of gamedev like the game loop, so I suggest you look at some tutorials (fyi, you’re using java2d).

-_- wouldn’t I use enum if I had predefined states that I didn’t want changed? Yeah I’ve noticed that the two beginner books I have no matter how in depth they go haven’t fully prepared me

So I’ve been working on it and I’ve got some simple stuff going however I’m curious if I should move the battle loop out of the main class. This is what it looks like

private void battle(Player bPlayer, Baddie badguy) {
		System.out.println("A " + badguy.getName() + " jumps out at you!");
		boolean playerAlive = true;
		boolean baddieAlive = true;
		
		System.out.println("On your turn type Attack defend or item to take an action");
		fight:
		while(playerAlive == true || baddieAlive == true){
			if((bPlayer.getHealth() <= 0)){
				playerAlive = false;
				break fight;
			}else{
				System.out.println("It's your turn.");
				String action = input.nextLine();
				if(!action.equalsIgnoreCase("attack") && !action.equalsIgnoreCase("defend") && !action.equalsIgnoreCase("item") && !action.equalsIgnoreCase("block") ){
					System.out.println("What? Lets try that again.");
					break fight;
				}
				move(action, bPlayer, badguy);
				
			}
			if(badguy.getHealth() <= 0){
				baddieAlive = false;
				System.out.println(badguy.getName() + " has fallen to your might.\nYou've gain "+ badguy.getXpReward() + " EXP.");
				//if(badguy.hasItem() == true){
					
				//}
				bPlayer.addExp(badguy.getXpReward());
				break fight;
			}
			
			if(bPlayer.getHealth() <= 0){
				playerAlive = false;
                                break fight;
			}else{

				String bAction = badguy.makeMove();

				bMove(bAction, player, badguy);
			}
		}
		
	}

I realize I would only be passing a reference of player to the method to make changes so I’m guess having battle in a separate class would be good, but I wanted to see what others have to say.