Jump to content

  • Log In with Google      Sign In   
  • Create Account


Structure of a game in Java


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Vaishna   Members   -  Reputation: 106

Like
0Likes
Like

Posted 14 June 2012 - 05:16 PM

Hi folks,

Having just finished my first semester of programming with Java at Uni, I decided to try and program a MUD-style text-based RPG to further increase my skills over the summer. My only goal is to (hopefully) learn much more about Java programming and game design, so I'll leave out the internet aspect and develop it as a single-player conceptual game.

I've been doing some brainstorming and have been reading up about game development the past days, and so far I figured out how to create the game world using map objects and exit objects to connect them, and how to split up my entities into sub-classes with inheritence. The part that I'm stuck with is the structure and hierarchy of the program, like where to implement the game logic, for example battles with an enemy. First I thought I would add all the relevant methods of battle to the character class, and to add a variable of character class as a reference to an opponent with whom the character is currently battling. This idea didn't work quite well, and it made my code very messy too. Now I'm thinking I should probably isolate all the battle mechanics in a seperate class, but I'm having problems figuring out how to do this.

Another thing I am unsure about is how to define all my entities such as enemies, items and spells. Do I create an enumeration for all of them, and write down the details for each item seperately? Or should I use databases to store all the information?

Just to be clear, I'm not asking for any code or a step by step walkthrough. It's just that this whole "thinking in Java" thing is new to me, so I'm not sure how to tackle these problems yet, and we haven't had any classes about design patterns or strategies yet either. The topics I've dealt with are: The basics, exceptions, associations, inheritence, interfaces and the Liskov-substitution principle.

Thanks! Posted Image

Sponsor:

#2 Olaf Van Schlacht   Members   -  Reputation: 724

Like
0Likes
Like

Posted 15 June 2012 - 12:20 AM

You should read something about the typical game loop and game state management.

Initialize Components -> Load resources -> Update -> Draw -> Update -> Draw and so on...

I think this will help you to structure your game in a more organized manner and many questions should be answered.

Concerning your Item and Enemy class problem. You can have a simple Enemy class which could be made serializable.
For Example you could create a typical Orc Enemy which can be saved as an XML file to your local drive. You can read the data from it and create new Objects from it.

printf("Hello Signature");


#3 santakine   Members   -  Reputation: 101

Like
0Likes
Like

Posted 15 June 2012 - 03:52 AM

In this tutorial, you learn about building the basic structure of the game and how to build packages.dieu this to me not reading through the many skills!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS