Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (616)
Games in Android Showcase (173)
games submitted by our members
Games in WIP (659)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Game Play & Game Design / Effect Architecture on: 2013-08-23 15:11:39
I've been working on a roguelike game for a few months now and I've gotten to the hardest part yet, effects! I'm talking about everything from an effect that represents fire by continuously damaging an object to an effect that summons a creature, to an effect that modifies the stats of an object. So obviously there are a lot of potential effects. The question is how to go about implementing effects in an object oriented manner.

My current approach is to have an Effect class that is really broad. It contains multiple hashmaps that can contain game objects, simple values, locations, and other effects. Most instances of the class won't utilize all of these hashmaps. Each effect also has a list of types. These define how the game interprets the effect.

Examples Types: damage, healing, armorModifier, summon, etc.

For example, when an agent suffers damage the game will look for effects on that agent of the type "armorModifier". If an effect with that type exists on the agent, the game knows there should be a key/value pair in one of the hashmaps that tells how much armor should be added/subtracted. This would be for a passive effect, however many effects are active. Such effects have an activate() method that is called. The Effect class then acts based on the types of the effect. So if its a damage effect it will look for a key/value pair for how much damage, what targets to damage, what damage type it is and so on.

So if it wasn't complex enough for you already, there are also effects that really only modify other effects. For example, the activateOverTime type of effect just activates another effect at a certain frequency. The onHit type of effect applies a new effect to whatever an Agent attacks.

Here are some examples of effects and what types they would have:

  • Fireball: damage, aoeBurst
  • Vampirism: damage, healing
  • Alien Parasite: damage, activateOverTime, onTargetDeath (would create the Summon Parasite effect)
  • Summon Parasite: summon

So, I'd like your input on how to best implement this system. My current method can work, but its getting more and more complicated. I've considered creating a child class for each "type" of effect, though that would be a lot of child classes.

Thanks for any help,
2  Game Development / Newbie & Debugging Questions / Re: Static Reference to Self on: 2013-08-19 20:53:03
Thanks for all the quick responses. I'll look into the singleton pattern.

Out of curiosity do you use the singleton pattern for your primary class for your games?

3  Game Development / Newbie & Debugging Questions / Static Reference to Self on: 2013-08-19 20:32:59
public class A {

   public static A current;

   public A() {
      current = this;

I'm considering doing something like the above and was wondering if this kind of thing is frowned upon and why. The reason i'm doing it is because I know there will only ever be one instance of the class A for each instance of my program and almost all classes need to be able to interact with the instance of class A. So I figured this would be a simpler approach than creating all the other classes with a pointer to the only instance of class A.

Thanks for any help,
4  Game Development / Newbie & Debugging Questions / Re: Uninitialized Objects on: 2013-07-29 21:21:14

Thats what the Effect class is, a class to hold each Effect's data. Game objects do have an arraylist of Effect objects. If your saying I should have a class that holds a single double, a single game object, and a single location, the issue with that is not all effects have all three of those things and not necessarily in equal amounts. One effect might have 2 doubles, 3 game objects, and a single location.

5  Game Development / Newbie & Debugging Questions / Re: Uninitialized Objects on: 2013-07-29 19:33:23
First off, thanks for all the good advice.

To go into more detail about the situation. The class in question is the Effect class, which will encompass every imaginable type of effect in my game which could range from various status effects (poison, fire) to enhancements or any sort of magical effect you could think of. Every game object can have one or more Effects on it at any time, though I doubt the number of Effect objects will ever exceed 1000. The three arraylists are potential information that an Effect could need (doubles, GameObjects, and Locations).

If keeping all the arraylists initialized wouldn't be significant I'll probably do so.
6  Game Development / Newbie & Debugging Questions / Re: Uninitialized Objects on: 2013-07-29 15:17:46
Thanks for the timely response!

I actually want the arraylists to be uninitialized because many instances of the object won't be using all of them. So whenever I create a new instance of this object none of the arraylists will be initialized. If an instance will need one or more I will individually initialize those arraylists.
7  Game Development / Newbie & Debugging Questions / Uninitialized Objects on: 2013-07-29 14:53:18
I've got an object with three arraylists:

public class Foo {

   protected String name;
   protected ArrayList<ObjectA> a;
   protected ArrayList<ObjectB> b;
   protected ArrayList<ObjectC> c;

   public Foo(String _name) {
      name = _name;

Lets say I create a couple instances of this object and for each instance I may initialize and use one or more of the arraylists. Is this inefficient? Will those uninitialized arraylists cause any issues (beyond if I try to use them before initializing them)?

Thanks for any help!
8  Game Development / Newbie & Debugging Questions / Re: Recommended Libraries for 2d ASCII games on: 2012-09-05 14:23:47
Unfortunately there are few java libraries there. Libjcsi and Blacken are the two mains ones I could find and neither has a comprehensive tutorial on their usage. There is a quick tutorial on how to use JNI to implement the curses library for direct console access. This, however, lacks some features I would definitely like (Background color being one of them).
9  Game Development / Newbie & Debugging Questions / Recommended Libraries for 2d ASCII games on: 2012-09-04 17:26:54
I've been working on a roguelike game and I was planning on using the libjcsi library but have run into some issues with it. I was thinking of swapping over to a more general java graphics library and was wondering what you guys would recommend. Note that I won't be doing anything too fancy. The game will likely consist of a grid of tiles and some menus.

Thanks for any help!
Pages: [1]
Coldstream24 (18 views)
2015-09-03 00:41:28

Andrew_3ds (29 views)
2015-09-01 19:08:10

afikri (20 views)
2015-08-31 09:30:22

afikri (27 views)
2015-08-31 09:30:07

afikri (15 views)
2015-08-31 09:27:24

afikri (17 views)
2015-08-31 09:26:40

Roquen (32 views)
2015-08-29 11:30:54

GamerC4 (38 views)
2015-08-22 20:38:50

GamerC4 (36 views)
2015-08-22 20:37:18

GamerC4 (42 views)
2015-08-22 20:37:01
HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!