Treballant en el enemic nou
This commit is contained in:
9
data/gfx/tabe/tabe.ani
Normal file
9
data/gfx/tabe/tabe.ani
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
frame_width=32
|
||||||
|
frame_height=32
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=default
|
||||||
|
speed=2
|
||||||
|
loop=0
|
||||||
|
frames=0,1
|
||||||
|
[/animation]
|
||||||
BIN
data/gfx/tabe/tabe.png
Normal file
BIN
data/gfx/tabe/tabe.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -451,6 +451,11 @@ void Director::setFileList()
|
|||||||
Asset::get()->add(prefix + "/data/gfx/bullet/bullet.png", AssetType::BITMAP);
|
Asset::get()->add(prefix + "/data/gfx/bullet/bullet.png", AssetType::BITMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ // Tabe
|
||||||
|
Asset::get()->add(prefix + "/data/gfx/tabe/tabe.png", AssetType::BITMAP);
|
||||||
|
Asset::get()->add(prefix + "/data/gfx/tabe/tabe.ani", AssetType::ANIMATION);
|
||||||
|
}
|
||||||
|
|
||||||
{ // Juego
|
{ // Juego
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_buildings.png", AssetType::BITMAP);
|
Asset::get()->add(prefix + "/data/gfx/game/game_buildings.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_clouds1.png", AssetType::BITMAP);
|
Asset::get()->add(prefix + "/data/gfx/game/game_clouds1.png", AssetType::BITMAP);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "section.h" // Para Name, name, Options, options
|
#include "section.h" // Para Name, name, Options, options
|
||||||
#include "smart_sprite.h" // Para SmartSprite
|
#include "smart_sprite.h" // Para SmartSprite
|
||||||
#include "stage.h" // Para number, get, Stage, power, total_p...
|
#include "stage.h" // Para number, get, Stage, power, total_p...
|
||||||
|
#include "tabe.h" // Para Tabe
|
||||||
#include "text.h" // Para Text
|
#include "text.h" // Para Text
|
||||||
#include "texture.h" // Para Texture
|
#include "texture.h" // Para Texture
|
||||||
struct JA_Sound_t; // lines 37-37
|
struct JA_Sound_t; // lines 37-37
|
||||||
@@ -46,7 +47,8 @@ Game::Game(int player_id, int current_stage, bool demo)
|
|||||||
canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.play_area.rect.w, param.game.play_area.rect.h)),
|
canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.play_area.rect.w, param.game.play_area.rect.h)),
|
||||||
fade_in_(std::make_unique<Fade>()),
|
fade_in_(std::make_unique<Fade>()),
|
||||||
fade_out_(std::make_unique<Fade>()),
|
fade_out_(std::make_unique<Fade>()),
|
||||||
balloon_manager_(std::make_unique<BalloonManager>())
|
balloon_manager_(std::make_unique<BalloonManager>()),
|
||||||
|
tabe_(std::make_unique<Tabe>())
|
||||||
{
|
{
|
||||||
// Pasa variables
|
// Pasa variables
|
||||||
demo_.enabled = demo;
|
demo_.enabled = demo;
|
||||||
@@ -942,6 +944,7 @@ void Game::fillCanvas()
|
|||||||
renderItems();
|
renderItems();
|
||||||
renderSmartSprites();
|
renderSmartSprites();
|
||||||
balloon_manager_->render();
|
balloon_manager_->render();
|
||||||
|
tabe_->render();
|
||||||
renderBullets();
|
renderBullets();
|
||||||
renderPathSprites();
|
renderPathSprites();
|
||||||
renderPlayers();
|
renderPlayers();
|
||||||
@@ -1207,6 +1210,12 @@ void Game::checkEvents()
|
|||||||
case SDLK_8:
|
case SDLK_8:
|
||||||
{
|
{
|
||||||
players_.at(0)->setPlayingState(PlayerState::LEAVING_SCREEN);
|
players_.at(0)->setPlayingState(PlayerState::LEAVING_SCREEN);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_9:
|
||||||
|
{
|
||||||
|
tabe_->enable();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -1373,7 +1382,7 @@ void Game::handleDemoMode()
|
|||||||
|
|
||||||
if (input_->checkAnyButtonPressed())
|
if (input_->checkAnyButtonPressed())
|
||||||
{
|
{
|
||||||
section::name = section::Name::TITLE; // Salir del modo demo y regresar al menú principal.
|
section::name = section::Name::TITLE; // Salir del modo demo y regresar al menú principal.
|
||||||
section::attract_mode = section::AttractMode::TITLE_TO_DEMO; // El juego volverá a mostrar la demo
|
section::attract_mode = section::AttractMode::TITLE_TO_DEMO; // El juego volverá a mostrar la demo
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1805,6 +1814,7 @@ void Game::updateGame()
|
|||||||
updateScoreboard();
|
updateScoreboard();
|
||||||
updateBackground();
|
updateBackground();
|
||||||
balloon_manager_->update();
|
balloon_manager_->update();
|
||||||
|
tabe_->update();
|
||||||
moveBullets();
|
moveBullets();
|
||||||
updateItems();
|
updateItems();
|
||||||
updateStage();
|
updateStage();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
class Asset; // lines 13-13
|
class Asset; // lines 13-13
|
||||||
class Background; // lines 14-14
|
class Background; // lines 14-14
|
||||||
class BalloonManager;
|
class BalloonManager;
|
||||||
|
class Tabe;
|
||||||
class Bullet; // lines 15-15
|
class Bullet; // lines 15-15
|
||||||
class Fade; // lines 16-16
|
class Fade; // lines 16-16
|
||||||
class Input; // lines 17-17
|
class Input; // lines 17-17
|
||||||
@@ -144,6 +145,7 @@ private:
|
|||||||
std::unique_ptr<Fade> fade_in_; // Objeto para renderizar fades
|
std::unique_ptr<Fade> fade_in_; // Objeto para renderizar fades
|
||||||
std::unique_ptr<Fade> fade_out_; // Objeto para renderizar fades
|
std::unique_ptr<Fade> fade_out_; // Objeto para renderizar fades
|
||||||
std::unique_ptr<BalloonManager> balloon_manager_; // Objeto para gestionar los globos
|
std::unique_ptr<BalloonManager> balloon_manager_; // Objeto para gestionar los globos
|
||||||
|
std::unique_ptr<Tabe> tabe_; // Objeto para gestionar el Tabe Volaor
|
||||||
std::vector<Path> paths_; // Vector con los recorridos precalculados almacenados
|
std::vector<Path> paths_; // Vector con los recorridos precalculados almacenados
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
|
|||||||
@@ -234,7 +234,6 @@ void Logo::render()
|
|||||||
void Logo::run()
|
void Logo::run()
|
||||||
{
|
{
|
||||||
// Detiene la música
|
// Detiene la música
|
||||||
//JA_StopMusic();
|
|
||||||
JA_FadeOutMusic(500);
|
JA_FadeOutMusic(500);
|
||||||
|
|
||||||
while (section::name == section::Name::LOGO)
|
while (section::name == section::Name::LOGO)
|
||||||
|
|||||||
55
source/tabe.cpp
Normal file
55
source/tabe.cpp
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#include "tabe.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#include "param.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Tabe::Tabe()
|
||||||
|
: sprite_(std::make_unique<AnimatedSprite>(Resource::get()->getTexture("tabe.png"), Resource::get()->getAnimation("tabe.ani")))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza la lógica
|
||||||
|
void Tabe::update()
|
||||||
|
{
|
||||||
|
if (enabled_)
|
||||||
|
{
|
||||||
|
sprite_->update();
|
||||||
|
move();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dibuja el objeto
|
||||||
|
void Tabe::render()
|
||||||
|
{
|
||||||
|
if (enabled_)
|
||||||
|
{
|
||||||
|
sprite_->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mueve el objeto
|
||||||
|
void Tabe::move()
|
||||||
|
{
|
||||||
|
x_ += speed_;
|
||||||
|
const float min_x = param.game.game_area.rect.x;
|
||||||
|
const float max_x = param.game.game_area.rect.x + param.game.game_area.rect.w - WIDTH_;
|
||||||
|
if (x_ < min_x || x_ > max_x)
|
||||||
|
{
|
||||||
|
x_ = std::clamp(x_, min_x, max_x);
|
||||||
|
speed_ = -speed_;
|
||||||
|
sprite_->setFlip(speed_ > 0.0f ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE);
|
||||||
|
}
|
||||||
|
shiftSprite();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Habilita el objeto
|
||||||
|
void Tabe::enable()
|
||||||
|
{
|
||||||
|
enabled_ = true;
|
||||||
|
speed_ = 5.0f;
|
||||||
|
x_ = 50.0f;
|
||||||
|
y_ = 20.0f;
|
||||||
|
sprite_->setFlip(speed_ > 0.0f ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE);
|
||||||
|
shiftSprite();
|
||||||
|
}
|
||||||
44
source/tabe.h
Normal file
44
source/tabe.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "animated_sprite.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
// Clase Tabe
|
||||||
|
class Tabe
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// Constantes
|
||||||
|
static constexpr int WIDTH_ = 32;
|
||||||
|
static constexpr int HEIGHT_ = 32;
|
||||||
|
|
||||||
|
// Punteros
|
||||||
|
std::unique_ptr<AnimatedSprite> sprite_; // Sprite con los graficos y animaciones
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
float x_; // Posición del objeto
|
||||||
|
float y_; // Posición del objeto
|
||||||
|
float speed_; // Velocidad de movimiento del objeto
|
||||||
|
bool enabled_ = false; // Indica si el objeto está activo
|
||||||
|
|
||||||
|
// Mueve el objeto
|
||||||
|
void move();
|
||||||
|
|
||||||
|
// Actualiza la posición del sprite
|
||||||
|
void shiftSprite() { sprite_->setPos(x_, y_); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
Tabe();
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~Tabe() = default;
|
||||||
|
|
||||||
|
// Actualiza la lógica
|
||||||
|
void update();
|
||||||
|
|
||||||
|
// Dibuja el objeto
|
||||||
|
void render();
|
||||||
|
|
||||||
|
// Habilita el objeto
|
||||||
|
void enable();
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user