Trabajando en la INTRO

This commit is contained in:
2022-09-28 18:52:19 +02:00
parent 2209ed5f97
commit c213124193
13 changed files with 766 additions and 551 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

BIN
data/gfx/title_bg_tile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

BIN
data/gfx/title_coffee.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
data/gfx/title_crisis.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

9
data/gfx/title_dust.ani Normal file
View File

@@ -0,0 +1,9 @@
frameWidth=16
frameHeight=16
[animation]
name=default
speed=8
loop=-1
frames=0,1,2,3,4,5,6
[/animation]

BIN
data/gfx/title_dust.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

BIN
data/gfx/title_gradient.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

109
data/menu/options.men Normal file
View File

@@ -0,0 +1,109 @@
font_png=smb2.png
font_txt=smb2.txt
sound_cancel=menu_cancel.wav
sound_accept=menu_select.wav
sound_move=menu_move.wav
name=TITLE
x=0
y=116
backgroundType=0
backgroundColor=48,48,64,192
areElementsCenteredOnX=true
isCenteredOnX=true
centerX=128
isCenteredOnY=true
centerY=96
selector_color=229,28,35,0
selector_text_color=255,180,0
defaultActionWhenCancel=13
[item]
text=DIFFICULTY
hPaddingDown=7
[/item]
[item]
text=PLAYER 1 CONTROLS
hPaddingDown=2
selectable=true
greyed=false
linkedDown=true
[/item]
[item]
text=KEYBOARD
hPaddingDown=7
selectable=false
greyed=false
[/item]
[item]
text=PLAYER 2 CONTROLS
hPaddingDown=2
selectable=true
greyed=false
linkedDown=true
[/item]
[item]
text=GAME CONTROLLER
hPaddingDown=7
selectable=false
greyed=false
[/item]
[item]
text=LANGUAGE
hPaddingDown=7
[/item]
[item]
text=DISPLAY MODE
hPaddingDown=2
selectable=true
greyed=false
linkedDown=true
[/item]
[item]
text=WINDOW
hPaddingDown=7
selectable=false
greyed=false
[/item]
[item]
text=WINDOW SIZE
hPaddingDown=2
[/item]
[item]
text=FILTER
hPaddingDown=2
[/item]
[item]
text=VSYNC
hPaddingDown=7
[/item]
[item]
text=HOW TO PLAY
hPaddingDown=7
[/item]
[item]
text=ACCEPT
hPaddingDown=2
[/item]
[item]
text=CANCEL
[/item]

40
data/menu/title.men Normal file
View File

@@ -0,0 +1,40 @@
font_png=smb2.png
font_txt=smb2.txt
sound_cancel=menu_cancel.wav
sound_accept=menu_select.wav
sound_move=menu_move.wav
name=TITLE
x=0
y=116
backgroundType=0
backgroundColor=48,48,64,192
areElementsCenteredOnX=true
isCenteredOnX=true
centerX=128
selector_color=229,28,35,0
selector_text_color=255,180,0
defaultActionWhenCancel=3
[item]
text=1 PLAYER
hPaddingDown=2
[/item]
[item]
text=2 PLAYERS
hPaddingDown=7
[/item]
[item]
text=OPTIONS
hPaddingDown=7
[/item]
[item]
text=QUIT
[/item]

View File

@@ -196,15 +196,23 @@ bool Director::setFileList()
asset->add("data/gfx/intro.png", t_bitmap);
asset->add("data/gfx/items.png", t_bitmap);
asset->add("data/gfx/logo.png", t_bitmap);
asset->add("data/gfx/player1_body.png", t_bitmap);
asset->add("data/gfx/player1_death.png", t_bitmap);
asset->add("data/gfx/player1_legs.png", t_bitmap);
asset->add("data/gfx/title.png", t_bitmap);
asset->add("data/gfx/title_bg_tile.png", t_bitmap);
asset->add("data/gfx/title_coffee.png", t_bitmap);
asset->add("data/gfx/title_crisis.png", t_bitmap);
asset->add("data/gfx/title_dust.png", t_bitmap);
asset->add("data/gfx/title_dust.ani", t_data);
asset->add("data/gfx/title_gradient.png", t_bitmap);
asset->add("data/gfx/player1_head.png", t_bitmap);
asset->add("data/gfx/player2_body.png", t_bitmap);
asset->add("data/gfx/player2_death.png", t_bitmap);
asset->add("data/gfx/player2_legs.png", t_bitmap);
asset->add("data/gfx/player1_body.png", t_bitmap);
asset->add("data/gfx/player1_legs.png", t_bitmap);
asset->add("data/gfx/player1_death.png", t_bitmap);
asset->add("data/gfx/player2_head.png", t_bitmap);
asset->add("data/gfx/player2_body.png", t_bitmap);
asset->add("data/gfx/player2_legs.png", t_bitmap);
asset->add("data/gfx/player2_death.png", t_bitmap);
// Fuentes
asset->add("data/font/8bithud.png", t_font);
@@ -225,6 +233,11 @@ bool Director::setFileList()
asset->add("data/lang/en_UK.txt", t_lang);
asset->add("data/lang/ba_BA.txt", t_lang);
// Menus
asset->add("data/menu/title.men", t_data);
asset->add("data/menu/options.men", t_data);
return asset->check();
}

View File

@@ -4,16 +4,55 @@
// Constructor
Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file)
{
// Copia punteros
this->renderer = renderer;
this->asset = asset;
this->input = input;
// Inicializa punteros
soundMove = nullptr;
soundAccept = nullptr;
soundCancel = nullptr;
init();
// Inicializa variables
name = "";
selector.index = 0;
itemSelected = MENU_NO_OPTION;
x = 0;
y = 0;
rectBG.rect = {0, 0, 0, 0};
rectBG.color = {0, 0, 0};
rectBG.a = 0;
backgroundType = MENU_BACKGROUND_SOLID;
isCenteredOnX = false;
isCenteredOnY = false;
areElementsCenteredOnX = false;
centerX = 0;
centerY = 0;
widestItem = 0;
colorGreyed = {128, 128, 128};
defaultActionWhenCancel = 0;
font_png = "";
font_txt = "";
// Selector
selector.originY = 0;
selector.targetY = 0;
selector.despY = 0;
selector.originH = 0;
selector.targetH = 0;
selector.incH = 0;
selector.y = 0.0f;
selector.h = 0.0f;
selector.numJumps = 8;
selector.moving = false;
selector.resizing = false;
selector.rect = {0, 0, 0, 0};
selector.color = {0, 0, 0};
selector.itemColor = {0, 0, 0};
selector.a = 255;
// Inicializa las variables desde un fichero
if (file != "")
{
load(file);
@@ -129,7 +168,7 @@ bool Menu::load(std::string file_path)
}
// Reorganiza el menu con los valores recien cargados
//reorganize();
// reorganize();
return success;
}
@@ -315,43 +354,6 @@ bool Menu::setVars(std::string var, std::string value)
// Inicializa las variables
void Menu::init()
{
// Inicia variables
name = "";
selector.index = 0;
itemSelected = MENU_NO_OPTION;
x = 0;
y = 0;
rectBG.rect = {0, 0, 0, 0};
rectBG.color = {0, 0, 0};
rectBG.a = 0;
backgroundType = MENU_BACKGROUND_SOLID;
isCenteredOnX = false;
isCenteredOnY = false;
areElementsCenteredOnX = false;
centerX = 0;
centerY = 0;
widestItem = 0;
colorGreyed = {128, 128, 128};
defaultActionWhenCancel = 0;
font_png = "";
font_txt = "";
// Selector
selector.originY = 0;
selector.targetY = 0;
selector.despY = 0;
selector.originH = 0;
selector.targetH = 0;
selector.incH = 0;
selector.y = 0.0f;
selector.h = 0.0f;
selector.numJumps = 8;
selector.moving = false;
selector.resizing = false;
selector.rect = {0, 0, 0, 0};
selector.color = {0, 0, 0};
selector.itemColor = {0, 0, 0};
selector.a = 255;
}
// Carga los ficheros de audio
@@ -736,14 +738,13 @@ void Menu::centerMenuElementsOnX()
void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool greyed, bool linkedDown)
{
item_t temp;
// Si es el primer item coge la posición en el eje Y del propio menu
if (item.size() == 0)
{
{// Si es el primer item coge la posición en el eje Y del propio menu
temp.rect.y = y;
}
else
// En caso contrario, coge la posición en el eje Y a partir del elemento anterior
{
{// En caso contrario, coge la posición en el eje Y a partir del elemento anterior
temp.rect.y = item.back().rect.y + item.back().rect.h + item.back().hPaddingDown;
}
@@ -754,6 +755,7 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
temp.linkedDown = linkedDown;
item.push_back(temp);
setItemCaption(item.size() - 1, text);
if (item.size() > 0)

File diff suppressed because it is too large Load Diff

View File

@@ -42,36 +42,42 @@ private:
};
// Objetos
SDL_Renderer *mRenderer; // El renderizador de la ventana
Screen *mScreen; // Objeto encargado de dibujar en pantalla
Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos
Input *mInput; // Objeto para leer las entradas de teclado o mando
Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas
SDL_Event *mEventHandler; // Manejador de eventos
SDL_Renderer *mRenderer; // El renderizador de la ventana
Screen *mScreen; // Objeto encargado de dibujar en pantalla
Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos
Input *mInput; // Objeto para leer las entradas de teclado o mando
Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas
Instructions *mInstructions; // Objeto para la sección de las instrucciones
Game *mDemoGame; // Objeto para lanzar la demo del juego
SDL_Event *mEventHandler; // Manejador de eventos
LTexture *dustTexture; // Textura con los graficos del polvo
LTexture *coffeeTexture; // Textura con los graficos de la palabra coffee
LTexture *crisisTexture; // Textura con los graficos de la plabra crisis
LTexture *gradientTexture; // Textura con los graficos para el degradado del fondo del titulo
SDL_Rect mBackgroundWindow; // Ventana visible para la textura de fondo del titulo
SDL_Texture *mBackground; // Textura dibujar el fondo del titulo
AnimatedSprite *mDustBitmapL; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo
AnimatedSprite *mDustBitmapR; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo
LTexture *mItemsTexture; // Textura con los gráficos de los items para las instrucciones
LTexture *mTitleTexture; // Textura con los graficos para el titulo
SDL_Rect mBackgroundWindow; // Ventana visible para la textura de fondo del titulo
SDL_Texture *mBackground; // Textura dibujar el fondo del titulo
SmartSprite *mCoffeeBitmap; // Sprite con la palabra COFFEE para la pantalla de titulo
SmartSprite *mCrisisBitmap; // Sprite con la palabra CRISIS para la pantalla de titulo
Sprite *mTile; // Sprite para dibujar el fondo de pantalla del título
Sprite *mGradient; // Sprite para dibujar el degradado del titulo
Text *mText; // Objeto de texto para poder escribir textos en pantalla
Text *mText2; // Objeto de texto para poder escribir textos en pantalla
Fade *mFade; // Objeto para realizar fundidos en pantalla
Instructions *mInstructions; // Objeto para la sección de las instrucciones
Game *mDemoGame; // Objeto para lanzar la demo del juego
SmartSprite *mCoffeeBitmap; // Sprite con la palabra COFFEE para la pantalla de titulo
SmartSprite *mCrisisBitmap; // Sprite con la palabra CRISIS para la pantalla de titulo
Sprite *mGradient; // Sprite para dibujar el degradado del titulo
Text *mText; // Objeto de texto para poder escribir textos en pantalla
Text *mText2; // Objeto de texto para poder escribir textos en pantalla
Fade *mFade; // Objeto para realizar fundidos en pantalla
// Variable
JA_Music mMusic; // Musica para el titulo
JA_Sound mSound; // Sonido con el impacto del título
int mBackgroundCounter; // Temporizador para el fondo de tiles de la pantalla de titulo
int mCounter; // Temporizador para la pantalla de titulo
int mBackgroundCounter; // Temporizador para el fondo de tiles de la pantalla de titulo
int mCounter; // Temporizador para la pantalla de titulo
Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa
Uint8 mBackgroundMode; // Variable para almacenar el tipo de efecto que hará el fondo de la pantalla de titulo
Uint8 mEvents[TITLE_TOTAL_EVENTS]; // Vector para coordinar los eventos de la pantalla de titulo
float mSin[360]; // Vector con los valores del seno precalculados
bool mMenuVisible; // Indicador para saber si se muestra el menu del titulo o la frase intermitente
bool mDemo; // Indica si el modo demo estará activo
@@ -85,6 +91,18 @@ private:
std::vector<input_t> mAvailableInputDevices; // Vector con todos los metodos de control disponibles
int mDeviceIndex[2]; // Indice para el jugador [i] del vector de dispositivos de entrada disponibles
// Actualiza las variables del objeto
void update();
// Dibuja el objeto en pantalla
void render();
// Comprueba los eventos
void checkEventHandler();
//Actualiza el tileado de fondo
void updateBG();
// Cambia el valor de la variable de modo de pantalla completa
void switchFullScreenModeVar();