Skip to content

Commit

Permalink
Fix formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurmoreno committed Nov 17, 2024
1 parent b549566 commit 077937b
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 148 deletions.
8 changes: 7 additions & 1 deletion src/Constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ enum struct DirectionEnum { UP = 0, DOWN = 1, RIGHT = 2, LEFT = 3 };

enum struct PlayerStateEnum { IDLE = 0, MOVING = 1, FIRING = 2, STABLE = 3, EXPLODING = 4 };

enum struct SceneSelection { TITLE_SCREEN = 0, MAIN_MENU = 1, GAME_MATCH = 2, WINNER_SCREEN = 3, UNKNOWN = 4};
enum struct SceneSelection {
TITLE_SCREEN = 0,
MAIN_MENU = 1,
GAME_MATCH = 2,
WINNER_SCREEN = 3,
UNKNOWN = 4
};

// Function to convert Jogador2Direction to string
inline std::string directionToString(DirectionEnum dir) {
Expand Down
12 changes: 4 additions & 8 deletions src/Player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Player {
std::string playerName;
SpriteSet spriteSet;
SDL_Surface* spriteSurface;
SDL_Texture *spriteTexture;
SDL_Texture* spriteTexture;

int direction;
SDL_Rect position;
Expand Down Expand Up @@ -51,21 +51,17 @@ class Player {
32); // Virado para esquerda
};

~Player() {
SDL_DestroyTexture(spriteTexture);
}
~Player() { SDL_DestroyTexture(spriteTexture); }

void resetStates() {
movingState = PlayerStateEnum::IDLE;
firingState = PlayerStateEnum::IDLE;
explodingState = PlayerStateEnum::STABLE;
}

void loadSprite(const std::string& spriteFileName, SDL_Renderer *renderer) {
void loadSprite(const std::string& spriteFileName, SDL_Renderer* renderer) {
spriteSurface = SDL_LoadBMP(spriteFileName.c_str());
SDL_SetColorKey(
spriteSurface, SDL_TRUE,
SDL_MapRGB(spriteSurface->format, 0, 255, 0));
SDL_SetColorKey(spriteSurface, SDL_TRUE, SDL_MapRGB(spriteSurface->format, 0, 255, 0));
spriteTexture = SDL_CreateTextureFromSurface(renderer, spriteSurface);
SDL_FreeSurface(spriteSurface);
};
Expand Down
12 changes: 4 additions & 8 deletions src/Projectile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Projectile {
int projectileId;
SpriteSet spriteSet;
SDL_Surface* spriteSurface;
SDL_Texture *spriteTexture;
SDL_Texture* spriteTexture;

int direction;
SDL_Rect position;
Expand All @@ -42,15 +42,11 @@ class Projectile {
32); // Virado para esquerda
};

~Projectile() {
SDL_DestroyTexture(spriteTexture);
}
~Projectile() { SDL_DestroyTexture(spriteTexture); }

void loadSprite(const std::string& spriteFileName, SDL_Renderer *renderer) {
void loadSprite(const std::string& spriteFileName, SDL_Renderer* renderer) {
spriteSurface = SDL_LoadBMP(spriteFileName.c_str());
SDL_SetColorKey(
spriteSurface, SDL_TRUE,
SDL_MapRGB(spriteSurface->format, 0, 255, 0));
SDL_SetColorKey(spriteSurface, SDL_TRUE, SDL_MapRGB(spriteSurface->format, 0, 255, 0));
spriteTexture = SDL_CreateTextureFromSurface(renderer, spriteSurface);
SDL_FreeSurface(spriteSurface);
};
Expand Down
Loading

0 comments on commit 077937b

Please sign in to comment.