My current project is a pixel themed shoot-em-up and a feature I have been thinking of for a while is an upgrade system for the players ship running like so:
-Players wins a level, earning income along the way
-Player transitions to an upgrade menu/shop
-Player can buy additions to his ship, extending ships dimensions, but bringing in new abilities
So lets say the players initial model is a 20x20 square, he can buy another square, lets say it boosts ship speed, and choose where on his model to place the ship (top, bottom, left, right), in a tile format
How would I implement something like this?
The relevant structure of my program:
I have a PlayerShip class extending the Ship class. It has a SDL_Rect defining its dimensions, and a pointer to a clip used for rendering. I have a SDL_Texture wrapper class that provides a Render function that takes x, y, clip, and rotation values, then renders with SDL_RenderCopyEx.
I tried to create an add_clip function which took a clip to add and a coordinate relative to the main clip location. I created a struct that held a clip and an x and y value for each clip, then created a vector of these, adding new clips to this vector as needed, and updating the PlayerShip dimensions as a rectangle enclosing all added clips. However, once I started expanding my other ship functions ( move, render, and collision detection ) this was quickly becoming cumbersome because of having to handle each added piece almost like an added ship, and updating each of their positions and attributes seperately.
Is this the right direction to take? Is there some way to set a rect to render that is comprised of the other rects, without having to iterate through and render them seperately?