So I’m trying to create a relatively simple 2D side-scrolling shooter, however, it isn’t turning out to be quite so simple… My problem is with determining how to structure the player entity. You see, the player should be comprised of two main parts: an arm with a gun, and a body. The arm with a gun is to rotate (aim) on a specified point (the player’s shoulder), meanwhile the body will have a hitbox for taking damage from enemy entities as well as displaying running or jumping animations (the player will always be in motion). On a side note I’ve already created a projectile system for my game, with a Bullet
class designed to take x & y coordinates + a direction to travel in, so no need to worry about coding that.
My first attempt at creating my player was to create both a Player
and PlayerGun
class, a Player
object would then store an instance of a PlayerGun
object, from which the update() method would be used to track input and adjust the PlayerGun
object accordingly (i.e. rotate it based on mouse x & y coordinates)… Although I’m not sure whether or not this is the way to go or not… How should I structure an entity whom has a rotating arm with a gun? Is this somehow accomplishable with a spritemap?
Any and all help would be greatly appreciated. Thanks.