Modificados algunos recursos

This commit is contained in:
2022-10-09 19:38:40 +02:00
parent 420f7e84a0
commit 80e89489a6
29 changed files with 129 additions and 130 deletions

View File

@@ -1,7 +1,7 @@
#include "prog.h"
#include "director.h"
// Constructor
Prog::Prog(std::string path)
Director::Director(std::string path)
{
// Crea el objeto que controla los ficheros de recursos
asset = new Asset(path.substr(0, path.find_last_of("\\/")));
@@ -35,7 +35,7 @@ Prog::Prog(std::string path)
debug = new Debug(renderer, screen, asset);
}
Prog::~Prog()
Director::~Director()
{
// Guarda las opciones de configuración
saveConfig();
@@ -52,7 +52,7 @@ Prog::~Prog()
}
// Carga el fichero de configuración
bool Prog::loadConfig()
bool Director::loadConfig()
{
// Crea el puntero a la estructura de opciones e inicializa valores
options = new options_t;
@@ -122,7 +122,7 @@ bool Prog::loadConfig()
}
// Guarda el fichero de configuración
bool Prog::saveConfig()
bool Director::saveConfig()
{
bool success = true;
@@ -169,7 +169,7 @@ bool Prog::saveConfig()
}
// Asigna variables a partir de dos cadenas
bool Prog::setOptions(options_t *options, std::string var, std::string value)
bool Director::setOptions(options_t *options, std::string var, std::string value)
{
// Indicador de éxito en la asignación
bool success = true;
@@ -253,13 +253,13 @@ bool Prog::setOptions(options_t *options, std::string var, std::string value)
}
// Inicializa JailAudio
void Prog::initJailAudio()
void Director::initJailAudio()
{
JA_Init(44100, AUDIO_S16, 2);
}
// Arranca SDL y crea la ventana
bool Prog::initSDL()
bool Director::initSDL()
{
// Indicador de éxito
bool success = true;
@@ -320,7 +320,7 @@ bool Prog::initSDL()
}
// Inicia las variables necesarias para arrancar el programa
void Prog::initInput()
void Director::initInput()
{
// Inicializa los controles
input->bindKey(INPUT_UP, SDL_SCANCODE_UP);
@@ -347,7 +347,7 @@ void Prog::initInput()
}
// Crea el indice de ficheros de recursos
bool Prog::setFileList()
bool Director::setFileList()
{
// Ficheros del mapa
asset->add("/data/map/01.map", data);
@@ -373,7 +373,7 @@ bool Prog::setFileList()
asset->add("/data/map/09.tmx", data);
asset->add("/data/map/10.map", data);
asset->add("/data/map/10.tmx", data);
asset->add("/data/map/surface.png", bitmap);
asset->add("/data/map/tiles_surface.png", bitmap);
// Ficheros de configuración
asset->add("/data/config/config.txt", data, false);
@@ -440,19 +440,19 @@ bool Prog::setFileList()
}
// Obtiene el valor de la variable
Uint8 Prog::getSection()
Uint8 Director::getSection()
{
return section.name;
}
// Establece el valor de la variable
void Prog::setSection(section_t section)
void Director::setSection(section_t section)
{
this->section = section;
}
// Ejecuta la seccion de juego con el logo
void Prog::runLogo()
void Director::runLogo()
{
logo = new Logo(renderer, screen, asset);
setSection(logo->run());
@@ -460,7 +460,7 @@ void Prog::runLogo()
}
// Ejecuta la seccion de juego de la introducción
void Prog::runIntro()
void Director::runIntro()
{
intro = new Intro(renderer, screen, asset);
setSection(intro->run());
@@ -468,7 +468,7 @@ void Prog::runIntro()
}
// Ejecuta la seccion de juego con el titulo y los menus
void Prog::runTitle()
void Director::runTitle()
{
title = new Title(renderer, screen, asset, input);
setSection(title->run());
@@ -476,14 +476,14 @@ void Prog::runTitle()
}
// Ejecuta la seccion de juego donde se juega
void Prog::runGame()
void Director::runGame()
{
game = new Game(renderer, screen, asset, input, debug);
setSection(game->run());
delete game;
}
void Prog::run()
void Director::run()
{
// Bucle principal
while (!(getSection() == SECTION_PROG_QUIT))

View File

@@ -11,14 +11,13 @@
#include "logo.h"
#include "intro.h"
#include "title.h"
#include "prog.h"
#include "debug.h"
#include "const.h"
#ifndef PROG_H
#define PROG_H
class Prog
class Director
{
private:
SDL_Window *window; // La ventana donde dibujamos
@@ -78,10 +77,10 @@ private:
public:
// Constructor
Prog(std::string path);
Director(std::string path);
// Destructor
~Prog();
~Director();
// Bucle principal
void run();

View File

@@ -15,7 +15,7 @@ Repres un 14 de febrer de 2021
#include <SDL2/SDL.h>
#include <time.h>
#include <stdio.h>
#include "prog.h"
#include "director.h"
int main(int argc, char *args[])
{
@@ -25,13 +25,13 @@ int main(int argc, char *args[])
srand(time(nullptr));
// Crea el objeto director
Prog *prog = new Prog(args[0]);
Director *director = new Director(args[0]);
// Bucle principal
prog->run();
director->run();
// Libera todos los recursos y cierra SDL
delete prog;
delete director;
printf("Shutting down the game...\n");
return 0;