2D RPG Ranged Damage Design Question

Started by
2 comments, last by Kylotan 17 years, 1 month ago
Hey all. I've got a design question for the board. I'm creating a 2D RPG game for a few friends and myself to play. It's nothing fancy, just a little dungeon crawler for a few nerds to play when we get bored. I'm using C++, Dev-C++, and SDL for graphics and sound (well, eventually sound :-P). I've setup a spell class that holds information such as spell name, mana cost, and damage- ya know, the norm. I've also set up a projectile class so I can easily keep track of all moving projetiles. The class has information such as range, speed, and position. Both classes of course have a crap-ton of other variables but you get the idea. My question is should I pass the damage from the spell template to the projectile to be inflicted on the unit when a collision is detected or should I keep the damage in the spell class and just use the projectile class for positioning? Any comments or ideas would be much appreciated. Let me know if I haven't given enough information. Thanks in advance, -Artum.
Advertisement
It seems to me passing the damage to the projectile class would be more encapsulated. That way your projectile class can work for any type of damage regardless of if its for spells, bows, traps, etc.
Awesome, thanks for the input. I've been using the projectile to carry the information so far and it's been working just fine. Sometimes it's just nice to get a second oppinion.

Thanks again,
-Artum.
This is really for our programming forums rather than the design forum, so I'll move it in case anybody else has any input.

Personally I would keep the damage resolution in the spell class. Putting it in the projectile makes sense when it's just a constant value or a simple range, but if you want to do something complex like draining life from the victim and adding it to the caster, or charming the victim, or anything else that relates the victim back to the caster somehow, you'll want to preserve that link.

This topic is closed to new replies.

Advertisement