Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (577)
games submitted by our members
Games in WIP (498)
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 17: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,
Nathan
2  Game Development / Newbie & Debugging Questions / Re: Static Reference to Self on: 2013-08-19 22: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?




Thanks,
Nathan
3  Game Development / Newbie & Debugging Questions / Static Reference to Self on: 2013-08-19 22:32:59
1  
2  
3  
4  
5  
6  
7  
8  
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,
Nathan
4  Game Development / Newbie & Debugging Questions / Re: Uninitialized Objects on: 2013-07-29 23:21:14
Mac70,

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.

Nate
5  Game Development / Newbie & Debugging Questions / Re: Uninitialized Objects on: 2013-07-29 21: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 17: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 16:53:18
I've got an object with three arraylists:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
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!
Nathan
8  Game Development / Newbie & Debugging Questions / Re: Recommended Libraries for 2d ASCII games on: 2012-09-05 16: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 19: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]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (23 views)
2014-04-15 18:08:23

BurntPizza (18 views)
2014-04-15 03:46:01

UprightPath (32 views)
2014-04-14 17:39:50

UprightPath (16 views)
2014-04-14 17:35:47

Porlus (32 views)
2014-04-14 15:48:38

tom_mai78101 (58 views)
2014-04-10 04:04:31

BurntPizza (116 views)
2014-04-08 23:06:04

tom_mai78101 (216 views)
2014-04-05 13:34:39

trollwarrior1 (183 views)
2014-04-04 12:06:45

CJLetsGame (190 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
java-gaming.org 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‑gaming.org
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!