I'm starting development on a 2D overhead RPG game, and am wondering what the best approach for handling weapon collision and dealing damage to enemies is.
I'm currently using a basic Entity/Component structure for my game objects. I have a CharacterEntity, that has an EquipableEntity data member. The CharacterEntity has a component that listens for input. When a command to attack is received, the CharacterEntity is set into an attack mode where an attacking component gets the equipped entity and moves it in the attacking motion. Any collisions detected with the moving equipped entity in the world are then registered as successful attacks. Once the attacking component determines the attack is finished, the CharacterEntity leaves attack mode and returns to it's normal state.
Weapon collision is a basic LWJGL Rectangle that tests the .interesects() method, checking against all enemy rectangles. Currently it's just a stabbing motion (it moves out to x length, then returns).
The reason I did it this way was:
1) I wanted enemies to receive and respond damage as the sword crosses their path, instead of just saying "attack occurred in this general area" and having all enemies update at once. In the stabbing case, an enemy at the full length of the sword wouldn't take damage until the actual sword entity crosses it's path.
2) The weapons define their own appearance and boundary on the screen, making it easier to animate and sync with the game.
I'm entirely new to game development (if you haven't figured that out already). Is this the appropriate way to achieve the result I'm looking for, or complete overkill? How does a game like Terraria (where weapons move in a sweeping motion) or the Zelda series handle attacking and determining what enemies to hit and when? Am I on the right path or totally off?
Any advice or suggestions would be greatly appreciated.