diff --git a/source/bullet.cpp b/source/bullet.cpp index 0e2819c..2b9a992 100644 --- a/source/bullet.cpp +++ b/source/bullet.cpp @@ -78,6 +78,11 @@ void Bullet::init(int x, int y, int kind) break; default: + // Establece la velocidad inicial + mVelX = 0; + + // Rectangulo con los gráficos del objeto + mSprite.setSpriteClip(0 * mWidth, 0, mSprite.getWidth(), mSprite.getHeight()); break; } diff --git a/source/gamedirector.cpp b/source/gamedirector.cpp index f84aab9..bba080f 100644 --- a/source/gamedirector.cpp +++ b/source/gamedirector.cpp @@ -31,12 +31,14 @@ GameDirector::GameDirector(SDL_Renderer *gRenderer) { this->gRenderer = gRenderer; - for (Uint8 i = 0; i < mMaxBalloons; i++) + mMaxBalloons = 50; + for (int i = 0; i < mMaxBalloons; ++i) { balloon[i] = new Balloon(gRenderer); } - for (int i = 0; i < mMaxBullets; i++) + mMaxBullets = 50; + for (int i = 0; i < mMaxBullets; ++i) { bullet[i] = new Bullet(gRenderer); } @@ -75,12 +77,12 @@ GameDirector::~GameDirector() delete menuPause; delete menuTitle; - for (Uint8 i = 0; i < mMaxBalloons; i++) + for (int i = 0; i < mMaxBalloons; ++i) { delete balloon[i]; } - for (int i = 0; i < mMaxBullets; i++) + for (int i = 0; i < mMaxBullets; ++i) { delete bullet[i]; } @@ -172,8 +174,6 @@ void GameDirector::init() // Variables mGameStatus = GAME_STATE_TITLE; mOldTicks = 0; - mMaxBalloons = 50; - mMaxBullets = 50; mGameSpeed = 15; mMenaceLevel = 0; mMenaceLevelThreshold = 7; @@ -361,7 +361,7 @@ Uint8 GameDirector::createNewBalloon(int x, int y, Uint8 kind, float velx, Uint1 // Establece a cero todos los valores del vector de objetos globo void GameDirector::resetBalloons() { - for (Uint8 i = 0; i < mMaxBalloons; i++) + for (int i = 0; i < mMaxBalloons; ++i) { balloon[i]->erase(); } @@ -525,7 +525,7 @@ Uint8 GameDirector::getBulletFreeIndex() // Establece a cero todos los valores del vector de objetos bala void GameDirector::resetBullets() { - for (Uint8 i = 0; i < mMaxBullets; i++) + for (int i = 0; i < mMaxBullets; ++i) { bullet[i]->init(0, 0, NO_KIND); } @@ -542,7 +542,7 @@ void GameDirector::createBullet(int x, int y, Uint8 kind) void GameDirector::calculateMenaceLevel() { mMenaceLevel = 0; - for (Uint8 i = 0; i < mMaxBalloons; i++) + for (int i = 0; i < mMaxBalloons; ++i) { switch (balloon[i]->getKind()) { diff --git a/source/globals.h b/source/globals.h index d235988..a3f85fa 100644 --- a/source/globals.h +++ b/source/globals.h @@ -1,7 +1,7 @@ #pragma once #include -#include +//#include #include #ifndef GLOBALS_H diff --git a/source/main.cpp b/source/main.cpp index 5c4f5c9..f02642d 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -120,12 +120,12 @@ bool init() SDL_RenderSetLogicalSize(gRenderer, SCREEN_WIDTH, SCREEN_HEIGHT); // Inicializa el cargador de PNG - int imgFlags = IMG_INIT_PNG; + /*int imgFlags = IMG_INIT_PNG; if (!(IMG_Init(imgFlags) & imgFlags)) { printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError()); success = false; - } + }*/ } } } @@ -143,7 +143,7 @@ void close() gRenderer = NULL; // Sal del subsistema SDL - IMG_Quit(); + //IMG_Quit(); SDL_Quit(); } diff --git a/source/menu.cpp b/source/menu.cpp index 62d2858..879cbd3 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -12,7 +12,7 @@ Menu::Menu(SDL_Renderer *gRenderer) printf("Failed to load menu texture!\n"); } - init(0, 0, 0, MENU_BACKGROUND_SOLID); + //init(0, 0, 0, MENU_BACKGROUND_SOLID); } // Destructor @@ -50,9 +50,9 @@ void Menu::init(int x, int y, int offset_sprite_selector, int backgroundType) // Elementos del menu for (Uint8 i = 0; i < 10; i++) { - mMenuItem[i].label = ""; mMenuItem[i].x = mPosX; mMenuItem[i].y = mPosY + (i * (BLOCK + 2)); + mMenuItem[i].label = "s"; } // Mueve el grafico del selector al elemento seleccionado