diff --git a/media/font/nokia_big2.png b/media/font/nokia_big2.png index c731cf4..581b378 100644 Binary files a/media/font/nokia_big2.png and b/media/font/nokia_big2.png differ diff --git a/source/animatedsprite.cpp b/source/animatedsprite.cpp index faf4ad4..933a7df 100644 --- a/source/animatedsprite.cpp +++ b/source/animatedsprite.cpp @@ -4,13 +4,11 @@ // Constructor AnimatedSprite::AnimatedSprite() { - //init(nullptr, nullptr); } // Destructor AnimatedSprite::~AnimatedSprite() { - //init(nullptr, nullptr); } // Iniciador @@ -41,10 +39,10 @@ void AnimatedSprite::animate(int index) { if (mEnabled) { - // Calculamos el frame actual a partir del contador + // Calcula el frame actual a partir del contador mCurrentFrame = mAnimationCounter / mAnimation[index].speed; - // Si alcanzamos el final de la animación, reiniciamos el contador de la animación + // Si alcanza el final de la animación, reinicia el contador de la animación // en función de la variable loop if (mCurrentFrame >= mAnimation[index].numFrames) { @@ -56,10 +54,10 @@ void AnimatedSprite::animate(int index) // En caso contrario else { - // Escogemos el frame correspondiente de la animación + // Escoge el frame correspondiente de la animación setSpriteClip(mAnimation[index].frames[mCurrentFrame]); - // Incrementamos el contador de la animacion + // Incrementa el contador de la animacion mAnimationCounter++; } } diff --git a/source/balloon.cpp b/source/balloon.cpp index b0c00a5..ea3cc8f 100644 --- a/source/balloon.cpp +++ b/source/balloon.cpp @@ -351,13 +351,16 @@ void Balloon::init(float x, float y, Uint8 kind, float velx, float speed, Uint16 mPosX = x; mPosY = y; - mBouncing.enabled = false; // Si el efecto está activo - mBouncing.counter = 0; // Countador para el efecto - mBouncing.speed = 0; // Velocidad a la que transcurre el efecto - mBouncing.zoomW = 1.0f; // Zoom aplicado a la anchura - mBouncing.zoomH = 1.0f; // Zoom aplicado a la altura - mBouncing.despX = 0.0f; // Desplazamiento de pixeles en el eje X antes de pintar el objeto con zoom + // Valores para el efecto de rebote + mBouncing.enabled = false; + mBouncing.counter = 0; + mBouncing.speed = 0; + mBouncing.zoomW = 1.0f; + mBouncing.zoomH = 1.0f; + mBouncing.despX = 0.0f; mBouncing.despY = 0.0f; + mBouncing.w = {1.10f, 1.05f, 1.00f, 0.95f, 0.90f, 0.95f, 1.00f, 1.02f, 1.05f, 1.02f}; + mBouncing.h = {0.90f, 0.95f, 1.00f, 1.05f, 1.10f, 1.05f, 1.00f, 0.98f, 0.95f, 0.98f}; // Textura con los gráficos del sprite mSprite->setTexture(texture); @@ -432,13 +435,9 @@ void Balloon::allignTo(int x) mPosX = float(x - (mWidth / 2)); if (mPosX < PLAY_AREA_LEFT) - { mPosX = PLAY_AREA_LEFT + 1; - } else if ((mPosX + mWidth) > PLAY_AREA_RIGHT) - { mPosX = float(PLAY_AREA_RIGHT - mWidth - 1); - } // Posición X,Y del sprite mSprite->setPosX(getPosX()); @@ -531,10 +530,12 @@ void Balloon::move() } /* + Para aplicar la gravedad, el diseño original la aplicaba en cada iteración del bucle Al añadir el modificador de velocidad se reduce la distancia que recorre el objeto y por tanto recibe mas gravedad. Para solucionarlo se va a aplicar la gravedad cuando se haya recorrido una distancia igual a la velocidad en Y, que era el cálculo inicial + */ // Incrementa la variable que calcula la distancia acumulada en Y @@ -550,11 +551,6 @@ void Balloon::move() mVelY += mGravity; std::min(mVelY, mMaxVelY); } - // Aplica la gravedad al objeto - //if (mVelY > mMaxVelY) - // mVelY = mMaxVelY; - //else if (mCounter % 1 == 0) - // mVelY += mGravity; // Actualiza la posición del sprite mSprite->setPosX(getPosX()); @@ -603,7 +599,7 @@ void Balloon::disable() void Balloon::pop() { setPopping(true); - mSprite->setAnimationCounter(0); + mSprite->setAnimationCounter(0); mSprite->disableRotate(); setTimeToLive(120); setStop(true); @@ -679,12 +675,6 @@ void Balloon::updateState() updateColliders(); } - // Hace visible el globo de forma intermitente - //if (mCreationCounter > 100) - // setVisible(mCreationCounter / 10 % 2 == 0); - //else - // setVisible(mCreationCounter / 5 % 2 == 0); - mCreationCounter--; } // El contador ha llegado a cero @@ -711,7 +701,8 @@ void Balloon::updateState() if (mStoppedCounter > 0) mStoppedCounter--; // Si el contador ha llegado a cero, ya no está detenido - else if (!isPopping()) // Quitarles el estado "detenido" si no estan explosionandoxq + else if (!isPopping()) + // Quitarles el estado "detenido" si no estan explosionando setStop(false); } } @@ -910,7 +901,6 @@ circle_t &Balloon::getCollider() // Alinea el circulo de colisión con la posición del objeto globo void Balloon::updateColliders() { - // Align collider to center of balloon mCollider.x = Uint16(mPosX + mCollider.r); mCollider.y = mPosY + mCollider.r; } @@ -940,6 +930,7 @@ void Balloon::bounceStart() mBouncing.despX = 0; mBouncing.despY = 0; } + void Balloon::bounceStop() { mBouncing.enabled = false; @@ -951,6 +942,7 @@ void Balloon::bounceStop() mBouncing.despX = 0.0f; mBouncing.despY = 0.0f; } + void Balloon::updateBounce() { if (mBouncing.enabled) diff --git a/source/balloon.h b/source/balloon.h index 198bc69..dce1b0a 100644 --- a/source/balloon.h +++ b/source/balloon.h @@ -1,13 +1,71 @@ #pragma once #include "utils.h" #include "animatedsprite.h" +#include #ifndef BALLOON_H #define BALLOON_H +// Cantidad de elementos del vector con los valores de la deformación del globo al rebotar #define MAX_BOUNCE 10 -// Clase globo +// Tipos de globo +#define BALLOON_1 1 +#define BALLOON_2 2 +#define BALLOON_3 3 +#define BALLOON_4 4 +#define HEXAGON_1 5 +#define HEXAGON_2 6 +#define HEXAGON_3 7 +#define HEXAGON_4 8 +#define POWER_BALL 9 + +// Puntos de globo +#define BALLOON_SCORE_1 50 +#define BALLOON_SCORE_2 100 +#define BALLOON_SCORE_3 200 +#define BALLOON_SCORE_4 400 + +// Tamaños de globo +#define BALLOON_SIZE_1 1 +#define BALLOON_SIZE_2 2 +#define BALLOON_SIZE_3 3 +#define BALLOON_SIZE_4 4 + +// Clases de globo +#define BALLOON_CLASS 0 +#define HEXAGON_CLASS 1 + +// Velocidad del globo +#define BALLOON_VELX_POSITIVE 0.7f +#define BALLOON_VELX_NEGATIVE -0.7f + +// Indice para las animaciones de los globos +#define BALLOON_MOVING_ANIMATION 0 +#define BALLOON_POP_ANIMATION 1 +#define BALLOON_BORN_ANIMATION 2 + +// Cantidad posible de globos +#define MAX_BALLOONS 100 + +// Velocidades a las que se mueven los globos +#define BALLOON_SPEED_1 0.60f +#define BALLOON_SPEED_2 0.70f +#define BALLOON_SPEED_3 0.80f +#define BALLOON_SPEED_4 0.90f +#define BALLOON_SPEED_5 1.00f + +// Tamaño de los globos +#define BALLOON_WIDTH_1 8 +#define BALLOON_WIDTH_2 13 +#define BALLOON_WIDTH_3 21 +#define BALLOON_WIDTH_4 37 + +// PowerBall +#define POWERBALL_SCREENPOWER_MINIMUM 10 +#define POWERBALL_COUNTER 8 + +// Clase Balloon class Balloon { private: @@ -44,17 +102,15 @@ private: struct bouncing // Estructura para las variables para el efecto de los rebotes { - bool enabled; // Si el efecto está activo - Uint8 counter; // Countador para el efecto - Uint8 speed; // Velocidad a la que transcurre el efecto - float zoomW; // Zoom aplicado a la anchura - float zoomH; // Zoom aplicado a la altura - float despX; // Desplazamiento de pixeles en el eje X antes de pintar el objeto con zoom - float despY; // Desplazamiento de pixeles en el eje Y antes de pintar el objeto con zoom - - // Vector con los valores de zoom para el ancho y alto del globo - float w[MAX_BOUNCE] = {1.10f, 1.05f, 1.00f, 0.95f, 0.90f, 0.95f, 1.00f, 1.02f, 1.05f, 1.02f}; - float h[MAX_BOUNCE] = {0.90f, 0.95f, 1.00f, 1.05f, 1.10f, 1.05f, 1.00f, 0.98f, 0.95f, 0.98f}; + bool enabled; // Si el efecto está activo + Uint8 counter; // Countador para el efecto + Uint8 speed; // Velocidad a la que transcurre el efecto + float zoomW; // Zoom aplicado a la anchura + float zoomH; // Zoom aplicado a la altura + float despX; // Desplazamiento de pixeles en el eje X antes de pintar el objeto con zoom + float despY; // Desplazamiento de pixeles en el eje Y antes de pintar el objeto con zoom + std::vector w; // Vector con los valores de zoom para el ancho del globo + std::vector h; // Vector con los valores de zoom para el alto del globo }; bouncing mBouncing; diff --git a/source/bullet.cpp b/source/bullet.cpp index f063556..73e10ed 100644 --- a/source/bullet.cpp +++ b/source/bullet.cpp @@ -11,7 +11,6 @@ Bullet::Bullet() // Destructor Bullet::~Bullet() { - //init(0, 0, NO_KIND, nullptr, nullptr); delete mSprite; mSprite = nullptr; } @@ -107,7 +106,7 @@ void Bullet::render() Uint8 Bullet::move() { // Variable con el valor de retorno - Uint8 msg = MSG_OK; + Uint8 msg = BULLET_MOVE_OK; // Mueve el objeto a su nueva posición mPosX += mVelX; @@ -119,7 +118,7 @@ Uint8 Bullet::move() mKind = NO_KIND; // Mensaje de salida - msg = MSG_BULLET_OUT; + msg = BULLET_MOVE_OUT; } // Mueve el objeto a su nueva posición en vertical @@ -132,7 +131,7 @@ Uint8 Bullet::move() mKind = NO_KIND; // Mensaje de salida - msg = MSG_BULLET_OUT; + msg = BULLET_MOVE_OUT; } // Actualiza la posición del sprite @@ -145,18 +144,6 @@ Uint8 Bullet::move() return msg; } -#ifdef TEST -void Bullet::testMove() -{ - // Update sprite position - mSprite->setPosX(mPosX); - mSprite->setPosY(mPosY); - - // Update circle colliders - shiftColliders(); -} -#endif - // Deshabilita el objeto void Bullet::erase() { @@ -167,13 +154,9 @@ void Bullet::erase() bool Bullet::isActive() { if (mKind == NO_KIND) - { return false; - } else - { return true; - } } // Obtiene el valor de la variable diff --git a/source/bullet.h b/source/bullet.h index a48f3d3..fbc7c81 100644 --- a/source/bullet.h +++ b/source/bullet.h @@ -5,7 +5,16 @@ #ifndef BULLET_H #define BULLET_H -// Clase bala +// Tipos de bala +#define BULLET_UP 1 +#define BULLET_LEFT 2 +#define BULLET_RIGHT 3 + +// Tipos de retorno de la funcion move de la bala +#define BULLET_MOVE_OK 0 +#define BULLET_MOVE_OUT 1 + +// Clase Bullet class Bullet { private: diff --git a/source/const.h b/source/const.h index 18ea2c5..8adc7c3 100644 --- a/source/const.h +++ b/source/const.h @@ -2,86 +2,23 @@ #include "ifdefs.h" #include "utils.h" #include "lang.h" -#include #ifndef CONST_H #define CONST_H -// Textos -#define WINDOW_CAPTION "Coffee Crisis" -#define TEXT_COPYRIGHT "@2020,2021 JailDesigner (v2.0.2)" - -// Recursos -//#define BINFILE_SCORE 0 -//#define BINFILE_DEMO 1 -//#define BINFILE_CONFIG 2 -// -//#define TOTAL_BINFILE 3 -// -//#define MUSIC_INTRO 0 -//#define MUSIC_PLAYING 1 -//#define MUSIC_TITLE 2 -// -//#define TOTAL_MUSIC 3 -// -//#define SOUND_BALLOON 0 -//#define SOUND_BUBBLE1 1 -//#define SOUND_BUBBLE2 2 -//#define SOUND_BUBBLE3 3 -//#define SOUND_BUBBLE4 4 -//#define SOUND_BULLET 5 -//#define SOUND_COFFEE_OUT 6 -//#define SOUND_HISCORE 7 -//#define SOUND_ITEM_DROP 8 -//#define SOUND_ITEM_PICKUP 9 -//#define SOUND_MENU_CANCEL 10 -//#define SOUND_MENU_MOVE 11 -//#define SOUND_MENU_SELECT 12 -//#define SOUND_PLAYER_COLLISION 13 -//#define SOUND_STAGE_CHANGE 14 -//#define SOUND_TITLE 15 -//#define SOUND_CLOCK 16 -//#define SOUND_POWERBALL 17 -// -//#define TOTAL_SOUND 18 -// -//#define TEXTURE_BALLOON 0 -//#define TEXTURE_BULLET 1 -//#define TEXTURE_FONT_BLACK 2 -//#define TEXTURE_FONT_BLACK_X2 3 -//#define TEXTURE_FONT_NOKIA 4 -//#define TEXTURE_FONT_WHITE 5 -//#define TEXTURE_FONT_WHITE_X2 6 -//#define TEXTURE_GAME_BG 7 -//#define TEXTURE_GAME_TEXT 8 -//#define TEXTURE_INTRO 9 -//#define TEXTURE_ITEMS 10 -//#define TEXTURE_LOGO 11 -//#define TEXTURE_MENU 12 -//#define TEXTURE_PLAYER_BODY 13 -//#define TEXTURE_PLAYER_DEATH 14 -//#define TEXTURE_PLAYER_LEGS 15 -//#define TEXTURE_TITLE 16 -// -//#define TOTAL_TEXTURE 17 -// -//// Tamaño de bloque +// Tamaño de bloque #define BLOCK 8 #define HALF_BLOCK BLOCK / 2 -// -//// Tamaño de la pantalla real + +// Tamaño de la pantalla real #define SCREEN_WIDTH 256 -const int SCREEN_HEIGHT = SCREEN_WIDTH * 3 / 4; -// -//// Tamaño de la pantalla que se muestra +#define SCREEN_HEIGHT 192 + +// Tamaño de la pantalla que se muestra const int VIEW_WIDTH = SCREEN_WIDTH * 3; const int VIEW_HEIGHT = SCREEN_HEIGHT * 3; -// -//// Cantidad de enteros a escribir en los ficheros de datos -#define TOTAL_SCORE_DATA 3 -#define TOTAL_DEMO_DATA 2000 -//// Zona de juego +// Zona de juego const int PLAY_AREA_TOP = (0 * BLOCK); const int PLAY_AREA_BOTTOM = SCREEN_HEIGHT - (4 * BLOCK); const int PLAY_AREA_LEFT = (0 * BLOCK); @@ -94,8 +31,8 @@ const int PLAY_AREA_CENTER_THIRD_QUARTER_X = (PLAY_AREA_WIDTH / 4) * 3; const int PLAY_AREA_CENTER_Y = PLAY_AREA_TOP + (PLAY_AREA_HEIGHT / 2); const int PLAY_AREA_FIRST_QUARTER_Y = PLAY_AREA_HEIGHT / 4; const int PLAY_AREA_THIRD_QUARTER_Y = (PLAY_AREA_HEIGHT / 4) * 3; -// -//// Anclajes de pantalla + +// Anclajes de pantalla const int SCREEN_CENTER_X = SCREEN_WIDTH / 2; const int SCREEN_FIRST_QUARTER_X = SCREEN_WIDTH / 4; const int SCREEN_THIRD_QUARTER_X = (SCREEN_WIDTH / 4) * 3; @@ -103,56 +40,14 @@ const int SCREEN_CENTER_Y = SCREEN_HEIGHT / 2; const int SCREEN_FIRST_QUARTER_Y = SCREEN_HEIGHT / 4; const int SCREEN_THIRD_QUARTER_Y = (SCREEN_HEIGHT / 4) * 3; -//// Opciones de menu -#define MENU_NO_OPTION -1 -//#define MENU_OPTION_START 0 -//#define MENU_OPTION_QUIT 1 -//#define MENU_OPTION_TOTAL 2 -// -//// Tipos de fondos para el menu -#define MENU_BACKGROUND_TRANSPARENT 0 -#define MENU_BACKGROUND_SOLID 1 - -//// Estados del jugador -#define PLAYER_STATUS_WALKING_LEFT 0 -#define PLAYER_STATUS_WALKING_RIGHT 1 -#define PLAYER_STATUS_WALKING_STOP 2 - -#define PLAYER_STATUS_FIRING_UP 0 -#define PLAYER_STATUS_FIRING_LEFT 1 -#define PLAYER_STATUS_FIRING_RIGHT 2 -#define PLAYER_STATUS_FIRING_NO 3 - -#define PLAYER_ANIMATION_LEGS_WALKING_RIGHT 1 -#define PLAYER_ANIMATION_LEGS_WALKING_STOP 2 - -#define PLAYER_ANIMATION_BODY_WALKING_LEFT 0 -#define PLAYER_ANIMATION_BODY_FIRING_LEFT 1 -#define PLAYER_ANIMATION_BODY_WALKING_RIGHT 2 -#define PLAYER_ANIMATION_BODY_FIRING_RIGHT 3 -#define PLAYER_ANIMATION_BODY_WALKING_STOP 4 -#define PLAYER_ANIMATION_BODY_FIRING_UP 5 - -#define PLAYER_ANIMATION_HEAD_WALKING_LEFT 0 -#define PLAYER_ANIMATION_HEAD_FIRING_LEFT 1 -#define PLAYER_ANIMATION_HEAD_WALKING_RIGHT 2 -#define PLAYER_ANIMATION_HEAD_FIRING_RIGHT 3 -#define PLAYER_ANIMATION_HEAD_WALKING_STOP 4 -#define PLAYER_ANIMATION_HEAD_FIRING_UP 5 -#define PLAYER_ANIMATION_LEGS_WALKING_LEFT 0 - -//// Variables del jugador -//#define PLAYER_INVULNERABLE_COUNTER 200 -//#define PLAYER_POWERUP_COUNTER 1500 -// -//// Secciones del programa +// Secciones del programa #define PROG_SECTION_LOGO 0 #define PROG_SECTION_INTRO 1 #define PROG_SECTION_TITLE 2 #define PROG_SECTION_GAME 3 #define PROG_SECTION_QUIT 4 -// -//// Subsecciones + +// Subsecciones #define GAME_SECTION_PLAY_1P 0 #define GAME_SECTION_PLAY_2P 1 #define GAME_SECTION_PAUSE 2 @@ -161,198 +56,18 @@ const int SCREEN_THIRD_QUARTER_Y = (SCREEN_HEIGHT / 4) * 3; #define TITLE_SECTION_2 4 #define TITLE_SECTION_3 5 #define TITLE_SECTION_INSTRUCTIONS 6 -// -//// Modo para las instrucciones -#define INSTRUCTIONS_MODE_MANUAL 0 -#define INSTRUCTIONS_MODE_AUTO 1 -// -//// Estados de cada elemento que pertenece a un evento + +// Estados de cada elemento que pertenece a un evento #define EVENT_WAITING 1 #define EVENT_RUNNING 2 #define EVENT_COMPLETED 3 -//// Cantidad de eventos de la intro -#define INTRO_TOTAL_BITMAPS 6 -#define INTRO_TOTAL_TEXTS 9 -const int INTRO_TOTAL_EVENTS = INTRO_TOTAL_BITMAPS + INTRO_TOTAL_TEXTS; -// -//// Cantidad de eventos de la pantalla de titulo -//#define TITLE_TOTAL_EVENTS 2 -// -//// Relaciones de Id con nomnbres -#define BITMAP0 0 -#define BITMAP1 1 -#define BITMAP2 2 -#define BITMAP3 3 -#define BITMAP4 4 -#define BITMAP5 5 -#define TEXT0 6 -#define TEXT1 7 -#define TEXT2 8 -#define TEXT3 9 -#define TEXT4 10 -#define TEXT5 11 -#define TEXT6 12 -#define TEXT7 13 -#define TEXT8 14 - -//// Anclajes para el marcador de puntos -//const int SCORE_WORD_X = (SCREEN_WIDTH / 4) - ((5 * BLOCK) / 2); -//const int SCORE_WORD_Y = SCREEN_HEIGHT - (3 * BLOCK) + 2; -//const int SCORE_NUMBER_X = (SCREEN_WIDTH / 4) - ((6 * BLOCK) / 2); -//const int SCORE_NUMBER_Y = SCREEN_HEIGHT - (2 * BLOCK) + 2; -// -//const int HISCORE_WORD_X = ((SCREEN_WIDTH / 4) * 3) - ((8 * BLOCK) / 2); -//const int HISCORE_WORD_Y = SCREEN_HEIGHT - (3 * BLOCK) + 2; -//const int HISCORE_NUMBER_X = ((SCREEN_WIDTH / 4) * 3) - ((6 * BLOCK) / 2); -//const int HISCORE_NUMBER_Y = SCREEN_HEIGHT - (2 * BLOCK) + 2; -// -//const int MULTIPLIER_WORD_X = (SCREEN_WIDTH / 2) - ((4 * BLOCK) / 2); -//const int MULTIPLIER_WORD_Y = SCREEN_HEIGHT - (3 * BLOCK) + 2; -//const int MULTIPLIER_NUMBER_X = (SCREEN_WIDTH / 2) - ((3 * BLOCK) / 2); -//const int MULTIPLIER_NUMBER_Y = SCREEN_HEIGHT - (2 * BLOCK) + 2; -// -//// Ningun tipo +// Ningun tipo #define NO_KIND 0 -// -//// Tipos de globo -#define BALLOON_1 1 -#define BALLOON_2 2 -#define BALLOON_3 3 -#define BALLOON_4 4 -#define HEXAGON_1 5 -#define HEXAGON_2 6 -#define HEXAGON_3 7 -#define HEXAGON_4 8 -#define POWER_BALL 9 -// -//// Puntos de globo -#define BALLOON_SCORE_1 50 -#define BALLOON_SCORE_2 100 -#define BALLOON_SCORE_3 200 -#define BALLOON_SCORE_4 400 -// -//// Tamaños de globo -#define BALLOON_SIZE_1 1 -#define BALLOON_SIZE_2 2 -#define BALLOON_SIZE_3 3 -#define BALLOON_SIZE_4 4 -// -//// Clases de globo -#define BALLOON_CLASS 0 -#define HEXAGON_CLASS 1 -// -//// Velocidad del globo -#define BALLOON_VELX_POSITIVE 0.7f -#define BALLOON_VELX_NEGATIVE -0.7f -//// Indice para las animaciones de los globos -#define BALLOON_MOVING_ANIMATION 0 -#define BALLOON_POP_ANIMATION 1 -#define BALLOON_BORN_ANIMATION 2 -// -//// Cantidad posible de globos -#define MAX_BALLOONS 100 -// -//// Velocidades a las que se mueven los enemigos -#define BALLOON_SPEED_1 0.60f -#define BALLOON_SPEED_2 0.70f -#define BALLOON_SPEED_3 0.80f -#define BALLOON_SPEED_4 0.90f -#define BALLOON_SPEED_5 1.00f - -//// Tamaño de los globos -#define BALLOON_WIDTH_1 8 -#define BALLOON_WIDTH_2 13 -#define BALLOON_WIDTH_3 21 -#define BALLOON_WIDTH_4 37 -// -//// PowerBall -#define POWERBALL_SCREENPOWER_MINIMUM 10 -#define POWERBALL_COUNTER 8 -// -//// Tipos de bala -#define BULLET_UP 1 -#define BULLET_LEFT 2 -#define BULLET_RIGHT 3 -// -//// Cantidad posible de globos -#define MAX_BULLETS 50 -// -//// Tipos de objetos -#define ITEM_POINTS_1_DISK 1 -#define ITEM_POINTS_2_GAVINA 2 -#define ITEM_POINTS_3_PACMAR 3 -#define ITEM_CLOCK 4 -#define ITEM_COFFEE 5 -#define ITEM_POWER_BALL 6 -#define ITEM_COFFEE_MACHINE 7 - -//// Porcentaje de aparición de los objetos -#define ITEM_POINTS_1_DISK_ODDS 10 -#define ITEM_POINTS_2_GAVINA_ODDS 6 -#define ITEM_POINTS_3_PACMAR_ODDS 3 -#define ITEM_CLOCK_ODDS 5 -#define ITEM_COFFEE_ODDS 5 -#define ITEM_POWER_BALL_ODDS 0 -#define ITEM_COFFEE_MACHINE_ODDS 4 - -//// Cantidad de objetos simultaneos -#define MAX_ITEMS 10 -// -//// Valores para las variables asociadas a los objetos -#define REMAINING_EXPLOSIONS 3 -#define REMAINING_EXPLOSIONS_COUNTER 50 -#define TIME_STOPPED_COUNTER 300 -// -//// Estados de entrada -#define NO_INPUT 0 -#define INPUT_FIRE_LEFT 7 -#define INPUT_FIRE_UP 8 -#define INPUT_FIRE_RIGHT 9 -//#define INPUT_PAUSE 10 -// -//// Zona muerta del mando analógico -//#define JOYSTICK_DEAD_ZONE 8000 -// -//// Tipos de mensajes para el retorno de las funciones -#define MSG_OK 0 -#define MSG_BULLET_OUT 1 -// -//// Tipos de texto -//#define TEXT_FIXED 0 -//#define TEXT_VARIABLE 1 -// -//// Cantidad de elementos del vector de SmartSprites -#define MAX_SMART_SPRITES 10 -// -//// Cantidad máxima de gotas de café -//#define MAX_COFFEE_DROPS 100 -// -//// Contadores -//#define TITLE_COUNTER 800 -#define STAGE_COUNTER 200 -#define INSTRUCTIONS_COUNTER 600 -#define DEATH_COUNTER 350 -#define SHAKE_COUNTER 10 -#define HELP_COUNTER 1000 -// -//// Colores +// Colores const color_t bgColor = {0x27, 0x27, 0x36}; const color_t noColor = {0xFF, 0xFF, 0xFF}; const color_t shdwTxtColor = {0x43, 0x43, 0x4F}; -//// Formaciones enemigas -#define NUMBER_OF_ENEMY_FORMATIONS 100 -#define MAX_NUMBER_OF_ENEMIES_IN_A_FORMATION 50 -// -//// Dificultad del juego -#define DIFFICULTY_EASY 0 -#define DIFFICULTY_NORMAL 1 -#define DIFFICULTY_HARD 2 -// -//// Tipo de filtro -#define FILTER_NEAREST 0 -#define FILTER_LINEAL 1 - #endif \ No newline at end of file diff --git a/source/director.cpp b/source/director.cpp index dca9901..51f7f9f 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -145,8 +145,7 @@ bool Director::initSDL() bool success = true; // Inicializa SDL - //if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO) < 0) - if (SDL_Init(SDL_INIT_EVERYTHING) < 0) + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO) < 0) { printf("SDL could not initialize!\nSDL Error: %s\n", SDL_GetError()); success = false; diff --git a/source/director.h b/source/director.h index 0d23e60..b25b56a 100644 --- a/source/director.h +++ b/source/director.h @@ -20,32 +20,32 @@ #include "game.h" #include "input.h" #include "fade.h" -//#include #ifndef DIRECTOR_H #define DIRECTOR_H +// Textos +#define WINDOW_CAPTION "Coffee Crisis" + +// Cantidad máxima de elementos para el vector con las rutas de los ficheros de recursos #define MAX_FILE_LIST 100 -// Director +// Clase Director class Director { private: - SDL_Window *mWindow; // La ventana donde dibujamos - SDL_Renderer *mRenderer; // El renderizador de la ventana - - Logo *mLogo; // Objeto para la sección del logo - Intro *mIntro; // Objeto para la sección de la intro - Title *mTitle; // Objeto para la sección del titulo y el menu de opciones - Game *mGame; // Objeto para la sección del juego - Input *mInput; // Objeto Input para gestionar las entradas - Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas - + SDL_Window *mWindow; // La ventana donde dibujamos + SDL_Renderer *mRenderer; // El renderizador de la ventana + Logo *mLogo; // Objeto para la sección del logo + Intro *mIntro; // Objeto para la sección de la intro + Title *mTitle; // Objeto para la sección del titulo y el menu de opciones + Game *mGame; // Objeto para la sección del juego + Input *mInput; // Objeto Input para gestionar las entradas + Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas std::string mFileList[MAX_FILE_LIST]; // Vector con las rutas a los ficheros de recursos struct options_t *mOptions; // Variable con todas las opciones del programa - - std::string mExecutablePath; // Path del ejecutable - section_t mSection; // Sección y subsección actual del programa; + std::string mExecutablePath; // Path del ejecutable + section_t mSection; // Sección y subsección actual del programa; // Inicializa jail_audio void initJailAudio(); diff --git a/source/fade.cpp b/source/fade.cpp index 17a96de..80d5fc9 100644 --- a/source/fade.cpp +++ b/source/fade.cpp @@ -25,9 +25,6 @@ void Fade::init(Uint8 r, Uint8 g, Uint8 b) mEnabled = false; mFinished = false; mCounter = 0; - //mR = 0x27; - //mG = 0x27; - //mB = 0x36; mR = r; mG = g; mB = b; @@ -121,7 +118,7 @@ void Fade::render() break; } } - + if (mFinished) { SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, 255); @@ -153,16 +150,7 @@ bool Fade::isEnabled() // Comprueba si ha terminado la transicion bool Fade::hasEnded() { - if (mFinished) - { - //mEnabled = false; - //mFinished = false; - return true; - } - else - { - return false; - } + return mFinished; } // Establece el tipo de fade diff --git a/source/fade.h b/source/fade.h index b5612ad..0d8247e 100644 --- a/source/fade.h +++ b/source/fade.h @@ -5,11 +5,12 @@ #ifndef FADE_H #define FADE_H +// Tipos de fundido #define FADE_FULLSCREEN 0 #define FADE_CENTER 1 #define FADE_RANDOM_SQUARE 2 -// Fade +// Clase Fade class Fade { private: diff --git a/source/game.cpp b/source/game.cpp index e826e16..2ef1917 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -388,9 +388,6 @@ void Game::init() initEnemyPools(); initGameStages(); - // BORRAR - //mStage[mCurrentStage].currentPower = mStage[mCurrentStage].powerToComplete - 10; - // Modo debug mDebug.enabled = false; mDebug.enemySet = 0; @@ -400,7 +397,7 @@ void Game::init() mDemo.recording = false; mDemo.counter = 0; - // Iniciualiza el objeto para el fundido + // Inicializa el objeto para el fundido mFade->init(0x27, 0x27, 0x36); // Inicializa el objeto con el menu de pausa @@ -1526,12 +1523,6 @@ void Game::increaseStageCurrentPower(Uint8 power) mStage[mCurrentStage].currentPower += power; } -// Establece el valor de la variable -/*void Game::setScore(Uint32 score) -{ - mScore = score; -}*/ - // Establece el valor de la variable void Game::setHiScore(Uint32 score) { @@ -1607,39 +1598,8 @@ std::string Game::updateScoreText(Uint32 num) // Pinta el marcador en pantalla usando un objeto texto void Game::renderScoreBoard() { - //color_t color = {0, 0, 0}; - - // Si el jugador esta muerto, no pintes el fondo del marcador, así que pase por encima cuando sale despedido - //if (mPlayer[0]->isAlive()) mSpriteScoreBoard->render(); - /* - // SCORE - mText->writeCentered(PLAY_AREA_CENTER_FIRST_QUARTER_X, SCORE_WORD_Y - 6, mLang->getText(39), 0); - mText->writeCentered(PLAY_AREA_CENTER_FIRST_QUARTER_X, SCORE_NUMBER_Y - 6, updateScoreText(mPlayer[0]->getScore()), 0); - // HI-SCORE - mText->writeCentered(PLAY_AREA_CENTER_THIRD_QUARTER_X, HISCORE_WORD_Y - 6, mLang->getText(40), 0); - mText->writeCentered(PLAY_AREA_CENTER_THIRD_QUARTER_X, HISCORE_NUMBER_Y - 6, updateScoreText(mHiScore), 0); - - // MULT - color.g = 255; - mText->writeColored(MULTIPLIER_WORD_X, MULTIPLIER_WORD_Y - 6, mLang->getText(41), color); - - color.g = 192; - mTextX2->writeShadowed(PLAY_AREA_CENTER_X - 16, SCORE_WORD_Y + 5, std::to_string(mPlayer[0]->getScoreMultiplier()).substr(0, 1), color, 1); - mText->writeShadowed(PLAY_AREA_CENTER_X - 2, SCORE_WORD_Y + 12, ".", color); - mText->writeShadowed(PLAY_AREA_CENTER_X + 4, SCORE_WORD_Y + 12, std::to_string(mPlayer[0]->getScoreMultiplier()).substr(2, 1), color); - - // STAGE - mText->writeCentered(PLAY_AREA_CENTER_FIRST_QUARTER_X, SCORE_NUMBER_Y + 4, mLang->getText(42) + std::to_string(mStage[mCurrentStage].number), 0); - - // POWER - mSpritePowerMeter->setSpriteClip(256, 184, 40, 8); - mSpritePowerMeter->render(); - const float percent = (mStage[mCurrentStage].currentPower * 40.0f) / mStage[mCurrentStage].powerToComplete; - mSpritePowerMeter->setSpriteClip(296, 184, (int)percent, 8); - mSpritePowerMeter->render(); - */ const int offset1 = 162; const int offset2 = offset1 + 7; const int offset3 = offset2 + 7; @@ -1801,8 +1761,6 @@ void Game::updateDeath() if (allAreDead) { - //JA_StopMusic(); - if (mDeathCounter > 0) { mDeathCounter--; @@ -2244,7 +2202,6 @@ void Game::checkBulletBalloonCollision() int index = mBullet[j]->getOwner(); mPlayer[index]->incScoreMultiplier(); mPlayer[index]->addScore(Uint32(mBalloon[i]->getScore() * mPlayer[index]->getScoreMultiplier() * mDifficultyScoreMultiplier)); - //setScore(mPlayer[index]->getScore()); updateHiScore(); // Explota el globo @@ -2281,7 +2238,7 @@ void Game::moveBullets() { for (int i = 0; i < MAX_BULLETS; i++) if (mBullet[i]->isActive()) - if (mBullet[i]->move() == MSG_BULLET_OUT) + if (mBullet[i]->move() == BULLET_MOVE_OUT) mPlayer[mBullet[i]->getOwner()]->decScoreMultiplier(); } @@ -2357,11 +2314,6 @@ void Game::resetItems() // Devuelve un item en función del azar Uint8 Game::dropItem() { - //if (mPlayer[0]->isPowerUp() || (mCoffeeMachineEnabled)) - // return NO_KIND; - //else - // return ITEM_COFFEE_MACHINE; - const Uint8 luckyNumber = rand() % 100; const Uint8 item = rand() % 6; @@ -2426,6 +2378,7 @@ void Game::createItemScoreSprite(int x, int y, SmartSprite *sprite) { const Uint8 index = getSmartSpriteFreeIndex(); + // Crea una copia del objeto *mSmartSprite[index] = *sprite; mSmartSprite[index]->setPosX(x); mSmartSprite[index]->setPosY(y); @@ -2842,12 +2795,12 @@ void Game::checkGameInput() mPlayer[index]->setInput(INPUT_RIGHT); if (mDemo.dataFile[mDemo.counter].noInput == 1) - mPlayer[index]->setInput(NO_INPUT); + mPlayer[index]->setInput(INPUT_NULL); if (mDemo.dataFile[mDemo.counter].fire == 1) if (mPlayer[index]->canFire()) { - mPlayer[index]->setInput(INPUT_FIRE_UP); + mPlayer[index]->setInput(INPUT_BUTTON_2); createBullet(mPlayer[index]->getPosX() + (mPlayer[index]->getWidth() / 2) - 4, mPlayer[index]->getPosY() + (mPlayer[index]->getHeight() / 2), BULLET_UP, mPlayer[index]->isPowerUp(), index); mPlayer[index]->setFireCooldown(10); } @@ -2855,7 +2808,7 @@ void Game::checkGameInput() if (mDemo.dataFile[mDemo.counter].fireLeft == 1) if (mPlayer[index]->canFire()) { - mPlayer[index]->setInput(INPUT_FIRE_LEFT); + mPlayer[index]->setInput(INPUT_BUTTON_1); createBullet(mPlayer[index]->getPosX() + (mPlayer[index]->getWidth() / 2) - 4, mPlayer[index]->getPosY() + (mPlayer[index]->getHeight() / 2), BULLET_UP, mPlayer[index]->isPowerUp(), index); mPlayer[index]->setFireCooldown(10); } @@ -2863,7 +2816,7 @@ void Game::checkGameInput() if (mDemo.dataFile[mDemo.counter].fireRight == 1) if (mPlayer[index]->canFire()) { - mPlayer[index]->setInput(INPUT_FIRE_RIGHT); + mPlayer[index]->setInput(INPUT_BUTTON_3); createBullet(mPlayer[index]->getPosX() + (mPlayer[index]->getWidth() / 2) - 4, mPlayer[index]->getPosY() + (mPlayer[index]->getHeight() / 2), BULLET_UP, mPlayer[index]->isPowerUp(), index); mPlayer[index]->setFireCooldown(10); } @@ -2900,7 +2853,7 @@ void Game::checkGameInput() else { // Ninguno de los dos inputs anteriores - mPlayer[i]->setInput(NO_INPUT); + mPlayer[i]->setInput(INPUT_NULL); mDemo.keys.noInput = 1; } } @@ -2909,7 +2862,7 @@ void Game::checkGameInput() { if (mPlayer[i]->canFire()) { - mPlayer[i]->setInput(INPUT_FIRE_UP); + mPlayer[i]->setInput(INPUT_BUTTON_2); createBullet(mPlayer[i]->getPosX() + (mPlayer[i]->getWidth() / 2) - 4, mPlayer[i]->getPosY() + (mPlayer[i]->getHeight() / 2), BULLET_UP, mPlayer[i]->isPowerUp(), i); mPlayer[i]->setFireCooldown(10); @@ -2925,7 +2878,7 @@ void Game::checkGameInput() { if (mPlayer[i]->canFire()) { - mPlayer[i]->setInput(INPUT_FIRE_LEFT); + mPlayer[i]->setInput(INPUT_BUTTON_1); createBullet(mPlayer[i]->getPosX() + (mPlayer[i]->getWidth() / 2) - 4, mPlayer[i]->getPosY() + (mPlayer[i]->getHeight() / 2), BULLET_LEFT, mPlayer[i]->isPowerUp(), i); mPlayer[i]->setFireCooldown(10); @@ -2941,7 +2894,7 @@ void Game::checkGameInput() { if (mPlayer[i]->canFire()) { - mPlayer[i]->setInput(INPUT_FIRE_RIGHT); + mPlayer[i]->setInput(INPUT_BUTTON_3); createBullet(mPlayer[i]->getPosX() + (mPlayer[i]->getWidth() / 2) - 4, mPlayer[i]->getPosY() + (mPlayer[i]->getHeight() / 2), BULLET_RIGHT, mPlayer[i]->isPowerUp(), i); mPlayer[i]->setFireCooldown(10); @@ -2981,10 +2934,6 @@ void Game::renderMessages() if ((mCounter < STAGE_COUNTER) && (!mDemo.enabled)) { mSpriteGetReady->setPosX((int)mGetReadyBitmapPath[mCounter]); - //mSpriteGetReady->render(); - //const color_t color = {0x17, 0x17, 0x26}; - //mTextBig->writeShadowed((int)mGetReadyBitmapPath[mCounter], PLAY_AREA_CENTER_Y - 8, mLang->getText(75), color, 2); - //mTextBig->writeDX(TXT_STROKE, (int)mGetReadyBitmapPath[mCounter], PLAY_AREA_CENTER_Y - 8, mLang->getText(75), 1, noColor, 1, shdwTxtColor); mTextNokiaBig2->write((int)mGetReadyBitmapPath[mCounter], PLAY_AREA_CENTER_Y - 8, mLang->getText(75), -2); } @@ -2992,11 +2941,7 @@ void Game::renderMessages() if (mTimeStopped) { if ((mTimeStoppedCounter > 100) || (mTimeStoppedCounter % 10 > 4)) - mTextNokia2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(36) + std::to_string(mTimeStoppedCounter / 10), -1, noColor, 1, shdwTxtColor); - //{ - // mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(36), -2); - // mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y + mTextNokiaBig2->getCharacterWidth() + 2, std::to_string(mTimeStoppedCounter / 10), -2); - //} + mTextNokia2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(36) + std::to_string(mTimeStoppedCounter / 10), -1, noColor, 1, shdwTxtColor); if (mTimeStoppedCounter > 100) { @@ -3027,7 +2972,7 @@ void Game::renderMessages() { // Texto de juego completado text = mLang->getText(50); mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], text, -2, noColor, 1, shdwTxtColor); - mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter] + mTextNokiaBig2->getCharacterWidth() + 2, mLang->getText(76), -1, noColor, 1, shdwTxtColor); + mTextNokia2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter] + mTextNokiaBig2->getCharacterWidth() + 2, mLang->getText(76), -1, noColor, 1, shdwTxtColor); } } } @@ -3197,13 +3142,7 @@ void Game::runPausedGame() } } - // Dibuja los objetos - //renderBackground(); - //renderBalloons(); - //renderBullets(); - //for (int i = 0; i < mNumPlayers; i++) - // mPlayer[i]->render(); - //renderScoreBoard(); + // Pinta el escenario renderPlayField(); mMenuPause->render(); mFade->render(); @@ -3218,7 +3157,6 @@ void Game::runPausedGame() switch (mMenuPause->getItemSelected()) { case 0: - //mMenuPause->reset(); mSection.name = PROG_SECTION_GAME; if (mNumPlayers == 1) mSection.subsection = GAME_SECTION_PLAY_1P; @@ -3229,7 +3167,6 @@ void Game::runPausedGame() break; case 1: - //mMenuPause->reset(); mFade->setFadeType(FADE_CENTER); mFade->activateFade(); break; @@ -3346,13 +3283,9 @@ void Game::runGameOverScreen() void Game::renderDebugInfo() { const color_t color = {0xFF, 0x20, 0x20}; - //mText->writeShadowed(2, 2 + 0 * BLOCK, "POW: " + std::to_string(mPlayer[0]->mPowerUpCounter), color); - //if (mHelper.needCoffeeMachine) - // mText->writeShadowed(2, 2 + 1 * BLOCK, "NEED COFFEMACHINE", color); if (mDebug.enabled) { - //SDL_RenderSetLogicalSize(mRenderer, SCREEN_WIDTH * 2, SCREEN_HEIGHT * 2); mText->writeShadowed(2, 2 + 0 * BLOCK, "menace(umb): " + std::to_string(mMenaceCurrent) + "(" + std::to_string(mMenaceThreshold) + ")", color); mText->writeShadowed(2, 2 + 1 * BLOCK, "currentPower: " + std::to_string(mStage[mCurrentStage].currentPower), color); mText->writeShadowed(2, 2 + 2 * BLOCK, "mCurrentStage:" + std::to_string(mCurrentStage), color); @@ -3451,19 +3384,21 @@ void Game::updateGameCompleted() // Actualiza las variables de ayuda void Game::updateHelper() { - // El ayudante solo funciona para un jugador - // Solo ofrece ayuda cuando la amenaza o la velocidad es elevada + // Solo ofrece ayuda cuando la amenaza es elevada if (mMenaceCurrent > 15) { - if (mPlayer[0]->getCoffees() == 0) - mHelper.needCoffee = true; - else - mHelper.needCoffee = false; + for (int i = 0; i < mNumPlayers; i++) + { + if (mPlayer[i]->getCoffees() == 0) + mHelper.needCoffee = true; + else + mHelper.needCoffee = false; - if (!mPlayer[0]->isPowerUp()) - mHelper.needCoffeeMachine = true; - else - mHelper.needCoffeeMachine = false; + if (!mPlayer[i]->isPowerUp()) + mHelper.needCoffeeMachine = true; + else + mHelper.needCoffeeMachine = false; + } } else { diff --git a/source/game.h b/source/game.h index 9e8a16f..3aeb414 100644 --- a/source/game.h +++ b/source/game.h @@ -22,7 +22,43 @@ #ifndef GAME_H #define GAME_H -// Game +// Cantidad de elementos a escribir en los ficheros de datos +#define TOTAL_SCORE_DATA 3 +#define TOTAL_DEMO_DATA 2000 + +// Contadores +#define STAGE_COUNTER 200 +#define SHAKE_COUNTER 10 +#define HELP_COUNTER 1000 + +// Formaciones enemigas +#define NUMBER_OF_ENEMY_FORMATIONS 100 +#define MAX_NUMBER_OF_ENEMIES_IN_A_FORMATION 50 + +// Cantidad de elementos del vector de SmartSprites +#define MAX_SMART_SPRITES 10 + +// Cantidad máxima posible de balas +#define MAX_BULLETS 50 + +// Porcentaje de aparición de los objetos +#define ITEM_POINTS_1_DISK_ODDS 10 +#define ITEM_POINTS_2_GAVINA_ODDS 6 +#define ITEM_POINTS_3_PACMAR_ODDS 3 +#define ITEM_CLOCK_ODDS 5 +#define ITEM_COFFEE_ODDS 5 +#define ITEM_POWER_BALL_ODDS 0 +#define ITEM_COFFEE_MACHINE_ODDS 4 + +// Cantidad de objetos simultaneos +#define MAX_ITEMS 10 + +// Valores para las variables asociadas a los objetos +#define REMAINING_EXPLOSIONS 3 +#define REMAINING_EXPLOSIONS_COUNTER 50 +#define TIME_STOPPED_COUNTER 300 + +// Clase Game class Game { private: diff --git a/source/ifdefs.h b/source/ifdefs.h index d5a071e..ee12c82 100644 --- a/source/ifdefs.h +++ b/source/ifdefs.h @@ -1,15 +1,4 @@ -#ifdef _WIN64 -#include "C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\SDL2\SDL.h" -#endif - -#ifdef _WIN32 -#include "C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\SDL2\SDL.h" -#endif - -#ifdef __APPLE__ -//#include "/Library/Frameworks/SDL2.framework/Versions/A/Headers/SDL.h" #include -#endif #ifdef __linux__ #ifdef __MIPSEL__ diff --git a/source/input.cpp b/source/input.cpp index dc8b705..9ebb704 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -1,9 +1,6 @@ #include "input.h" #include -// Contestar cuantos joystics ha detectado -// Preguntarlepor los joystics que ha encontrado para ir poniendolos en la variable de opciones - // Constructor Input::Input(std::string file) { diff --git a/source/input.h b/source/input.h index bea512b..13dafa2 100644 --- a/source/input.h +++ b/source/input.h @@ -49,11 +49,10 @@ private: }; GameControllerBindings_t mGameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos - //SDL_GameController *mGameController; // Manejador para el mando - std::vector mConnectedControllers; - std::vector mControllerNames; - int mNumGamepads; - std::string mDBpath; // Ruta al archivo gamecontrollerdb.txt + std::vector mConnectedControllers; // Vector con todos los mandos conectados + std::vector mControllerNames; // Vector con los nombres de los mandos + int mNumGamepads; // Numero de mandos conectados + std::string mDBpath; // Ruta al archivo gamecontrollerdb.txt // Comprueba si hay un mando conectado bool discoverGameController(); @@ -72,7 +71,7 @@ public: void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button); // Comprueba si un input esta activo - bool checkInput(Uint8 input, bool repeat, int device=INPUT_USE_ANY, int index=0); + bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0); // Comprueba si hay algun mando conectado bool gameControllerFound(); diff --git a/source/instructions.h b/source/instructions.h index b3cc7b1..bd584c4 100644 --- a/source/instructions.h +++ b/source/instructions.h @@ -10,7 +10,14 @@ #ifndef INSTRUCTIONS_H #define INSTRUCTIONS_H -// Instructions +// Contadores +#define INSTRUCTIONS_COUNTER 600 + +// Modo para las instrucciones +#define INSTRUCTIONS_MODE_MANUAL 0 +#define INSTRUCTIONS_MODE_AUTO 1 + +// Clase Instructions class Instructions { private: diff --git a/source/intro.cpp b/source/intro.cpp index c6db912..4e51690 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -181,9 +181,7 @@ void Intro::init() mWriter[8]->setSpeed(20); for (int i = 0; i < INTRO_TOTAL_TEXTS; i++) - { mWriter[i]->center(SCREEN_CENTER_X); - } } // Carga los recursos @@ -208,10 +206,7 @@ section_t Intro::run() // Si la música no está sonando if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED)) - { - // Reproduce la música - JA_PlayMusic(mMusic, 0); - } + JA_PlayMusic(mMusic, 0); // Reproduce la música while (mSection.name == PROG_SECTION_INTRO) { diff --git a/source/intro.h b/source/intro.h index 257e573..716ed5b 100644 --- a/source/intro.h +++ b/source/intro.h @@ -10,7 +10,29 @@ #ifndef INTRO_H #define INTRO_H -// Intro +// Cantidad de eventos de la intro +#define INTRO_TOTAL_BITMAPS 6 +#define INTRO_TOTAL_TEXTS 9 +const int INTRO_TOTAL_EVENTS = INTRO_TOTAL_BITMAPS + INTRO_TOTAL_TEXTS; + +// Relaciones de Id con nombres +#define BITMAP0 0 +#define BITMAP1 1 +#define BITMAP2 2 +#define BITMAP3 3 +#define BITMAP4 4 +#define BITMAP5 5 +#define TEXT0 6 +#define TEXT1 7 +#define TEXT2 8 +#define TEXT3 9 +#define TEXT4 10 +#define TEXT5 11 +#define TEXT6 12 +#define TEXT7 13 +#define TEXT8 14 + +// Clase Intro class Intro { private: diff --git a/source/item.cpp b/source/item.cpp index 141cbdf..73d78dd 100644 --- a/source/item.cpp +++ b/source/item.cpp @@ -1,6 +1,5 @@ #include "const.h" #include "item.h" -#include // Constructor Item::Item() diff --git a/source/item.h b/source/item.h index 0084c87..4515cac 100644 --- a/source/item.h +++ b/source/item.h @@ -6,7 +6,16 @@ #ifndef ITEM_H #define ITEM_H -// Clase AnimatedSprite +// Tipos de objetos +#define ITEM_POINTS_1_DISK 1 +#define ITEM_POINTS_2_GAVINA 2 +#define ITEM_POINTS_3_PACMAR 3 +#define ITEM_CLOCK 4 +#define ITEM_COFFEE 5 +#define ITEM_POWER_BALL 6 +#define ITEM_COFFEE_MACHINE 7 + +// Clase Item class Item { private: diff --git a/source/lang.h b/source/lang.h index 228e1c9..a57ab99 100644 --- a/source/lang.h +++ b/source/lang.h @@ -5,7 +5,7 @@ #ifndef LANG_H #define LANG_H -// Lang codes +// Códigos de idioma #define es_ES 0 #define ba_BA 1 #define en_UK 2 @@ -18,15 +18,15 @@ class Lang { private: - std::string *mFileList; // Lista de ficheros con los recursos - std::string mTextStrings[MAX_TEXT_STRINGS]; + std::string *mFileList; // Lista de ficheros con los recursos + std::string mTextStrings[MAX_TEXT_STRINGS]; // Vector con los textos public: - // Constructor - Lang(std::string *fileList); + // Constructor + Lang(std::string *fileList); - // Destructor - ~Lang(); + // Destructor + ~Lang(); // Inicializa los textos del juego en el idioma seleccionado bool setLang(Uint8 lang); diff --git a/source/logo.h b/source/logo.h index 0d81f74..0de698c 100644 --- a/source/logo.h +++ b/source/logo.h @@ -9,7 +9,7 @@ #ifndef LOGO_H #define LOGO_H -// Logo +// Clase Logo class Logo { private: diff --git a/source/menu.cpp b/source/menu.cpp index c8deee5..2dbc492 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -227,26 +227,15 @@ bool Menu::increaseSelectorIndex() mSelector.h = mSelector.originH = getSelectorHeight(mSelector.index); // Calcula cual es el siguiente elemento - //if (mSelector.index < (mTotalItems - 1)) - //{ - // mSelector.index++; - // while ((!mItem[mSelector.index].selectable) && (mSelector.index < (mTotalItems - 1))) - // mSelector.index++; - // success = true; - //} - - // Calcula cual es el siguiente elemento (versión con loop) - //if (mSelector.index < (mTotalItems - 1)) - { + ++mSelector.index %= mTotalItems; + while (!mItem[mSelector.index].selectable) + //mSelector.index++; ++mSelector.index %= mTotalItems; - while (!mItem[mSelector.index].selectable) - //mSelector.index++; - ++mSelector.index %= mTotalItems; - success = true; - } + success = true; + // Establece las coordenadas y altura de destino if (success) - { // Establece las coordenadas y altura de destino + { mSelector.targetY = mItem[mSelector.index].rect.y; mSelector.despY = (mSelector.targetY - mSelector.originY) / mSelector.numJumps; @@ -271,33 +260,22 @@ bool Menu::decreaseSelectorIndex() mSelector.h = mSelector.originH = getSelectorHeight(mSelector.index); // Calcula cual es el siguiente elemento - //if (mSelector.index > 0) - //{ - // mSelector.index--; - // while ((!mItem[mSelector.index].selectable) && (mSelector.index > 0)) - // mSelector.index--; - // success = true; - //} - - // Calcula cual es el siguiente elemento (versión con loop) - //if (mSelector.index > 0) + if (mSelector.index == 0) + mSelector.index = mTotalItems; + else + mSelector.index--; + while (!mItem[mSelector.index].selectable) { if (mSelector.index == 0) mSelector.index = mTotalItems; else mSelector.index--; - while (!mItem[mSelector.index].selectable) - { - if (mSelector.index == 0) - mSelector.index = mTotalItems; - else - mSelector.index--; - } - success = true; } + success = true; + // Establece las coordenadas y altura de destino if (success) - { // Establece las coordenadas y altura de destino + { mSelector.targetY = mItem[mSelector.index].rect.y; mSelector.despY = (mSelector.targetY - mSelector.originY) / mSelector.numJumps; @@ -370,10 +348,6 @@ void Menu::render() mText->write(mItem[i].rect.x, mItem[i].rect.y, mItem[i].label); } } - - //borrar - //mText->write(0, 0, std::to_string(mSelector.h) + " " + std::to_string(mSelector.incH) + " " + std::to_string(mSelector.resizing)); - //mText->write(0, 8, std::to_string(mSelector.y) + " " + std::to_string(mSelector.despY) + " " + std::to_string(mSelector.moving)); } } @@ -433,9 +407,6 @@ void Menu::centerMenuOnX(int value) mIsCenteredOnX = true; mCenterX = value; - // Actualiza el rectangulo de fondo para recalcular las dimensiones - //setRectSize(); - // Establece la nueva posición centrada en funcion del elemento más ancho mPosX = (value) - (findWidth() / 2); @@ -453,9 +424,6 @@ void Menu::centerMenuOnY(int value) mIsCenteredOnY = true; mCenterY = value; - // Actualiza el rectangulo de fondo para recalcular las dimensiones - //setRectSize(); - // Establece la nueva posición centrada en funcion del elemento más ancho mPosY = (value) - (findHeight() / 2); @@ -497,7 +465,6 @@ void Menu::addItem(std::string text, Uint8 hPaddingDown, bool selectable, bool g setTotalItems(mTotalItems + 1); mCenterX = mPosX + (findWidth() / 2); - //setSelectorPos(0); reorganize(); } @@ -520,16 +487,12 @@ void Menu::setDefaultActionWhenCancel(Uint8 item) void Menu::checkInput() { if (mInput->checkInput(INPUT_UP, REPEAT_FALSE)) - { if (decreaseSelectorIndex()) JA_PlaySound(mSoundMove); - } if (mInput->checkInput(INPUT_DOWN, REPEAT_FALSE)) - { if (increaseSelectorIndex()) JA_PlaySound(mSoundMove); - } if (mInput->checkInput(INPUT_ACCEPT, REPEAT_FALSE)) { diff --git a/source/menu.h b/source/menu.h index 6843919..3b2c477 100644 --- a/source/menu.h +++ b/source/menu.h @@ -8,9 +8,17 @@ #ifndef MENU_H #define MENU_H +// Cantidad máxima de items en el menu #define MENU_MAX_ITEMS 50 -// Clase menu +// Tipos de fondos para el menu +#define MENU_BACKGROUND_TRANSPARENT 0 +#define MENU_BACKGROUND_SOLID 1 + +// Opciones de menu +#define MENU_NO_OPTION -1 + +// Clase Menu class Menu { private: diff --git a/source/player.cpp b/source/player.cpp index 66f2873..0dccb37 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -262,15 +262,15 @@ void Player::setInput(Uint8 input) setWalkingStatus(PLAYER_STATUS_WALKING_RIGHT); break; - case INPUT_FIRE_UP: + case INPUT_BUTTON_2: setFiringStatus(PLAYER_STATUS_FIRING_UP); break; - case INPUT_FIRE_LEFT: + case INPUT_BUTTON_1: setFiringStatus(PLAYER_STATUS_FIRING_LEFT); break; - case INPUT_FIRE_RIGHT: + case INPUT_BUTTON_3: setFiringStatus(PLAYER_STATUS_FIRING_RIGHT); break; @@ -291,10 +291,7 @@ void Player::move() // Si el jugador abandona el area de juego por los laterales if ((mPosX < PLAY_AREA_LEFT - 5) || (mPosX + mWidth > PLAY_AREA_RIGHT + 5)) - { - // Restaura su posición - mPosX -= mVelX; - } + mPosX -= mVelX; // Restaura su posición // Actualiza la posición del sprite mSpriteLegs->setPosX(getPosX()); @@ -509,13 +506,9 @@ bool Player::canFire() { // Si el contador a llegado a cero, podemos disparar. En caso contrario decrementamos el contador if (mCooldown > 0) - { return false; - } else - { return true; - } } // Establece el valor de la variable diff --git a/source/player.h b/source/player.h index cedee4e..1c1f5fa 100644 --- a/source/player.h +++ b/source/player.h @@ -6,7 +6,42 @@ #ifndef PLAYER_H #define PLAYER_H -// The player +// Contadores +#define DEATH_COUNTER 350 + +// Estados del jugador +#define PLAYER_STATUS_WALKING_LEFT 0 +#define PLAYER_STATUS_WALKING_RIGHT 1 +#define PLAYER_STATUS_WALKING_STOP 2 + +#define PLAYER_STATUS_FIRING_UP 0 +#define PLAYER_STATUS_FIRING_LEFT 1 +#define PLAYER_STATUS_FIRING_RIGHT 2 +#define PLAYER_STATUS_FIRING_NO 3 + +#define PLAYER_ANIMATION_LEGS_WALKING_RIGHT 1 +#define PLAYER_ANIMATION_LEGS_WALKING_STOP 2 + +#define PLAYER_ANIMATION_BODY_WALKING_LEFT 0 +#define PLAYER_ANIMATION_BODY_FIRING_LEFT 1 +#define PLAYER_ANIMATION_BODY_WALKING_RIGHT 2 +#define PLAYER_ANIMATION_BODY_FIRING_RIGHT 3 +#define PLAYER_ANIMATION_BODY_WALKING_STOP 4 +#define PLAYER_ANIMATION_BODY_FIRING_UP 5 + +#define PLAYER_ANIMATION_HEAD_WALKING_LEFT 0 +#define PLAYER_ANIMATION_HEAD_FIRING_LEFT 1 +#define PLAYER_ANIMATION_HEAD_WALKING_RIGHT 2 +#define PLAYER_ANIMATION_HEAD_FIRING_RIGHT 3 +#define PLAYER_ANIMATION_HEAD_WALKING_STOP 4 +#define PLAYER_ANIMATION_HEAD_FIRING_UP 5 +#define PLAYER_ANIMATION_LEGS_WALKING_LEFT 0 + +// Variables del jugador +#define PLAYER_INVULNERABLE_COUNTER 200 +#define PLAYER_POWERUP_COUNTER 1500 + +// Clase Player class Player { private: diff --git a/source/smartsprite.cpp b/source/smartsprite.cpp index c88f02f..c316246 100644 --- a/source/smartsprite.cpp +++ b/source/smartsprite.cpp @@ -4,13 +4,11 @@ // Constructor SmartSprite::SmartSprite() { - //init(nullptr, nullptr); } // Destructor SmartSprite::~SmartSprite() { - //init(nullptr, nullptr); } // Inicializador @@ -114,7 +112,7 @@ bool SmartSprite::update() // Comprueba si se desplaza en el eje X hacia la derecha if ((getAccelX() > 0) || ((getAccelX() == 0) && (getVelX() > 0))) { - // Comprueba si hemos llegado al destino + // Comprueba si ha llegado al destino if (getPosX() > mDestX) { // Lo coloca en posición @@ -128,7 +126,7 @@ bool SmartSprite::update() // Comprueba si se desplaza en el eje X hacia la izquierda else if ((getAccelX() < 0) || ((getAccelX() == 0) && (getVelX() < 0))) { - // Comprueba si hemos llegado al destino + // Comprueba si ha llegado al destino if (getPosX() < mDestX) { // Lo coloca en posición @@ -143,7 +141,7 @@ bool SmartSprite::update() // Comprueba si se desplaza en el eje Y hacia abajo if ((getAccelY() > 0) || ((getAccelY() == 0) && (getVelY() > 0))) { - // Comprueba si hemos llegado al destino + // Comprueba si ha llegado al destino if (getPosY() > mDestY) { // Lo coloca en posición @@ -157,7 +155,7 @@ bool SmartSprite::update() // Comprueba si se desplaza en el eje Y hacia arriba else if ((getAccelY() < 0) || ((getAccelY() == 0) && (getVelY() < 0))) { - // Comprueba si hemos llegado al destino + // Comprueba si ha llegado al destino if (getPosY() < mDestY) { // Lo coloca en posición @@ -171,13 +169,9 @@ bool SmartSprite::update() // Comprueba si ha llegado a su destino if ((getPosX() == mDestX) && (getPosY() == mDestY)) - { mIsOnDestination = true; - } else - { mIsOnDestination = false; - } // Si esta en el destino comprueba su contador if (mIsOnDestination) @@ -185,7 +179,7 @@ bool SmartSprite::update() // Si el contador es mayor que cero, lo decrementa if (mEnabledCounter > 0) { - --mEnabledCounter; + mEnabledCounter--; } // Si ha llegado a cero, deshabilita el objeto o manda el aviso en función de si tiene Id else if (mEnabledCounter == 0) @@ -215,9 +209,7 @@ bool SmartSprite::isOnDestination() void SmartSprite::render() { if (mEnabled) - { MovingSprite::render(); - } } // Establece el valor de la variable diff --git a/source/text.h b/source/text.h index e74b9db..ccadef2 100644 --- a/source/text.h +++ b/source/text.h @@ -10,7 +10,7 @@ #define TXT_CENTER 4 #define TXT_STROKE 8 -// Clase texto. Pinta texto en pantalla a partir de un bitmap +// Clase Text. Pinta texto en pantalla a partir de una cadena y un bitmap class Text { private: @@ -18,9 +18,9 @@ private: struct Offset { - int x; - int y; - Uint8 w; + int x; // Posición en el eje X dentro del bitmap + int y; // Posición en el eje Y dentro del bitmap + Uint8 w; // Ancho en pixeles de la letra }; Offset mOffset[128]; // Vector con las posiciones y ancho de cada letra diff --git a/source/title.cpp b/source/title.cpp index e1e96c3..d3eacda 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -33,6 +33,7 @@ Title::Title(SDL_Window *window, SDL_Renderer *renderer, Input *input, std::stri mMenu.title = new Menu(mRenderer, mText, mInput, mFileList); mMenu.options = new Menu(mRenderer, mText, mInput, mFileList); + // Crea la textura para el mosaico de fondo mBackground = SDL_CreateTexture(mRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, SCREEN_WIDTH * 2, SCREEN_HEIGHT * 2); if (mBackground == NULL) printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError()); @@ -136,22 +137,23 @@ void Title::init(bool demo, Uint8 subsection) mFade->init(0x17, 0x17, 0x26); mDemo = demo; - //if (!mInput->gameControllerFound()) - { - mOptions->input[0].id = 0; - mOptions->input[0].name = "KEYBOARD"; - mOptions->input[0].deviceType = INPUT_USE_KEYBOARD; + // Pone valores por defecto a las opciones de control + mOptions->input[0].id = 0; + mOptions->input[0].name = "KEYBOARD"; + mOptions->input[0].deviceType = INPUT_USE_KEYBOARD; - mOptions->input[1].id = 0; - mOptions->input[1].name = "GAME CONTROLLER"; - mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER; - } + mOptions->input[1].id = 0; + mOptions->input[1].name = "GAME CONTROLLER"; + mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER; + // Comprueba si hay mandos conectados checkInputDevices(); - mDeviceIndex[0] = mAvailableInputDevices.size() - 1; - mDeviceIndex[1] = 0; + // Pone valores por defecto + mDeviceIndex[0] = mAvailableInputDevices.size() - 1; // El último dispositivo encontrado es el teclado + mDeviceIndex[1] = 0; // El primer mando encontrado. Si no ha encontrado ninguno es el teclado + // Si ha encontrado un mando se lo asigna al segundo jugador if (mInput->gameControllerFound()) { mOptions->input[1].id = mAvailableInputDevices[mDeviceIndex[1]].id; @@ -244,6 +246,7 @@ void Title::init(bool demo, Uint8 subsection) // Crea el mosaico de fondo del titulo createTiledBackground(); + // Coloca la ventana que recorre el mosaico de fondo de manera que coincida con el mosaico que hay pintado en el titulo al iniciar mBackgroundWindow.x = 128; mBackgroundWindow.y = 96; mBackgroundWindow.w = SCREEN_WIDTH; @@ -251,9 +254,7 @@ void Title::init(bool demo, Uint8 subsection) // Inicializa los valores del vector con los valores del seno for (int i = 0; i < 360; i++) - { mSin[i] = SDL_sinf((float)i * 3.14f / 180.0f); - } // Inicializa los objetos de menu mMenu.title->init("TITLE", 0, (14 * BLOCK) + 4, MENU_BACKGROUND_TRANSPARENT); @@ -380,7 +381,6 @@ void Title::updateMenuLabels() else { mMenu.options->setGreyed(i, false); - //mMenu.options->setItemCaption(i, mInput->getControllerName(0)); mMenu.options->setItemCaption(i, mOptions->input[0].name); } break; @@ -410,7 +410,6 @@ void Title::updateMenuLabels() else { mMenu.options->setGreyed(i, false); - //mMenu.options->setItemCaption(i, mInput->getControllerName(0)); mMenu.options->setItemCaption(i, mOptions->input[1].name); } break; @@ -496,15 +495,18 @@ void Title::updateMenuLabels() // CANCEL mMenu.options->setItemCaption(i, mLang->getText(10)); // CANCEL + // Recoloca el menu de opciones mMenu.options->centerMenuOnX(SCREEN_CENTER_X); mMenu.options->centerMenuOnY(SCREEN_CENTER_Y); mMenu.options->centerMenuElementsOnX(); + // Establece las etiquetas del menu de titulo mMenu.title->setItemCaption(0, mLang->getText(51)); // 1 PLAYER mMenu.title->setItemCaption(1, mLang->getText(52)); // 2 PLAYERS mMenu.title->setItemCaption(2, mLang->getText(1)); // OPTIONS mMenu.title->setItemCaption(3, mLang->getText(3)); // QUIT + // Recoloca el menu de titulo mMenu.title->centerMenuOnX(SCREEN_CENTER_X); mMenu.title->centerMenuElementsOnX(); } @@ -655,10 +657,7 @@ section_t Title::run(Uint8 subsection) // Si la música no está sonando if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED)) - { - // Reproduce la música - JA_PlayMusic(mMusic); - } + JA_PlayMusic(mMusic); // Reproduce la música // Calcula la lógica de los objetos if (SDL_GetTicks() - mTicks > mTicksSpeed) @@ -842,9 +841,7 @@ section_t Title::run(Uint8 subsection) } if (mMenu.active->getName() == "TITLE") - { mCounter--; - } } // Limpia la pantalla @@ -949,29 +946,23 @@ bool Title::updatePlayerInputs(int numPlayer) } else // Si hay mas de un dispositivo, se recorre el vector { - printf("numplayer:%i\n",numPlayer); - printf("deviceindex:%i\n",mDeviceIndex[numPlayer]); + printf("numplayer:%i\n", numPlayer); + printf("deviceindex:%i\n", mDeviceIndex[numPlayer]); // Incrementa el indice if (mDeviceIndex[numPlayer] < numDevices - 1) mDeviceIndex[numPlayer]++; else mDeviceIndex[numPlayer] = 0; - printf("deviceindex:%i\n",mDeviceIndex[numPlayer]); + printf("deviceindex:%i\n", mDeviceIndex[numPlayer]); // Si coincide con el del otro jugador, se lo intercambian if (mDeviceIndex[0] == mDeviceIndex[1]) { - printf("%i:%i\n",mDeviceIndex[0],mDeviceIndex[1]); - - //const int temp = mDeviceIndex[0]; - //mDeviceIndex[0] = mDeviceIndex[1]; - //mDeviceIndex[1] = temp; const int theOtherPlayer = (numPlayer + 1) % 2; mDeviceIndex[theOtherPlayer]--; if (mDeviceIndex[theOtherPlayer] < 0) - mDeviceIndex[theOtherPlayer]=numDevices-1; - printf("%i:%i\n",mDeviceIndex[0],mDeviceIndex[1]); + mDeviceIndex[theOtherPlayer] = numDevices - 1; } // Copia el dispositivo marcado por el indice a la variable de opciones de cada jugador diff --git a/source/title.h b/source/title.h index 7fa6d2f..55343c4 100644 --- a/source/title.h +++ b/source/title.h @@ -2,11 +2,9 @@ #include "ifdefs.h" #include "const.h" #include "utils.h" - #include "sprite.h" #include "movingsprite.h" #include "smartsprite.h" - #include "item.h" #include "text.h" #include "menu.h" @@ -19,7 +17,16 @@ #ifndef TITLE_H #define TITLE_H -// Title +// Textos +#define TEXT_COPYRIGHT "@2020,2021 JailDesigner (v2.0.2)" + +// Contadores +#define TITLE_COUNTER 800 + +// Cantidad de eventos de la pantalla de titulo +#define TITLE_TOTAL_EVENTS 2 + +// Clase Title class Title { private: diff --git a/source/utils.cpp b/source/utils.cpp index 2b28c40..5223501 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -17,10 +17,7 @@ bool checkCollision(circle_t &a, circle_t &b) // Si la distancia entre el centro de los circulos es inferior a la suma de sus radios if (distanceSquared(a.x, a.y, b.x, b.y) < (totalRadiusSquared)) - { - // Los circulos han colisionado - return true; - } + return true; // Los circulos han colisionado // En caso contrario return false; @@ -114,11 +111,11 @@ bool checkCollision(SDL_Rect &a, SDL_Rect &b) // Carga un archivo de imagen en una textura bool loadTextureFromFile(LTexture *texture, std::string path, SDL_Renderer *renderer) { - bool success = true; - if (!texture->loadFromFile(path, renderer)) - { - printf("Failed to load %s texture!\n", path.c_str()); - success = false; - } - return success; + bool success = true; + if (!texture->loadFromFile(path, renderer)) + { + printf("Failed to load %s texture!\n", path.c_str()); + success = false; + } + return success; } \ No newline at end of file diff --git a/source/utils.h b/source/utils.h index 6d25712..4b5191b 100644 --- a/source/utils.h +++ b/source/utils.h @@ -6,6 +6,15 @@ #ifndef UTILS_H #define UTILS_H +// Dificultad del juego +#define DIFFICULTY_EASY 0 +#define DIFFICULTY_NORMAL 1 +#define DIFFICULTY_HARD 2 + +// Tipo de filtro +#define FILTER_NEAREST 0 +#define FILTER_LINEAL 1 + // Estructura para definir un circulo struct circle_t { diff --git a/source/writer.cpp b/source/writer.cpp index ef9cfa7..2aaa3ec 100644 --- a/source/writer.cpp +++ b/source/writer.cpp @@ -134,9 +134,7 @@ void Writer::update() void Writer::render() { if (mEnabled) - { mText->write(mPosX, mPosY, mCaption, mKerning, mIndex); - } } // Centra la cadena de texto a un punto X diff --git a/source/writer.h b/source/writer.h index b3a4051..0027995 100644 --- a/source/writer.h +++ b/source/writer.h @@ -5,7 +5,7 @@ #ifndef WRITER_H #define WRITER_H -// Clase texto. Pinta texto en pantalla a partir de un bitmap +// Clase Writer. Pinta texto en pantalla a partir de una cadena y un bitmap class Writer { private: