forked from jaildesigner-jailgames/jaildoctors_dilemma
añadido map.h y map.cpp
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
#define CONST_H
|
||||
|
||||
// Textos
|
||||
#define WINDOW_CAPTION "Pepe el Cazavampiros"
|
||||
#define TEXT_COPYRIGHT "@2021 JailDesigner (v0.1)"
|
||||
#define WINDOW_CAPTION "New JailGame"
|
||||
#define TEXT_COPYRIGHT "@2022 JailDesigner (v0.1)"
|
||||
|
||||
// Tamaño de bloque
|
||||
#define BLOCK 8
|
||||
@@ -49,21 +49,20 @@ const int GAMECANVAS_FIRST_QUARTER_Y = GAMECANVAS_HEIGHT / 4;
|
||||
const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3;
|
||||
|
||||
// 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
|
||||
#define SECTION_PROG_LOGO 0
|
||||
#define SECTION_PROG_INTRO 1
|
||||
#define SECTION_PROG_TITLE 2
|
||||
#define SECTION_PROG_GAME 3
|
||||
#define SECTION_PROG_QUIT 4
|
||||
|
||||
// Subsecciones
|
||||
#define GAME_SECTION_PLAY_1P 0
|
||||
#define GAME_SECTION_PLAY_2P 1
|
||||
#define GAME_SECTION_PAUSE 2
|
||||
#define GAME_SECTION_GAMEOVER 3
|
||||
#define TITLE_SECTION_1 3
|
||||
#define TITLE_SECTION_2 4
|
||||
#define TITLE_SECTION_3 5
|
||||
#define TITLE_SECTION_INSTRUCTIONS 6
|
||||
#define SECTION_GAME_PLAY 0
|
||||
#define SECTION_GAME_PAUSE 1
|
||||
#define SECTION_GAME_GAMEOVER 2
|
||||
#define SECTION_TITLE_1 3
|
||||
#define SECTION_TITLE_2 4
|
||||
#define SECTION_TITLE_3 5
|
||||
#define SECTION_TITLE_INSTRUCTIONS 6
|
||||
|
||||
// Estados de cada elemento que pertenece a un evento
|
||||
#define EVENT_WAITING 1
|
||||
@@ -71,7 +70,7 @@ const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3;
|
||||
#define EVENT_COMPLETED 3
|
||||
|
||||
// Estados de entrada
|
||||
#define NO_INPUT 0
|
||||
#define INPUT_NULL 0
|
||||
#define INPUT_FIRE_LEFT 7
|
||||
#define INPUT_FIRE_UP 8
|
||||
#define INPUT_FIRE_RIGHT 9
|
||||
|
||||
@@ -17,9 +17,9 @@ Director::Director(std::string path)
|
||||
setFileList();
|
||||
|
||||
// Si falta algún fichero no inicia el programa
|
||||
Uint8 section = PROG_SECTION_GAME;
|
||||
Uint8 section = SECTION_PROG_GAME;
|
||||
if (!mAsset->check())
|
||||
section = PROG_SECTION_QUIT;
|
||||
section = SECTION_PROG_QUIT;
|
||||
|
||||
// Inicializa el objeto de idioma
|
||||
mLang = new Lang(mAsset);
|
||||
@@ -360,20 +360,20 @@ void Director::runGame()
|
||||
void Director::run()
|
||||
{
|
||||
// Bucle principal
|
||||
while (!(getSection() == PROG_SECTION_QUIT))
|
||||
while (!(getSection() == SECTION_PROG_QUIT))
|
||||
{
|
||||
switch (getSection())
|
||||
{
|
||||
case PROG_SECTION_LOGO:
|
||||
case SECTION_PROG_LOGO:
|
||||
runLogo();
|
||||
break;
|
||||
case PROG_SECTION_INTRO:
|
||||
case SECTION_PROG_INTRO:
|
||||
runIntro();
|
||||
break;
|
||||
case PROG_SECTION_TITLE:
|
||||
case SECTION_PROG_TITLE:
|
||||
runTitle();
|
||||
break;
|
||||
case PROG_SECTION_GAME:
|
||||
case SECTION_PROG_GAME:
|
||||
runGame();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ Game::Game(SDL_Window *window,SDL_Renderer *renderer, Asset *asset, Lang *lang,
|
||||
mInput = input;
|
||||
|
||||
mScreen = new Screen(window, renderer);
|
||||
mMap = new Map();
|
||||
mEventHandler = new SDL_Event();
|
||||
mTextureText = new LTexture();
|
||||
mText = new Text(mAsset->get("nokia2.txt"), mTextureText, renderer);
|
||||
@@ -33,6 +34,9 @@ Game::~Game()
|
||||
delete mScreen;
|
||||
mScreen = nullptr;
|
||||
|
||||
delete mMap;
|
||||
mMap = nullptr;
|
||||
|
||||
delete mText;
|
||||
mText = nullptr;
|
||||
|
||||
@@ -49,8 +53,8 @@ void Game::init()
|
||||
mTicks = 0;
|
||||
mTicksSpeed = 15;
|
||||
|
||||
mSection.name = PROG_SECTION_GAME;
|
||||
mSection.subsection = GAME_SECTION_PLAY_1P;
|
||||
mSection.name = SECTION_PROG_GAME;
|
||||
mSection.subsection = SECTION_GAME_PLAY;
|
||||
}
|
||||
|
||||
// Carga los recursos necesarios para la sección 'Game'
|
||||
@@ -69,10 +73,10 @@ section_t Game::run()
|
||||
{
|
||||
init();
|
||||
|
||||
while (mSection.name == PROG_SECTION_GAME)
|
||||
while (mSection.name == SECTION_PROG_GAME)
|
||||
{
|
||||
// Sección juego jugando
|
||||
if ((mSection.subsection == GAME_SECTION_PLAY_1P) || (mSection.subsection == GAME_SECTION_PLAY_2P))
|
||||
if (mSection.subsection == SECTION_GAME_PLAY)
|
||||
{
|
||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||
if (SDL_GetTicks() - mTicks > mTicksSpeed)
|
||||
@@ -86,7 +90,7 @@ section_t Game::run()
|
||||
// Evento de salida de la aplicación
|
||||
if (mEventHandler->type == SDL_QUIT)
|
||||
{
|
||||
mSection.name = PROG_SECTION_QUIT;
|
||||
mSection.name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -102,7 +106,7 @@ section_t Game::run()
|
||||
mText->write(0, GAMECANVAS_CENTER_Y - (mText->getCharacterWidth() / 2), std::to_string(GAMECANVAS_HEIGHT), -1);
|
||||
|
||||
// Texto en el centro de la pantalla
|
||||
mText->writeCentered(GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y - (mText->getCharacterWidth() / 2), "Pepe el Cazavampiros", -1);
|
||||
mText->writeCentered(GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y - (mText->getCharacterWidth() / 2), "New JailGame", -1);
|
||||
|
||||
// Actualiza la pantalla
|
||||
mScreen->blit();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "lang.h"
|
||||
#include "screen.h"
|
||||
#include "asset.h"
|
||||
#include "map.h"
|
||||
#include "jail_audio.h"
|
||||
|
||||
#ifndef GAME_H
|
||||
@@ -26,7 +27,8 @@ class Game
|
||||
private:
|
||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
||||
SDL_Event *mEventHandler; // Manejador de eventos
|
||||
Screen *mScreen; // El objeto encargado de manejar el renderizador
|
||||
Screen *mScreen; // Objeto encargado de manejar el renderizador
|
||||
Map *mMap; // Objeto encargado de gestionar el mapa del juego
|
||||
Asset *mAsset; // Objeto con la ruta a todos los ficheros de recursos
|
||||
Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas
|
||||
Input *mInput; // Manejador de entrada
|
||||
@@ -45,7 +47,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Game(SDL_Window *window,SDL_Renderer *renderer, Asset *asset, Lang *lang, Input *input);
|
||||
Game(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Lang *lang, Input *input);
|
||||
|
||||
// Destructor
|
||||
~Game();
|
||||
|
||||
11
source/map.cpp
Normal file
11
source/map.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "Map.h"
|
||||
|
||||
// Constructor
|
||||
Map::Map()
|
||||
{
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Map::~Map()
|
||||
{
|
||||
}
|
||||
22
source/map.h
Normal file
22
source/map.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "ifdefs.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef MAP_H
|
||||
#define MAP_H
|
||||
|
||||
// Clase Map
|
||||
class Map
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Map();
|
||||
|
||||
// Destructor
|
||||
~Map();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user