• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
KittyPlaysViolin

RogueLike Class Selection

3 posts in this topic

Hey everyone! It's been a while again since I've posted. I'm working on a Roguelike right now, and I'm currently in the console stage still. I'm trying to work out all the mechanics before I flush out the graphics.

Currently I plan on having several classes available to the player that have unique skill trees and stats. I have a class Entity that is the top level class for anything that can battle in the game. Monster extends Entity and Player extends Entity. Then I have each of the individual classes of Monster extend Monster and the same for the Player. However this is where I seem to have run into a snag.

When I start the game I create a Dungeon object with a random number of Floors. Dungeon then spawns those number of Floor objects, each with a random number of Rooms. Then each Floor spawns those number of Room objects, and finally each Room takes care of how many items,"interactors", and Monsters it has.

After Dungeon has spawned the entirety of it's components it generates a random story based on a static array of Strings that I pull from a "random" utility class I made. Then the game proceeds into the TUTORIAL state before going into the actual game loop. At this point the program asks the Player his/her name and profession. This is the part that confuses me. My program is currently responding to requests to the Player as such:

Pick your Job:
1:ARCHER
2:WARRIOR
3:MAGE
4:ASSASSIN

etc.

However a number of things escape me. I only have a few classes as of now, but I plan to expand on them, so how should I prompt the character with the classes? As of now I simply use a forLoop to run through an array of String names of the classes. But then after that how do I read in a number input to spawn the right class for the character?

Also, in anticipation of the graphics I had a few questions as well. I don't plan on making the game real time. The window will display one Room at a time and a mini-map of the rooms at the top left corner. The player will make every command from a selection of buttons at the bottom section of the screen.

This is where I get confused.

Take the following hypothetical situation:

Player is a Warrior, and enters a battle with a monster. The bottom panel displays
[ATTACK] [MAGIC] [ITEMS]
[DEFEND] [SKILLS] [RUN]

The player decides to attack so he clicks the attack button. The panel's "state" switches over to the attack state and displays a new set of buttons. However, each class will have a different set and number of buttons. How would I allocate them in the screen per each class? I haven't gotten to this stage yet but I would still like some feedback on it.

I'm still cleaning up the code a bit, it's quite ugly so I'm not going to post it immediately. If anyone requests it though I will gladly post it.
Thank you so much for your help, I hope my questions and descriptions were clear enough.
0

Share this post


Link to post
Share on other sites
I'm still not the best when it comes to Java, but here is my response as I would go about it:
If you wish to read something into the Java console (AKA: System), your best bet is to use Scanner (java.util.Scanner), which is a means of getting information from something containing Strings. An example of this could be as follows:
[source lang="java"]import java.util.Scanner; //remember to import Scanner
public class Foo{
//Using a global array of Strings so it can be reused.
//Need to change/add a job? Just edit the array
private String[] jobs = new String[]{"ARCHER",
"WARRIOR","MAGE","ASSASSIN"};

public static void main(String[] args){
System.out.println("Pick your Job:\n");
for (int i=1; i<=jobs.length; i++) //goes through each jobs and labels it
System.out.println(i+jobs[i-1]);
Scanner s = new Scanner(System.in); //Creates scanner for System.in (the console)
String answer = s.nextLine(); //user inputs String here.
for(String j: jobs) //for each loop. checks every name for matches
if (answer.equalsIgnoreCase(j))
//put your Player creation code here or something.
}
}[/source]
As for your Panel during turn-based combat, I would make it store an Entity. Then, every Entity in your game could have its own moveset. Just give your Entity class a public method that would allow it to share it with your Panel, and viola!
Hopefully I was clear enough with that response. Doing code out for all that just to explain it to you would be an overhaul. :)
1

Share this post


Link to post
Share on other sites
Thanks for the reply! I'm a little bit unsure about that for loop though. The way it's set up it would show you one job then ask you for input, then another, and ask you for input and so on. Unless I'm reading it wrong. I assume since you weren't using braces on your for loop that you only meant to loop the displaying code right? If so, that's what I have so far. Ah I see, and then in the second for loop your looping through the array to see if my string matches one of the available classes. That's what I thought as well. However, I would have to then specifically instantiate that class.

If I picked Archer I would have to go:

Player player = new Archer("Adrian");

or for whichever respective class. So how would I do that in the context of that loop? Would I have to make yet another switch statement that says
(pseudocode)
switch(job)
case Archer:
new Archer();
break;
case Warrior:
new Warrior();
break;

and so on?

As for the graphics yes that does make a lot of sense. However say the Warrior class has these skills inside his [SKILL] button (click [SKILL] and it jumps to a new state with new buttons)

[HILT SMASH] [SHIELD BASH] [VITAL STRIKE]

and then the Warrior levels up, allowing him to choose between [BLOOD FRENZY] and [TENDON SLICE] as his skills. His panel would then have a new button added to it. So how would I take care of adding new buttons as they pop up dynamically?

Again thank you so much for your help! I'm going to have a quick snack break and chill out to let my brain relax a bit before going back to coding.
0

Share this post


Link to post
Share on other sites
A point to clarify, as it may shorten your code, when writing for loops, while loops, or if statements, it is acceptable in Java to not use the curly braces, so long as the content of your loop is only one command or block statement (another if statement or loop). As long as you keep your indentation okay, it should still be understandable by most.

A switch statement would work for that if you wanted to, but you would have to update your code with every new job added. Another thing you would have to do is make your User Input match the strings you compare it to. Due to the ASCII values that chars are assigned, "Archer" != "archer" (which is why I used String.equalsIgnoreCase()). However, you can easily just capitalize/lowercase all of the User Input via String.toUpperCase() or String.toLowerCase().

Another way to work around this, which would require less updating on your part, would be to use the Java Reflection API. If you're not familiar with reflection, it's the practice of referring to your own code on a more abstract level, so that you can create indefinite objects. It can be confusing though, and more difficult to debug if you have to, because all of the reflection processes occur at runtime.

I'm going to avoid going to much into it for the sake of sanity, but it's really useful if you want to try.
INFO/API: [url="http://docs.oracle.com/javase/tutorial/reflect/index.html"]http://docs.oracle.c...lect/index.html[/url]
Things to find to make things a bit easier:[list]
[*]Class.forName(String name) or Class literals. These give you a Class Object (your starting point)
[*]Constructor.newInstance(Object... args) creates a new object from the Class. args is a list of any arguments, but you'll probably just need a String.
[/list]
As for the moves, you could do what some party-based games do, and limit the number of skills available. That way, you can simply make the buttons take up a fraction of the available space and leave unused ones blank until they are filled in (think of the battle interface from the earlier Pokemon games). Edited by epicpunnum
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0