This commit is contained in:
2022-09-05 16:13:50 +02:00
21 changed files with 216 additions and 96 deletions

View File

@@ -1,5 +1,6 @@
name=void main
bgColor=black
border=red
tileset=standard.png
roomUp=0
roomDown=0

View File

@@ -1,5 +1,6 @@
name=case switch
bgColor=black
border=green
tileset=standard.png
roomUp=0
roomDown=04.room
@@ -23,7 +24,7 @@ x1=14
y1=0
x2=14
y2=12
color=purple
color=magenta
[/enemy]
[item]

View File

@@ -1,5 +1,6 @@
name=the edge
bgColor=light_black
border=black
tileset=standard.png
roomUp=0
roomDown=05.room
@@ -55,7 +56,7 @@ x1=16
y1=2
x2=16
y2=13
color=purple
color=magenta
[/enemy]
[item]

View File

@@ -1,5 +1,6 @@
name=The Fridge
bgColor=blue
border=blue
tileset=standard.png
roomUp=02.room
roomDown=0
@@ -23,7 +24,7 @@ x1=1
y1=3
x2=14
y2=3
color=purple
color=magenta
[/enemy]
[enemy]
@@ -55,7 +56,7 @@ x1=15
y1=12
x2=30
y2=12
color=light_purple
color=light_magenta
[/enemy]
[item]

View File

@@ -1,5 +1,6 @@
name=sigmasua
bgColor=black
border=blue
tileset=standard.png
roomUp=03.room
roomDown=0

View File

@@ -28,7 +28,7 @@ Director::Director(std::string path)
options->filter = FILTER_NEAREST;
options->vSync = true;
options->screenWidth = GAMECANVAS_WIDTH * options->windowSize;
options->screenHeight = GAMECANVAS_HEIGHT * options->windowSize;
options->screenHeight = GAMECANVAS_HEIGHT * options->windowSize;
options->integerScale = true;
options->keepAspect = true;

View File

@@ -17,7 +17,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input)
// Crea los objetos
scoreboard = new ScoreBoard(renderer, asset, &playerLives, &itemsPicked, &clock);
itemTracker = new ItemTracker();
room = new Room(asset->get(currentRoom), renderer, asset, itemTracker, &itemsPicked);
room = new Room(asset->get(currentRoom), renderer, screen, asset, itemTracker, &itemsPicked);
player = new Player(spawnPoint, asset->get("player01.png"), asset->get("player01.ani"), renderer, asset, input, room);
eventHandler = new SDL_Event();
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
@@ -267,7 +267,7 @@ bool Game::changeRoom(std::string file)
room = nullptr;
// Crea un objeto habitación nuevo a partir del fichero
room = new Room(asset->get(file), renderer, asset, itemTracker, &itemsPicked);
room = new Room(asset->get(file), renderer, screen, asset, itemTracker, &itemsPicked);
// Pasa la nueva habitación al jugador
player->setRoom(room);
@@ -325,7 +325,7 @@ void Game::killPlayer()
delete player;
// Crea la nueva habitación y el nuevo jugador
room = new Room(asset->get(currentRoom), renderer, asset, itemTracker, &itemsPicked);
room = new Room(asset->get(currentRoom), renderer, screen, asset, itemTracker, &itemsPicked);
player = new Player(spawnPoint, asset->get("player01.png"), asset->get("player01.ani"), renderer, asset, input, room);
}

View File

@@ -177,7 +177,7 @@ bool Input::discoverGameController()
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
}
//mGameController = mConnectedControllers[0];
// mGameController = mConnectedControllers[0];
SDL_GameControllerEventState(SDL_ENABLE);
}

View File

@@ -49,8 +49,8 @@ private:
};
GameControllerBindings_t mGameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
//SDL_GameController *mGameController; // Manejador para el mando
std::vector<SDL_GameController*> mConnectedControllers;
// SDL_GameController *mGameController; // Manejador para el mando
std::vector<SDL_GameController *> mConnectedControllers;
std::vector<std::string> mControllerNames;
int mNumGamepads;
std::string mDBpath; // Ruta al archivo gamecontrollerdb.txt
@@ -72,7 +72,7 @@ public:
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
// Comprueba si un input esta activo
bool checkInput(Uint8 input, bool repeat, int device=INPUT_USE_ANY, int index=0);
bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0);
// Comprueba si hay algun mando conectado
bool gameControllerFound();

View File

@@ -10,7 +10,7 @@ Item::Item(item_t item)
renderer = item.renderer;
// Crea objetos
texture = new LTexture(renderer,asset->get(item.tileset));
texture = new LTexture(renderer, asset->get(item.tileset));
sprite = new Sprite(item.x, item.y, 8, 8, texture, renderer);
// Inicia variables
@@ -26,7 +26,7 @@ Item::Item(item_t item)
c = stringToColor("red");
color.push_back(c);
c = stringToColor("purple");
c = stringToColor("magenta");
color.push_back(c);
c = stringToColor("green");

View File

@@ -49,7 +49,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset)
c = stringToColor("red");
color.push_back(c);
c = stringToColor("purple");
c = stringToColor("magenta");
color.push_back(c);
c = stringToColor("green");

View File

@@ -24,7 +24,7 @@ private:
SDL_Event *eventHandler; // Manejador de eventos
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
Sprite *sprite2; // Sprite para manejar la textura2
std::vector<color_t> color; // Vector con los colores para el fade
std::vector<color_t> color; // Vector con los colores para el fade
int counter; // Contador
section_t section; // Estado del bucle principal para saber si continua o se sale
int ticks; // Contador de ticks para ajustar la velocidad del programa

View File

@@ -15,7 +15,7 @@ private:
SDL_Renderer *renderer; // Renderizador donde dibujar la textura
int width; // Ancho de la imagen
int height; // Alto de la imagen
std::string path; // Ruta de la imagen de la textura
std::string path; // Ruta de la imagen de la textura
public:
// Constructor

View File

@@ -4,11 +4,12 @@
#include <sstream>
// Constructor
Room::Room(std::string file_path, SDL_Renderer *renderer, Asset *asset, ItemTracker *itemTracker, int *items)
Room::Room(std::string file_path, SDL_Renderer *renderer, Screen *screen, Asset *asset, ItemTracker *itemTracker, int *items)
{
// Copia los punteros a objetos
this->asset = asset;
this->renderer = renderer;
this->asset = asset;
this->screen = screen;
this->itemTracker = itemTracker;
this->itemsPicked = items;
@@ -24,6 +25,9 @@ Room::Room(std::string file_path, SDL_Renderer *renderer, Asset *asset, ItemTrac
// Pinta el mapa de la habitación en la textura
fillMapTexture();
// Establece el color del borde
screen->setBorderColor(borderColor);
}
// Destructor
@@ -213,6 +217,11 @@ bool Room::setVars(std::string var, std::string value)
bgColor = stringToColor(value);
}
else if (var == "border")
{
borderColor = stringToColor(value);
}
else if (var == "tileset")
{
tileset = value;

View File

@@ -3,6 +3,7 @@
#include "utils.h"
#include "asset.h"
#include "screen.h"
#include "enemy.h"
#include "item.h"
#include "item_tracker.h"
@@ -39,6 +40,7 @@ class Room
private:
std::string name; // Nombre de la habitación
color_t bgColor; // Color de fondo de la habitación
color_t borderColor; // Color de fondo de la habitación
std::string roomUp; // Identificador de la habitación que se encuentra arriba
std::string roomDown; // Identificador de la habitación que se encuentra abajp
std::string roomLeft; // Identificador de la habitación que se encuentra a la izquierda
@@ -49,6 +51,7 @@ private:
std::vector<Item *> items; // Listado con los items que hay en la habitación
LTexture *texture; // Textura con los graficos de la habitación
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
Screen *screen; // Objeto encargado de dibujar en pantalla
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
SDL_Renderer *renderer; // El renderizador de la ventana
SDL_Texture *mapTexture; // Textura para dibujar el mapa de la habitación
@@ -72,7 +75,7 @@ private:
public:
// Constructor
Room(std::string file_path, SDL_Renderer *renderer, Asset *asset, ItemTracker *item_tracker, int *items);
Room(std::string file_path, SDL_Renderer *renderer, Screen *screen, Asset *asset, ItemTracker *item_tracker, int *items);
// Destructor
~Room();

View File

@@ -29,7 +29,7 @@ ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, int *lives, int *it
c = stringToColor("red");
color.push_back(c);
c = stringToColor("purple");
c = stringToColor("magenta");
color.push_back(c);
c = stringToColor("green");
@@ -50,7 +50,7 @@ ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, int *lives, int *it
c = stringToColor("light_red");
color.push_back(c);
c = stringToColor("light_purple");
c = stringToColor("light_magenta");
color.push_back(c);
c = stringToColor("light_green");

View File

@@ -8,10 +8,10 @@
struct anchor_t
{
int left; // Parte izquierda de la pantalla de juego
int right; // Parte drecha de la pantalla de juego
int left; // Parte izquierda de la pantalla de juego
int right; // Parte drecha de la pantalla de juego
int center; // Parte central horizontal de la pantalla de juego
int top; // Parte superior de la pantalla de juego
int top; // Parte superior de la pantalla de juego
int bottom; // Parte infoerior de la pantalla de juego
int middle; // Parte central vertical de la pantalla de juego
};

View File

@@ -180,5 +180,5 @@ int Text::getCharacterWidth()
// Recarga la textura
void Text::reLoadTexture()
{
texture->reLoad();
texture->reLoad();
}

View File

@@ -143,70 +143,173 @@ bool checkCollision(SDL_Point &p, SDL_Rect &r)
// Devuelve un color_t a partir de un string
color_t stringToColor(std::string str)
{
color_t color = {0x00, 0x00, 0x00};
if (str == "black")
const std::string palette = "spectrum";
if (palette == "spectrum")
{
color = {0x00, 0x00, 0x00};
if (str == "black")
{
return {0x00, 0x00, 0x00};
}
else if (str == "light_black")
{
return {0x00, 0x00, 0x00};
}
else if (str == "blue")
{
return {0x00, 0x00, 0xFF};
}
else if (str == "light_blue")
{
return {0x00, 0x00, 0xEE};
}
else if (str == "red")
{
return {0xFF, 0x00, 0x00};
}
else if (str == "light_red")
{
return {0xEE, 0x00, 0x00};
}
else if (str == "magenta")
{
return {0xFF, 0x00, 0xFF};
}
else if (str == "light_magenta")
{
return {0xEE, 0x00, 0xEE};
}
else if (str == "green")
{
return {0x00, 0xFF, 0x00};
}
else if (str == "light_green")
{
return {0x00, 0xEE, 0x00};
}
else if (str == "cyan")
{
return {0x00, 0xFF, 0xFF};
}
else if (str == "light_cyan")
{
return {0x00, 0xEE, 0xEE};
}
else if (str == "yellow")
{
return {0xFF, 0xFF, 0x00};
}
else if (str == "light_yellow")
{
return {0xEE, 0xEE, 0x00};
}
else if (str == "white")
{
return {0xEE, 0xEE, 0xEE};
}
else if (str == "light_white")
{
return {0xFF, 0xFF, 0xFF};
}
}
else if (str == "light_black")
else
{
color = {0x3C, 0x35, 0x1F};
if (str == "black")
{
return {0x00, 0x00, 0x00};
}
else if (str == "light_black")
{
return {0x3C, 0x35, 0x1F};
}
else if (str == "blue")
{
return {0x31, 0x33, 0x90};
}
else if (str == "light_blue")
{
return {0x15, 0x59, 0xDB};
}
else if (str == "red")
{
return {0xA7, 0x32, 0x11};
}
else if (str == "light_red")
{
return {0xD8, 0x55, 0x25};
}
else if (str == "magenta")
{
return {0xA1, 0x55, 0x89};
}
else if (str == "light_magenta")
{
return {0xCD, 0x7A, 0x50};
}
else if (str == "green")
{
return {0x62, 0x9A, 0x31};
}
else if (str == "light_green")
{
return {0x9C, 0xD3, 0x3C};
}
else if (str == "cyan")
{
return {0x28, 0xA4, 0xCB};
}
else if (str == "light_cyan")
{
return {0x65, 0xDC, 0xD6};
}
else if (str == "yellow")
{
return {0xE8, 0xBC, 0x50};
}
else if (str == "light_yellow")
{
return {0xF1, 0xE7, 0x82};
}
else if (str == "white")
{
return {0xBF, 0xBF, 0xBD};
}
else if (str == "light_white")
{
return {0xF2, 0xF1, 0xED};
}
}
else if (str == "blue")
{
color = {0x31, 0x33, 0x90};
}
else if (str == "light_blue")
{
color = {0x15, 0x59, 0xDB};
}
else if (str == "red")
{
color = {0xA7, 0x32, 0x11};
}
else if (str == "light_red")
{
color = {0xD8, 0x55, 0x25};
}
else if (str == "purple")
{
color = {0xA1, 0x55, 0x89};
}
else if (str == "light_purple")
{
color = {0xCD, 0x7A, 0x50};
}
else if (str == "green")
{
color = {0x62, 0x9A, 0x31};
}
else if (str == "light_green")
{
color = {0x9C, 0xD3, 0x3C};
}
else if (str == "cyan")
{
color = {0x28, 0xA4, 0xCB};
}
else if (str == "light_cyan")
{
color = {0x65, 0xDC, 0xD6};
}
else if (str == "yellow")
{
color = {0xE8, 0xBC, 0x50};
}
else if (str == "light_yellow")
{
color = {0xF1, 0xE7, 0x82};
}
else if (str == "white")
{
color = {0xBF, 0xBF, 0xBD};
}
else if (str == "light_white")
{
color = {0xF2, 0xF1, 0xED};
}
return color;
return {0x00, 0x00, 0x00};
}

View File

@@ -7,9 +7,9 @@ x (A) Colisiones con los enemigos {cm:2022-08-29}
x (A) Decidir un diseño para qué sucede en caso de morir: Recordar el punto por donde se entró al mapa y la velocidad en el eje X/Y que llevaba el personaje, crear puntos de reaparicion en las habitaciones, etc {cm:2022-08-29}
x En el Jet Set Willy el juego recuerda la posicion y el momento. En las Tres Luces de Glaurung solo la posición. Se va a optar por seguir el diseño del Jet Set Willy {cm:2022-08-29}
x (A) Crear tiles que maten {cm:2022-08-29}
(A) Modificar el salto para que coincida con el del JSW, no ha de colisionar lateralmente
x (A) Modificar el salto para que coincida con el del JSW, no ha de colisionar lateralmente
(A) Crear tiles que deslicen, (no tipo hielo sino cinta)
(A) Crear tiles que arrastren, tipo cinta transportadora
(A) Tiles animados
(A) Crear ascensores
x (A) Enemigos de diferente tamaño {cm:2022-08-30}
@@ -23,14 +23,14 @@ x (A) Tecla F para pasar a pantalla completa {cm:2022-08-30}
x (A) Tecla + y - para cambiar tamaño de ventana. O control F1 a F4 {cm:2022-08-30}
(A) Poner en el marcador el indicador de si esta sonando la música
(A) Poner en el marcador el numero de habitaciones visitadas
(A) Añadir a cada habitación el color del borde
x (A) Añadir a cada habitación el color del borde
(A) Añadir a cada habitación el color del nombre de la habitación
x (A) Crear el logo al estilo del logo de ERBE o TOPO, con lineas que lo formen
(A) El titulo del juego hacerlo parecido al del Jet Set Willy in Paris
- Ha de generarse como las cargas de pantalla de spectrum
- Luego se colorea
- Finalmente, cada elemento cambia de color como si fueran luces de neon
x (A) El titulo del juego hacerlo parecido al del Jet Set Willy in Paris
x - Ha de generarse como las cargas de pantalla de spectrum
x - Luego se colorea
x - Finalmente, cada elemento cambia de color como si fueran luces de neon
x (A) En el titulo del juego, por la parte inferior ha de aparecer una marquesina con texto, al estilo demoscene
x (A) La pantalla de titulo no tiene menu, solo un PRESS ENTER TO PLAY