Eliminat "const.h"

This commit is contained in:
2024-09-28 10:16:35 +02:00
parent 8d263931b2
commit f2cc0dc352
28 changed files with 74 additions and 91 deletions

View File

@@ -1,5 +1,4 @@
#include "balloon.h" #include "balloon.h"
#include "const.h"
#include "param.h" #include "param.h"
// Constructor // Constructor
@@ -281,9 +280,9 @@ void Balloon::allignTo(int x)
{ {
posX = float(x - (width / 2)); posX = float(x - (width / 2));
if (posX < PLAY_AREA_LEFT) if (posX < param.game.playArea.rect.x)
{ {
posX = PLAY_AREA_LEFT + 1; posX = param.game.playArea.rect.x + 1;
} }
else if ((posX + width) > param.game.playArea.rect.w) else if ((posX + width) > param.game.playArea.rect.w)
{ {
@@ -347,7 +346,7 @@ void Balloon::move()
posX += (velX * speed); posX += (velX * speed);
// Si queda fuera de pantalla, corregimos su posición y cambiamos su sentido // Si queda fuera de pantalla, corregimos su posición y cambiamos su sentido
if ((posX < PLAY_AREA_LEFT) || (posX + width > param.game.playArea.rect.w)) if ((posX < param.game.playArea.rect.x) || (posX + width > param.game.playArea.rect.w))
{ {
// Corrige posición // Corrige posición
posX -= (velX * speed); posX -= (velX * speed);
@@ -369,10 +368,10 @@ void Balloon::move()
posY += (velY * speed); posY += (velY * speed);
// Si se sale por arriba // Si se sale por arriba
if (posY < PLAY_AREA_TOP) if (posY < param.game.playArea.rect.y)
{ {
// Corrige // Corrige
posY = PLAY_AREA_TOP; posY = param.game.playArea.rect.y;
// Invierte sentido // Invierte sentido
velY = -velY; velY = -velY;
@@ -508,7 +507,7 @@ void Balloon::updateState()
posX += velX; posX += velX;
// Comprueba no se salga por los laterales // Comprueba no se salga por los laterales
if ((posX < PLAY_AREA_LEFT) || (posX > (param.game.playArea.rect.w - width))) if ((posX < param.game.playArea.rect.x) || (posX > (param.game.playArea.rect.w - width)))
{ {
// Corrige y cambia el sentido de la velocidad // Corrige y cambia el sentido de la velocidad
posX -= velX; posX -= velX;

View File

@@ -1,5 +1,5 @@
#include "const.h"
#include "bullet.h" #include "bullet.h"
#include "param.h"
// Constructor // Constructor
Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, SDL_Rect *playArea, Texture *texture) Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, SDL_Rect *playArea, Texture *texture)
@@ -108,10 +108,10 @@ Uint8 Bullet::move()
posX += velX; posX += velX;
// Si el objeto se sale del area de juego por los laterales // Si el objeto se sale del area de juego por los laterales
if ((posX < PLAY_AREA_LEFT - width) || (posX > playArea->w)) if ((posX < param.game.playArea.rect.x - width) || (posX > playArea->w))
{ {
// Se deshabilita // Se deshabilita
kind = NO_KIND; kind = BULLET_NULL;
// Mensaje de salida // Mensaje de salida
msg = BULLET_MOVE_OUT; msg = BULLET_MOVE_OUT;
@@ -121,10 +121,10 @@ Uint8 Bullet::move()
posY += int(velY); posY += int(velY);
// Si el objeto se sale del area de juego por la parte superior // Si el objeto se sale del area de juego por la parte superior
if (posY < PLAY_AREA_TOP - height) if (posY < param.game.playArea.rect.y - height)
{ {
// Se deshabilita // Se deshabilita
kind = NO_KIND; kind = BULLET_NULL;
// Mensaje de salida // Mensaje de salida
msg = BULLET_MOVE_OUT; msg = BULLET_MOVE_OUT;
@@ -143,7 +143,7 @@ Uint8 Bullet::move()
// Comprueba si el objeto está habilitado // Comprueba si el objeto está habilitado
bool Bullet::isEnabled() bool Bullet::isEnabled()
{ {
if (kind == NO_KIND) if (kind == BULLET_NULL)
{ {
return false; return false;
} }
@@ -156,7 +156,7 @@ bool Bullet::isEnabled()
// Deshabilita el objeto // Deshabilita el objeto
void Bullet::disable() void Bullet::disable()
{ {
kind = NO_KIND; kind = BULLET_NULL;
} }
// Obtiene el valor de la variable // Obtiene el valor de la variable

View File

@@ -8,6 +8,7 @@
#define BULLET_UP 1 #define BULLET_UP 1
#define BULLET_LEFT 2 #define BULLET_LEFT 2
#define BULLET_RIGHT 3 #define BULLET_RIGHT 3
#define BULLET_NULL 4
// Tipos de retorno de la funcion move de la bala // Tipos de retorno de la funcion move de la bala
#define BULLET_MOVE_OK 0 #define BULLET_MOVE_OK 0

View File

@@ -1,29 +0,0 @@
#pragma once
#include <SDL2/SDL.h>
#include "utils.h"
// Tamaño de bloque
#define BLOCK 8
// Para mejor visibilidad
#define PLAY_AREA_LEFT 0
#define PLAY_AREA_TOP 0
// Ningun tipo
#define NO_KIND 0
// Colores
const color_t bgColor = {0x27, 0x27, 0x36};
const color_t noColor = {0xFF, 0xFF, 0xFF};
const color_t shdwTxtColor = {0x43, 0x43, 0x4F};
const color_t separatorColor = {0x0D, 0x1A, 0x2B};
const color_t scoreboardColor = {0x2E, 0x3F, 0x47};
const color_t difficultyEasyColor = {0x4B, 0x69, 0x2F};
const color_t difficultyNormalColor = {0xFF, 0x7A, 0x00};
const color_t difficultyHardColor = {0x76, 0x42, 0x8A};
const color_t flashColor = {0xFF, 0xFF, 0xFF};
const color_t fadeColor = {0x27, 0x27, 0x36};
const color_t orangeColor = {0xFF, 0x7A, 0x00};

View File

@@ -3,7 +3,6 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "input.h" #include "input.h"
#include "text.h" #include "text.h"
#include "const.h"
#include "lang.h" #include "lang.h"
struct db_button_t struct db_button_t

View File

@@ -1,6 +1,5 @@
#include "director.h" #include "director.h"
#include "utils.h" #include "utils.h"
#include "const.h"
#include "options.h" #include "options.h"
#include "section.h" #include "section.h"
#include <iostream> #include <iostream>

View File

@@ -7,7 +7,6 @@
#include "screen.h" #include "screen.h"
#include "text.h" #include "text.h"
#include "utils.h" #include "utils.h"
#include "const.h"
#include "fade.h" #include "fade.h"
#include "game.h" #include "game.h"
#include "intro.h" #include "intro.h"

View File

@@ -18,19 +18,19 @@ EnemyFormations::~EnemyFormations()
void EnemyFormations::initEnemyFormations() void EnemyFormations::initEnemyFormations()
{ {
const int y4 = - BLOCK; const int y4 = - BLOCK;
const int x4_0 = PLAY_AREA_LEFT; const int x4_0 = param.game.playArea.rect.x;
const int x4_100 = param.game.playArea.rect.w - BALLOON_WIDTH_4; const int x4_100 = param.game.playArea.rect.w - BALLOON_WIDTH_4;
const int y3 = - BLOCK; const int y3 = - BLOCK;
const int x3_0 = PLAY_AREA_LEFT; const int x3_0 = param.game.playArea.rect.x;
const int x3_100 = param.game.playArea.rect.w - BALLOON_WIDTH_3; const int x3_100 = param.game.playArea.rect.w - BALLOON_WIDTH_3;
const int y2 = - BLOCK; const int y2 = - BLOCK;
const int x2_0 = PLAY_AREA_LEFT; const int x2_0 = param.game.playArea.rect.x;
const int x2_100 = param.game.playArea.rect.w - BALLOON_WIDTH_2; const int x2_100 = param.game.playArea.rect.w - BALLOON_WIDTH_2;
const int y1 = - BLOCK; const int y1 = - BLOCK;
const int x1_0 = PLAY_AREA_LEFT; const int x1_0 = param.game.playArea.rect.x;
const int x1_50 = param.game.playArea.centerX - (BALLOON_WIDTH_1 / 2); const int x1_50 = param.game.playArea.centerX - (BALLOON_WIDTH_1 / 2);
const int x1_100 = param.game.playArea.rect.w - BALLOON_WIDTH_1; const int x1_100 = param.game.playArea.rect.w - BALLOON_WIDTH_1;

View File

@@ -2,7 +2,6 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "utils.h" #include "utils.h"
#include "const.h"
#include "balloon.h" #include "balloon.h"
#define NUMBER_OF_ENEMY_FORMATIONS 100 #define NUMBER_OF_ENEMY_FORMATIONS 100

View File

@@ -1,5 +1,4 @@
#include "fade.h" #include "fade.h"
#include "const.h"
#include "param.h" #include "param.h"
#include <iostream> #include <iostream>

View File

@@ -985,7 +985,7 @@ void Game::createPowerBall()
const int values = 6; const int values = 6;
const int posY = -BLOCK; const int posY = -BLOCK;
const int left = PLAY_AREA_LEFT; const int left = param.game.playArea.rect.x;
const int center = param.game.playArea.centerX - (BALLOON_WIDTH_4 / 2); const int center = param.game.playArea.centerX - (BALLOON_WIDTH_4 / 2);
const int right = param.game.playArea.rect.w - BALLOON_WIDTH_4; const int right = param.game.playArea.rect.w - BALLOON_WIDTH_4;
@@ -1416,7 +1416,7 @@ void Game::checkBulletBalloonCollision()
// Suelta el item si se da el caso // Suelta el item si se da el caso
const int droppeditem = dropItem(); const int droppeditem = dropItem();
if ((droppeditem != NO_KIND) && !(demo.recording)) if ((droppeditem != ITEM_NULL) && !(demo.recording))
{ {
if (droppeditem != ITEM_COFFEE_MACHINE) if (droppeditem != ITEM_COFFEE_MACHINE)
{ {
@@ -1596,7 +1596,7 @@ int Game::dropItem()
break; break;
} }
return NO_KIND; return ITEM_NULL;
} }
// Crea un objeto item // Crea un objeto item
@@ -2460,7 +2460,7 @@ void Game::initPaths()
// Letrero de GetReady // Letrero de GetReady
const int size = textNokiaBig2->lenght(lang::getText(75), -2); const int size = textNokiaBig2->lenght(lang::getText(75), -2);
const float start1 = PLAY_AREA_LEFT - size; const float start1 = param.game.playArea.rect.x - size;
const float finish1 = param.game.playArea.centerX - (size / 2); const float finish1 = param.game.playArea.centerX - (size / 2);
const float start2 = finish1; const float start2 = finish1;

View File

@@ -12,7 +12,6 @@
#include "sprite.h" #include "sprite.h"
#include "text.h" #include "text.h"
#include "utils.h" #include "utils.h"
#include "const.h"
#include "fade.h" #include "fade.h"
#include "item.h" #include "item.h"
#include "player.h" #include "player.h"

View File

@@ -5,7 +5,6 @@
#include "screen.h" #include "screen.h"
#include "smartsprite.h" #include "smartsprite.h"
#include "jail_audio.h" #include "jail_audio.h"
#include "const.h"
// Clase GameLogo // Clase GameLogo
class GameLogo class GameLogo

View File

@@ -8,7 +8,6 @@
#include "sprite.h" #include "sprite.h"
#include "text.h" #include "text.h"
#include "utils.h" #include "utils.h"
#include "const.h"
#include "lang.h" #include "lang.h"
#include "fade.h" #include "fade.h"
#include "background.h" #include "background.h"

View File

@@ -8,7 +8,6 @@
#include "sprite.h" #include "sprite.h"
#include "text.h" #include "text.h"
#include "utils.h" #include "utils.h"
#include "const.h"
#include "lang.h" #include "lang.h"
#include "tiledbg.h" #include "tiledbg.h"
#include "fade.h" #include "fade.h"

View File

@@ -8,7 +8,6 @@
#include "smartsprite.h" #include "smartsprite.h"
#include "utils.h" #include "utils.h"
#include "writer.h" #include "writer.h"
#include "const.h"
#include "lang.h" #include "lang.h"
#include <vector> #include <vector>
#include "section.h" #include "section.h"

View File

@@ -1,5 +1,5 @@
#include "const.h"
#include "item.h" #include "item.h"
#include "param.h"
// Constructor // Constructor
Item::Item(int kind, float x, float y, SDL_Rect *playArea, Texture *texture, std::vector<std::string> *animation) Item::Item(int kind, float x, float y, SDL_Rect *playArea, Texture *texture, std::vector<std::string> *animation)
@@ -52,9 +52,9 @@ void Item::allignTo(int x)
{ {
posX = float(x - (width / 2)); posX = float(x - (width / 2));
if (posX < PLAY_AREA_LEFT) if (posX < param.game.playArea.rect.x)
{ {
posX = PLAY_AREA_LEFT + 1; posX = param.game.playArea.rect.x + 1;
} }
else if ((posX + width) > playArea->w) else if ((posX + width) > playArea->w)
{ {
@@ -99,7 +99,7 @@ void Item::move()
velY += accelY; velY += accelY;
// Si queda fuera de pantalla, corregimos su posición y cambiamos su sentido // Si queda fuera de pantalla, corregimos su posición y cambiamos su sentido
if ((posX < PLAY_AREA_LEFT) || (posX + width > playArea->w)) if ((posX < param.game.playArea.rect.x) || (posX + width > playArea->w))
{ {
// Corregir posición // Corregir posición
posX -= velX; posX -= velX;
@@ -109,10 +109,10 @@ void Item::move()
} }
// Si se sale por arriba rebota (excepto la maquina de café) // Si se sale por arriba rebota (excepto la maquina de café)
if ((posY < PLAY_AREA_TOP) && !(kind == ITEM_COFFEE_MACHINE)) if ((posY < param.game.playArea.rect.y) && !(kind == ITEM_COFFEE_MACHINE))
{ {
// Corrige // Corrige
posY = PLAY_AREA_TOP; posY = param.game.playArea.rect.y;
// Invierte el sentido // Invierte el sentido
velY = -velY; velY = -velY;

View File

@@ -11,6 +11,7 @@
#define ITEM_CLOCK 4 #define ITEM_CLOCK 4
#define ITEM_COFFEE 5 #define ITEM_COFFEE 5
#define ITEM_COFFEE_MACHINE 6 #define ITEM_COFFEE_MACHINE 6
#define ITEM_NULL 7
// Clase Item // Clase Item
class Item class Item

View File

@@ -3,7 +3,6 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <vector> #include <vector>
#include "asset.h" #include "asset.h"
#include "const.h"
#include "input.h" #include "input.h"
#include "jail_audio.h" #include "jail_audio.h"
#include "lang.h" #include "lang.h"

View File

@@ -2,7 +2,6 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "utils.h" #include "utils.h"
#include "const.h"
// Variables // Variables
extern options_t options; extern options_t options;

View File

@@ -2,7 +2,6 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "utils.h" #include "utils.h"
#include "const.h"
extern param_t param; extern param_t param;

View File

@@ -1,5 +1,5 @@
#include "const.h"
#include "player.h" #include "player.h"
#include "param.h"
// Constructor // Constructor
Player::Player(int id, float x, int y, SDL_Rect *playArea, std::vector<Texture *> texture, std::vector<std::vector<std::string> *> animations) Player::Player(int id, float x, int y, SDL_Rect *playArea, std::vector<Texture *> texture, std::vector<std::vector<std::string> *> animations)
@@ -114,7 +114,7 @@ void Player::move()
posX += velX; posX += velX;
// Si el jugador abandona el area de juego por los laterales // Si el jugador abandona el area de juego por los laterales
if ((posX < PLAY_AREA_LEFT - 5) || (posX + width > playArea->w + 5)) if ((posX < param.game.playArea.rect.x - 5) || (posX + width > playArea->w + 5))
{ {
// Restaura su posición // Restaura su posición
posX -= velX; posX -= velX;
@@ -131,7 +131,7 @@ void Player::move()
playerSprite->update(); playerSprite->update();
// Si el cadaver abandona el area de juego por los laterales // Si el cadaver abandona el area de juego por los laterales
if ((playerSprite->getPosX() < PLAY_AREA_LEFT) || (playerSprite->getPosX() + width > playArea->w)) if ((playerSprite->getPosX() < param.game.playArea.rect.x) || (playerSprite->getPosX() + width > playArea->w))
{ {
// Restaura su posición // Restaura su posición
const float vx = playerSprite->getVelX(); const float vx = playerSprite->getVelX();

View File

@@ -6,7 +6,6 @@
#include "sprite.h" #include "sprite.h"
#include "text.h" #include "text.h"
#include "utils.h" #include "utils.h"
#include "const.h"
#include "lang.h" #include "lang.h"
// Defines // Defines

View File

@@ -5,7 +5,6 @@
#include "utils.h" #include "utils.h"
#include "notify.h" #include "notify.h"
#include "input.h" #include "input.h"
#include "const.h"
#include <vector> #include <vector>
#define SCREEN_FILTER_NEAREST 0 #define SCREEN_FILTER_NEAREST 0

View File

@@ -4,7 +4,6 @@
#include "asset.h" #include "asset.h"
#include "screen.h" #include "screen.h"
#include "sprite.h" #include "sprite.h"
#include "const.h"
// Modos de funcionamiento para el tileado de fondo // Modos de funcionamiento para el tileado de fondo
#define TILED_MODE_CIRCLE 0 #define TILED_MODE_CIRCLE 0

View File

@@ -2,25 +2,24 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "asset.h" #include "asset.h"
#include "define_buttons.h"
#include "fade.h"
#include "game.h"
#include "game_logo.h"
#include "hiscore_table.h"
#include "input.h" #include "input.h"
#include "instructions.h"
#include "item.h"
#include "jail_audio.h" #include "jail_audio.h"
#include "lang.h"
#include "movingsprite.h" #include "movingsprite.h"
#include "screen.h" #include "screen.h"
#include "section.h"
#include "smartsprite.h" #include "smartsprite.h"
#include "sprite.h" #include "sprite.h"
#include "text.h" #include "text.h"
#include "utils.h"
#include "const.h"
#include "fade.h"
#include "game.h"
#include "hiscore_table.h"
#include "instructions.h"
#include "item.h"
#include "lang.h"
#include "tiledbg.h" #include "tiledbg.h"
#include "game_logo.h" #include "utils.h"
#include "define_buttons.h"
#include "section.h"
// Textos // Textos
#define TEXT_COPYRIGHT "@2020,2024 JailDesigner" #define TEXT_COPYRIGHT "@2020,2024 JailDesigner"

View File

@@ -1,6 +1,19 @@
#include "utils.h" #include "utils.h"
#include <math.h> #include <math.h>
// Colores
const color_t bgColor = {0x27, 0x27, 0x36};
const color_t noColor = {0xFF, 0xFF, 0xFF};
const color_t shdwTxtColor = {0x43, 0x43, 0x4F};
const color_t separatorColor = {0x0D, 0x1A, 0x2B};
const color_t scoreboardColor = {0x2E, 0x3F, 0x47};
const color_t difficultyEasyColor = {0x4B, 0x69, 0x2F};
const color_t difficultyNormalColor = {0xFF, 0x7A, 0x00};
const color_t difficultyHardColor = {0x76, 0x42, 0x8A};
const color_t flashColor = {0xFF, 0xFF, 0xFF};
const color_t fadeColor = {0x27, 0x27, 0x36};
const color_t orangeColor = {0xFF, 0x7A, 0x00};
// Calcula el cuadrado de la distancia entre dos puntos // Calcula el cuadrado de la distancia entre dos puntos
double distanceSquared(int x1, int y1, int x2, int y2) double distanceSquared(int x1, int y1, int x2, int y2)
{ {

View File

@@ -1,17 +1,19 @@
#pragma once #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "texture.h"
#include "jail_audio.h"
#include "input.h"
#include <string> #include <string>
#include <vector> #include <vector>
#include "input.h"
#include "jail_audio.h"
// Dificultad del juego // Dificultad del juego
#define DIFFICULTY_EASY 0 #define DIFFICULTY_EASY 0
#define DIFFICULTY_NORMAL 1 #define DIFFICULTY_NORMAL 1
#define DIFFICULTY_HARD 2 #define DIFFICULTY_HARD 2
// Tamaño de bloque
#define BLOCK 8
// Estructura para definir un circulo // Estructura para definir un circulo
struct circle_t struct circle_t
{ {
@@ -288,4 +290,17 @@ JA_Music_t *getMusic(std::vector<music_file_t> music, std::string name);
hiScoreEntry_t sortHiScoreTable(hiScoreEntry_t entry1, hiScoreEntry_t entry2); hiScoreEntry_t sortHiScoreTable(hiScoreEntry_t entry1, hiScoreEntry_t entry2);
// Dibuja un circulo // Dibuja un circulo
void DrawCircle(SDL_Renderer *renderer, int32_t centerX, int32_t centerY, int32_t radius); void DrawCircle(SDL_Renderer *renderer, int32_t centerX, int32_t centerY, int32_t radius);
// Colores
extern const color_t bgColor;
extern const color_t noColor;
extern const color_t shdwTxtColor;
extern const color_t separatorColor;
extern const color_t scoreboardColor;
extern const color_t difficultyEasyColor;
extern const color_t difficultyNormalColor;
extern const color_t difficultyHardColor;
extern const color_t flashColor;
extern const color_t fadeColor;
extern const color_t orangeColor;