Compare commits
23
Commits
v0.6
..
new_engine
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfb4919a3e | ||
|
|
4193414f10 | ||
|
|
247e0060ee | ||
|
|
9af135100c | ||
|
|
066a9ab811 | ||
|
|
189b933622 | ||
|
|
7e9daddbb6 | ||
|
|
16ae06a755 | ||
|
|
ce8a4a8050 | ||
|
|
b6cfe45872 | ||
|
|
65eac860b1 | ||
|
|
e50aa77514 | ||
|
|
014312732b | ||
|
|
0e91809429 | ||
|
|
a121850adb | ||
|
|
87d7bd03ff | ||
|
|
73d394388b | ||
|
|
796a31a099 | ||
|
|
1351943c79 | ||
|
|
8630a0ae56 | ||
|
|
5eaf44d0b8 | ||
|
|
eba04a32fb | ||
|
|
c46637092a |
No files matched your search
+2
-1
@@ -1,9 +1,10 @@
|
|||||||
name=void main
|
name=void main
|
||||||
bgColor=black
|
bgColor=black
|
||||||
|
border=red
|
||||||
tileset=standard.png
|
tileset=standard.png
|
||||||
roomUp=0
|
roomUp=0
|
||||||
roomDown=0
|
roomDown=0
|
||||||
roomLeft=0
|
roomLeft=06.room
|
||||||
roomRight=02.room
|
roomRight=02.room
|
||||||
|
|
||||||
[tilemap]
|
[tilemap]
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<map version="1.9" tiledversion="1.9.0" orientation="orthogonal" renderorder="right-down" width="32" height="16" tilewidth="8" tileheight="8" infinite="0" nextlayerid="2" nextobjectid="1">
|
<map version="1.9" tiledversion="1.9.1" orientation="orthogonal" renderorder="right-down" width="32" height="16" tilewidth="8" tileheight="8" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||||
<tileset firstgid="1" source="../../../jaildoctors_dilemma_resources/tilesets/standard.tsx"/>
|
<tileset firstgid="1" source="../../../jaildoctors_dilemma_resources/tilesets/standard.tsx"/>
|
||||||
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,211,0,0,0,0,0,0,0,
|
21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,211,0,0,0,0,0,0,0,
|
||||||
21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
21,0,0,0,0,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,0,0,0,0,0,0,0,
|
21,0,0,0,0,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,0,0,0,0,0,0,0,
|
||||||
21,0,0,0,0,0,0,0,0,211,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,211,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
|
21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
|
||||||
21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21
|
21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
name=case switch
|
name=case switch
|
||||||
bgColor=black
|
bgColor=black
|
||||||
|
border=green
|
||||||
tileset=standard.png
|
tileset=standard.png
|
||||||
roomUp=0
|
roomUp=0
|
||||||
roomDown=04.room
|
roomDown=04.room
|
||||||
@@ -23,7 +24,7 @@ x1=14
|
|||||||
y1=0
|
y1=0
|
||||||
x2=14
|
x2=14
|
||||||
y2=12
|
y2=12
|
||||||
color=purple
|
color=magenta
|
||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
|
|||||||
+4
-3
@@ -1,5 +1,6 @@
|
|||||||
name=the edge
|
name=the edge
|
||||||
bgColor=light_black
|
bgColor=bright_black
|
||||||
|
border=black
|
||||||
tileset=standard.png
|
tileset=standard.png
|
||||||
roomUp=0
|
roomUp=0
|
||||||
roomDown=05.room
|
roomDown=05.room
|
||||||
@@ -39,7 +40,7 @@ x1=10
|
|||||||
y1=2
|
y1=2
|
||||||
x2=10
|
x2=10
|
||||||
y2=13
|
y2=13
|
||||||
color=light_blue
|
color=bright_blue
|
||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
@@ -55,7 +56,7 @@ x1=16
|
|||||||
y1=2
|
y1=2
|
||||||
x2=16
|
x2=16
|
||||||
y2=13
|
y2=13
|
||||||
color=purple
|
color=magenta
|
||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
|
|||||||
+4
-3
@@ -1,5 +1,6 @@
|
|||||||
name=The Fridge
|
name=The Fridge
|
||||||
bgColor=blue
|
bgColor=blue
|
||||||
|
border=blue
|
||||||
tileset=standard.png
|
tileset=standard.png
|
||||||
roomUp=02.room
|
roomUp=02.room
|
||||||
roomDown=0
|
roomDown=0
|
||||||
@@ -23,7 +24,7 @@ x1=1
|
|||||||
y1=3
|
y1=3
|
||||||
x2=14
|
x2=14
|
||||||
y2=3
|
y2=3
|
||||||
color=purple
|
color=magenta
|
||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
@@ -39,7 +40,7 @@ x1=10
|
|||||||
y1=7
|
y1=7
|
||||||
x2=30
|
x2=30
|
||||||
y2=7
|
y2=7
|
||||||
color=light_white
|
color=bright_white
|
||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
@@ -55,7 +56,7 @@ x1=15
|
|||||||
y1=12
|
y1=12
|
||||||
x2=30
|
x2=30
|
||||||
y2=12
|
y2=12
|
||||||
color=light_purple
|
color=bright_magenta
|
||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
|
|||||||
+3
-2
@@ -1,5 +1,6 @@
|
|||||||
name=sigmasua
|
name=sigmasua
|
||||||
bgColor=black
|
bgColor=black
|
||||||
|
border=blue
|
||||||
tileset=standard.png
|
tileset=standard.png
|
||||||
roomUp=03.room
|
roomUp=03.room
|
||||||
roomDown=0
|
roomDown=0
|
||||||
@@ -55,7 +56,7 @@ x1=10
|
|||||||
y1=10
|
y1=10
|
||||||
x2=10
|
x2=10
|
||||||
y2=13
|
y2=13
|
||||||
color=light_red
|
color=bright_red
|
||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
@@ -71,7 +72,7 @@ x1=23
|
|||||||
y1=10
|
y1=10
|
||||||
x2=23
|
x2=23
|
||||||
y2=13
|
y2=13
|
||||||
color=light_red
|
color=bright_red
|
||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
name=the test room
|
||||||
|
bgColor=blue
|
||||||
|
border=blue
|
||||||
|
tileset=standard.png
|
||||||
|
roomUp=0
|
||||||
|
roomDown=0
|
||||||
|
roomLeft=0
|
||||||
|
roomRight=01.room
|
||||||
|
|
||||||
|
[tilemap]
|
||||||
|
06.tmx
|
||||||
|
[/tilemap]
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<map version="1.9" tiledversion="1.9.1" orientation="orthogonal" renderorder="right-down" width="32" height="16" tilewidth="8" tileheight="8" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||||
|
<tileset firstgid="1" source="../../../jaildoctors_dilemma_resources/tilesets/standard.tsx"/>
|
||||||
|
<layer id="1" name="Capa de patrones 1" width="32" height="16">
|
||||||
|
<data encoding="csv">
|
||||||
|
26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
|
||||||
|
26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,183,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||||
|
26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,183,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||||
|
26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,183,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||||
|
26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,183,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||||
|
26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,167,66,66,66,66,187,0,0,0,0,164,65,65,0,0,0,26,
|
||||||
|
26,0,0,0,0,0,0,0,0,0,0,0,0,0,162,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||||
|
26,0,0,0,0,0,0,0,0,0,0,0,0,162,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||||
|
26,0,0,0,0,0,0,0,0,0,0,0,162,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,
|
||||||
|
26,0,0,0,0,0,0,0,0,161,212,212,212,212,212,212,212,0,212,212,181,0,0,0,0,0,0,0,0,0,0,26,
|
||||||
|
26,0,0,0,0,0,0,0,161,0,0,0,0,0,0,0,0,0,0,0,0,181,0,0,0,0,0,0,0,0,0,26,
|
||||||
|
26,0,0,0,0,0,0,161,0,0,0,0,0,0,0,0,0,269,0,0,0,0,181,0,0,0,0,0,0,0,0,26,
|
||||||
|
26,0,0,0,0,0,161,0,0,0,0,0,0,0,0,0,0,269,0,0,0,0,0,181,0,0,0,0,0,0,0,0,
|
||||||
|
26,0,0,0,0,161,0,0,0,0,0,0,0,0,0,0,0,289,0,0,0,0,0,0,181,0,0,0,0,0,0,0,
|
||||||
|
26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
|
||||||
|
26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26
|
||||||
|
</data>
|
||||||
|
</layer>
|
||||||
|
</map>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.5 KiB |
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
// Textos
|
// Textos
|
||||||
#define WINDOW_CAPTION "JailDoctor's Dilemma"
|
#define WINDOW_CAPTION "JailDoctor's Dilemma"
|
||||||
#define TEXT_COPYRIGHT "@2022 JailDesigner"
|
#define TEXT_COPYRIGHT "@2022 JailDesigner"
|
||||||
#define VERSION "0.1"
|
#define VERSION "0.6"
|
||||||
|
|
||||||
// Tamaño de bloque
|
// Tamaño de bloque
|
||||||
#define BLOCK 8
|
#define BLOCK 8
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Debug::Debug(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||||
|
{
|
||||||
|
// Copia la dirección de los objetos
|
||||||
|
this->renderer = renderer;
|
||||||
|
this->screen = screen;
|
||||||
|
this->asset = asset;
|
||||||
|
|
||||||
|
// Reserva memoria para los punteros
|
||||||
|
text = new Text(asset->get("debug.png"), asset->get("debug.txt"), renderer);
|
||||||
|
|
||||||
|
// Inicializa variables
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
Debug::~Debug()
|
||||||
|
{
|
||||||
|
delete text;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza las variables
|
||||||
|
void Debug::update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dibuja en pantalla
|
||||||
|
void Debug::render()
|
||||||
|
{
|
||||||
|
int y = this->y;
|
||||||
|
int w = 0;
|
||||||
|
|
||||||
|
for (auto s : slot)
|
||||||
|
{
|
||||||
|
text->write(x, y, s);
|
||||||
|
w = (std::max(w, (int)s.length()));
|
||||||
|
y += text->getCharacterSize() + 1;
|
||||||
|
if (y > 192 - text->getCharacterSize())
|
||||||
|
{
|
||||||
|
y = this->y;
|
||||||
|
x += w*text->getCharacterSize() + 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece la posición donde se colocará la información de debug
|
||||||
|
void Debug::setPos(SDL_Point p)
|
||||||
|
{
|
||||||
|
x = p.x;
|
||||||
|
y = p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añade un texto para mostrar
|
||||||
|
void Debug::add(std::string text)
|
||||||
|
{
|
||||||
|
slot.push_back(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Borra la información de debug
|
||||||
|
void Debug::clear()
|
||||||
|
{
|
||||||
|
slot.clear();
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include "const.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "screen.h"
|
||||||
|
#include "asset.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#ifndef DEBUG_H
|
||||||
|
#define DEBUG_H
|
||||||
|
|
||||||
|
// Clase Debug
|
||||||
|
class Debug
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
|
Text *text; // Objeto encargado de escribir texto en pantalla
|
||||||
|
std::vector<std::string> slot; // Vector con los textos a escribir
|
||||||
|
int x; // Posicion donde escribir el texto de debug
|
||||||
|
int y; // Posición donde escribir el texto de debug
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
Debug(SDL_Renderer *renderer, Screen *screen, Asset *asset);
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~Debug();
|
||||||
|
|
||||||
|
// Actualiza las variables
|
||||||
|
void update();
|
||||||
|
|
||||||
|
// Dibuja en pantalla
|
||||||
|
void render();
|
||||||
|
|
||||||
|
// Establece la posición donde se colocará la información de debug
|
||||||
|
void setPos(SDL_Point p);
|
||||||
|
|
||||||
|
// Añade un texto para mostrar
|
||||||
|
void add(std::string text);
|
||||||
|
|
||||||
|
// Borra la información de debug
|
||||||
|
void clear();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
+13
-3
@@ -17,7 +17,7 @@ Director::Director(std::string path)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_LOGO;
|
section.name = SECTION_PROG_GAME;
|
||||||
section.subsection = 0;
|
section.subsection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ Director::Director(std::string path)
|
|||||||
options->filter = FILTER_NEAREST;
|
options->filter = FILTER_NEAREST;
|
||||||
options->vSync = true;
|
options->vSync = true;
|
||||||
options->screenWidth = GAMECANVAS_WIDTH * options->windowSize;
|
options->screenWidth = GAMECANVAS_WIDTH * options->windowSize;
|
||||||
options->screenHeight = GAMECANVAS_HEIGHT * options->windowSize;
|
options->screenHeight = GAMECANVAS_HEIGHT * options->windowSize;
|
||||||
options->integerScale = true;
|
options->integerScale = true;
|
||||||
options->keepAspect = true;
|
options->keepAspect = true;
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ Director::Director(std::string path)
|
|||||||
initInput();
|
initInput();
|
||||||
screen = new Screen(window, renderer, options, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
screen = new Screen(window, renderer, options, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||||
screen->setBorderColor(borderColor);
|
screen->setBorderColor(borderColor);
|
||||||
|
debug = new Debug(renderer, screen, asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
Director::~Director()
|
Director::~Director()
|
||||||
@@ -51,6 +52,7 @@ Director::~Director()
|
|||||||
delete asset;
|
delete asset;
|
||||||
delete input;
|
delete input;
|
||||||
delete screen;
|
delete screen;
|
||||||
|
delete debug;
|
||||||
|
|
||||||
SDL_DestroyRenderer(renderer);
|
SDL_DestroyRenderer(renderer);
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
@@ -164,11 +166,13 @@ bool Director::setFileList()
|
|||||||
asset->add("/data/room/03.room", room);
|
asset->add("/data/room/03.room", room);
|
||||||
asset->add("/data/room/04.room", room);
|
asset->add("/data/room/04.room", room);
|
||||||
asset->add("/data/room/05.room", room);
|
asset->add("/data/room/05.room", room);
|
||||||
|
asset->add("/data/room/06.room", room);
|
||||||
asset->add("/data/room/01.tmx", room);
|
asset->add("/data/room/01.tmx", room);
|
||||||
asset->add("/data/room/02.tmx", room);
|
asset->add("/data/room/02.tmx", room);
|
||||||
asset->add("/data/room/03.tmx", room);
|
asset->add("/data/room/03.tmx", room);
|
||||||
asset->add("/data/room/04.tmx", room);
|
asset->add("/data/room/04.tmx", room);
|
||||||
asset->add("/data/room/05.tmx", room);
|
asset->add("/data/room/05.tmx", room);
|
||||||
|
asset->add("/data/room/06.tmx", room);
|
||||||
|
|
||||||
asset->add("/media/tilesets/standard.png", bitmap);
|
asset->add("/media/tilesets/standard.png", bitmap);
|
||||||
|
|
||||||
@@ -188,6 +192,9 @@ bool Director::setFileList()
|
|||||||
|
|
||||||
asset->add("/media/music/title.ogg", music);
|
asset->add("/media/music/title.ogg", music);
|
||||||
asset->add("/media/music/game.ogg", music);
|
asset->add("/media/music/game.ogg", music);
|
||||||
|
asset->add("/media/music/loading_sound1.ogg", music);
|
||||||
|
asset->add("/media/music/loading_sound2.ogg", music);
|
||||||
|
asset->add("/media/music/loading_sound3.ogg", music);
|
||||||
|
|
||||||
asset->add("/media/sound/item.wav", sound);
|
asset->add("/media/sound/item.wav", sound);
|
||||||
|
|
||||||
@@ -230,6 +237,9 @@ void Director::runLogo()
|
|||||||
// Ejecuta la seccion de juego de la introducción
|
// Ejecuta la seccion de juego de la introducción
|
||||||
void Director::runIntro()
|
void Director::runIntro()
|
||||||
{
|
{
|
||||||
|
intro = new Intro(renderer, screen, asset);
|
||||||
|
setSection(intro->run());
|
||||||
|
delete intro;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta la seccion de juego con el titulo y los menus
|
// Ejecuta la seccion de juego con el titulo y los menus
|
||||||
@@ -243,7 +253,7 @@ void Director::runTitle()
|
|||||||
// Ejecuta la seccion de juego donde se juega
|
// Ejecuta la seccion de juego donde se juega
|
||||||
void Director::runGame()
|
void Director::runGame()
|
||||||
{
|
{
|
||||||
game = new Game(renderer, screen, asset, input);
|
game = new Game(renderer, screen, asset, input, debug);
|
||||||
setSection(game->run());
|
setSection(game->run());
|
||||||
delete game;
|
delete game;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "logo.h"
|
#include "logo.h"
|
||||||
#include "title.h"
|
#include "title.h"
|
||||||
|
#include "intro.h"
|
||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
|
#include "debug.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
|
||||||
#ifndef DIRECTOR_H
|
#ifndef DIRECTOR_H
|
||||||
@@ -26,7 +28,9 @@ private:
|
|||||||
Game *game; // Objeto para gestionar la sección del juego
|
Game *game; // Objeto para gestionar la sección del juego
|
||||||
Logo *logo; // Objeto para gestionar la sección del logo del programa
|
Logo *logo; // Objeto para gestionar la sección del logo del programa
|
||||||
Title *title; // Objeto para gestionar la pantalla de título
|
Title *title; // Objeto para gestionar la pantalla de título
|
||||||
|
Intro *intro; // Onjeto para gestionar la introducción del juego
|
||||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
|
Debug *debug; // Objeto para getsionar la información de debug
|
||||||
|
|
||||||
struct options_t *options; // Variable con todas las opciones del programa
|
struct options_t *options; // Variable con todas las opciones del programa
|
||||||
|
|
||||||
|
|||||||
+61
-153
@@ -1,36 +1,42 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input)
|
Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Debug *debug)
|
||||||
{
|
{
|
||||||
// Inicia variables
|
// Inicia algunas variables
|
||||||
clock = SDL_GetTicks();
|
clock = SDL_GetTicks();
|
||||||
currentRoom = "01.room";
|
currentRoom = "01.room";
|
||||||
spawnPoint = {2 * 8, 12 * 8, 0, 0, 0, STATUS_STANDING, SDL_FLIP_NONE};
|
spawnPoint = {16, 96, 0, 0, 0, s_standing, SDL_FLIP_NONE};
|
||||||
debug = false;
|
|
||||||
|
currentRoom = "06.room";
|
||||||
|
spawnPoint = {240, 96, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
||||||
|
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
|
this->debug = debug;
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
scoreboard = new ScoreBoard(renderer, asset, &playerLives, &itemsPicked, &clock);
|
scoreboard = new ScoreBoard(renderer, asset, &playerLives, &itemsPicked, &clock);
|
||||||
itemTracker = new ItemTracker();
|
itemTracker = new ItemTracker();
|
||||||
room = new Room(asset->get(currentRoom), renderer, asset, itemTracker, &itemsPicked);
|
room = new Room(asset->get(currentRoom), renderer, screen, asset, itemTracker, &itemsPicked, debug);
|
||||||
player = new Player(spawnPoint, asset->get("player01.png"), asset->get("player01.ani"), renderer, asset, input, room);
|
player = new Player(spawnPoint, asset->get("player01.png"), asset->get("player01.ani"), renderer, asset, input, room, debug);
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
||||||
debugText = new Text(asset->get("debug.png"), asset->get("debug.txt"), renderer);
|
|
||||||
music = JA_LoadMusic(asset->get("game.ogg").c_str());
|
music = JA_LoadMusic(asset->get("game.ogg").c_str());
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa el resto de variables
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
playerLives = 9;
|
playerLives = 9;
|
||||||
itemsPicked = 0;
|
itemsPicked = 0;
|
||||||
|
|
||||||
|
debugEnabled = true;
|
||||||
|
player->setInvincible(debugEnabled);
|
||||||
|
musicEnabled = !debugEnabled;
|
||||||
|
|
||||||
section.name = SECTION_PROG_GAME;
|
section.name = SECTION_PROG_GAME;
|
||||||
section.subsection = SUBSECTION_GAME_PLAY;
|
section.subsection = SUBSECTION_GAME_PLAY;
|
||||||
}
|
}
|
||||||
@@ -44,25 +50,11 @@ Game::~Game()
|
|||||||
|
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
delete scoreboard;
|
delete scoreboard;
|
||||||
scoreboard = nullptr;
|
|
||||||
|
|
||||||
delete itemTracker;
|
delete itemTracker;
|
||||||
itemTracker = nullptr;
|
|
||||||
|
|
||||||
delete room;
|
delete room;
|
||||||
room = nullptr;
|
|
||||||
|
|
||||||
delete player;
|
delete player;
|
||||||
player = nullptr;
|
|
||||||
|
|
||||||
delete eventHandler;
|
delete eventHandler;
|
||||||
eventHandler = nullptr;
|
|
||||||
|
|
||||||
delete text;
|
delete text;
|
||||||
text = nullptr;
|
|
||||||
|
|
||||||
delete debugText;
|
|
||||||
debugText = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los eventos de la cola
|
// Comprueba los eventos de la cola
|
||||||
@@ -75,6 +67,7 @@ void Game::checkEventHandler()
|
|||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section.name = SECTION_PROG_QUIT;
|
||||||
|
screen->setBorderColor(stringToColor("black"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0))
|
else if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0))
|
||||||
@@ -86,7 +79,10 @@ void Game::checkEventHandler()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_D:
|
case SDL_SCANCODE_D:
|
||||||
debug = !debug;
|
debugEnabled = !debugEnabled;
|
||||||
|
player->setInvincible(debugEnabled);
|
||||||
|
musicEnabled = !debugEnabled;
|
||||||
|
musicEnabled ? JA_PlayMusic(music) : JA_StopMusic();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_M:
|
case SDL_SCANCODE_M:
|
||||||
@@ -128,7 +124,10 @@ void Game::checkEventHandler()
|
|||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
section_t Game::run()
|
section_t Game::run()
|
||||||
{
|
{
|
||||||
JA_PlayMusic(music);
|
if (musicEnabled)
|
||||||
|
{
|
||||||
|
JA_PlayMusic(music);
|
||||||
|
}
|
||||||
|
|
||||||
while (section.name == SECTION_PROG_GAME)
|
while (section.name == SECTION_PROG_GAME)
|
||||||
{
|
{
|
||||||
@@ -158,16 +157,14 @@ void Game::update()
|
|||||||
checkEventHandler();
|
checkEventHandler();
|
||||||
|
|
||||||
// Actualiza los objetos
|
// Actualiza los objetos
|
||||||
|
debug->clear();
|
||||||
room->update();
|
room->update();
|
||||||
{
|
player->update();
|
||||||
player->update();
|
|
||||||
checkPlayerAndWalls(); // Debe ir detras del player update, por si se ha metido en algun muro
|
|
||||||
}
|
|
||||||
checkPlayerOnBorder();
|
checkPlayerOnBorder();
|
||||||
checkPlayerOnFloor();
|
|
||||||
checkPlayerAndItems();
|
checkPlayerAndItems();
|
||||||
checkPlayerAndEnemies();
|
checkPlayerAndEnemies();
|
||||||
scoreboard->update();
|
scoreboard->update();
|
||||||
|
updateDebugInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,14 +189,27 @@ void Game::render()
|
|||||||
screen->blit();
|
screen->blit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pasa la información de debug
|
||||||
|
void Game::updateDebugInfo()
|
||||||
|
{
|
||||||
|
debug->add("X = " + std::to_string((int)player->x) + ", Y = " + std::to_string((int)player->y));
|
||||||
|
debug->add("VX = " + std::to_string(player->vx).substr(0,4) + ", VY = " + std::to_string(player->vy).substr(0,4));
|
||||||
|
debug->add("STATE = " + std::to_string(player->state));
|
||||||
|
}
|
||||||
|
|
||||||
// Pone la información de debug en pantalla
|
// Pone la información de debug en pantalla
|
||||||
void Game::renderDebugInfo()
|
void Game::renderDebugInfo()
|
||||||
{
|
{
|
||||||
if (!debug)
|
if (!debugEnabled)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Borra el marcador
|
||||||
|
SDL_Rect rect = {0, 18 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT};
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
// Pinta la rejilla
|
// Pinta la rejilla
|
||||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 64);
|
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 64);
|
||||||
for (int i = 0; i < PLAY_AREA_BOTTOM; i += 8)
|
for (int i = 0; i < PLAY_AREA_BOTTOM; i += 8)
|
||||||
@@ -211,37 +221,26 @@ void Game::renderDebugInfo()
|
|||||||
SDL_RenderDrawLine(renderer, i, 0, i, PLAY_AREA_BOTTOM - 1);
|
SDL_RenderDrawLine(renderer, i, 0, i, PLAY_AREA_BOTTOM - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pinta mascaras de sprite
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 192);
|
||||||
|
rect = player->getRect();
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
// Pinta el texto
|
// Pinta el texto
|
||||||
std::string text;
|
debug->setPos({1, 18 * 8});
|
||||||
const int inc = debugText->getCharacterWidth() + 1;
|
debug->render();
|
||||||
int line = 131;
|
|
||||||
|
|
||||||
text = "status: " + std::to_string(player->status);
|
|
||||||
debugText->write(0, line += inc, text);
|
|
||||||
|
|
||||||
text = "foot: " + std::to_string((int)player->getLeftFoot().y);
|
|
||||||
debugText->write(0, line += inc, text);
|
|
||||||
|
|
||||||
const int a = (player->lastPosition.y + 16) / 8;
|
|
||||||
const int b = player->getLeftFoot().y / 8;
|
|
||||||
text = "tile: " + std::to_string(a) + " - " + std::to_string(b);
|
|
||||||
debugText->write(0, line += inc, text);
|
|
||||||
|
|
||||||
const bool collision = checkPlayerAndEnemies();
|
|
||||||
text = "collision: " + std::to_string(collision);
|
|
||||||
debugText->write(0, line += inc, text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el nombre de la pantalla
|
// Escribe el nombre de la pantalla
|
||||||
void Game::renderRoomName()
|
void Game::renderRoomName()
|
||||||
{
|
{
|
||||||
// Texto en el centro de la pantalla
|
// Texto en el centro de la pantalla
|
||||||
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK};
|
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2};
|
||||||
color_t color = stringToColor("light_black");
|
color_t color = stringToColor("white");
|
||||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
||||||
SDL_RenderFillRect(renderer, &rect);
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
text->writeCentered(GAMECANVAS_CENTER_X, 16 * 8, room->getName());
|
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, 16 * 8 + 4, room->getName(), 1, room->getBGColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia de habitación
|
// Cambia de habitación
|
||||||
@@ -259,7 +258,10 @@ bool Game::changeRoom(std::string file)
|
|||||||
room = nullptr;
|
room = nullptr;
|
||||||
|
|
||||||
// Crea un objeto habitación nuevo a partir del fichero
|
// 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, debug);
|
||||||
|
|
||||||
|
// Pasa la nueva habitación al jugador
|
||||||
|
player->setRoom(room);
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@@ -282,105 +284,6 @@ void Game::checkPlayerOnBorder()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si el jugador esta sobre el suelo
|
|
||||||
void Game::checkPlayerOnFloor()
|
|
||||||
{
|
|
||||||
// Comprueba si tiene suelo bajo los pies solo cuando no hay velocidad de subida
|
|
||||||
// y solo cuando el pie este encima de un bloque, es decir, en multiplos de 8
|
|
||||||
|
|
||||||
// *** HAY UN POSIBLE PROBLEMA y es que caiga muy rapido y viaje a mas de un pixel de velocidad,
|
|
||||||
// con lo que se saltaria la comprobación
|
|
||||||
|
|
||||||
// *** POSIBLE SOLUCION. Comprobar si el tile actual del pie es diferente al tile del pie previo.
|
|
||||||
// Esto indica que se ha saltado la comprobacion cada 8 pixeles.
|
|
||||||
// En este caso habría que recolocar al jugador en el sitio
|
|
||||||
|
|
||||||
// *** PARECE RESUELTO
|
|
||||||
|
|
||||||
const int a = (player->lastPosition.y + 16) / 8;
|
|
||||||
const int b = player->getLeftFoot().y / 8;
|
|
||||||
const bool tile_change = a != b;
|
|
||||||
|
|
||||||
const bool is_not_going_up = player->getVelY() >= 0;
|
|
||||||
const bool is_tile_aligned = player->getLeftFoot().y % 8 == 0;
|
|
||||||
|
|
||||||
if (((is_not_going_up) && (is_tile_aligned)) || ((is_not_going_up) && (tile_change)))
|
|
||||||
{
|
|
||||||
bool test = false;
|
|
||||||
test |= (room->getTile(player->getLeftFoot()) == TILE_SOLID);
|
|
||||||
test |= (room->getTile(player->getRightFoot()) == TILE_SOLID);
|
|
||||||
test |= (room->getTile(player->getLeftFoot()) == TILE_TRAVESSABLE);
|
|
||||||
test |= (room->getTile(player->getRightFoot()) == TILE_TRAVESSABLE);
|
|
||||||
|
|
||||||
// Tiene uno de los pies sobre una superficie
|
|
||||||
if (test)
|
|
||||||
{
|
|
||||||
player->setStatus(STATUS_STANDING);
|
|
||||||
|
|
||||||
// Si ha habido un cambio de tile, hay que recolocarlo
|
|
||||||
if (tile_change)
|
|
||||||
{
|
|
||||||
int offset = (int)player->sprite->getPosY() % 8;
|
|
||||||
player->sprite->setPosY((int)player->sprite->getPosY() - offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Tiene ambos pies sobre el vacío
|
|
||||||
else if (player->getStatus() != STATUS_JUMPING)
|
|
||||||
{
|
|
||||||
player->setStatus(STATUS_FALLING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba que el jugador no atraviese ninguna pared
|
|
||||||
void Game::checkPlayerAndWalls()
|
|
||||||
{
|
|
||||||
// Obtiene los ocho puntos de colisión del jugador
|
|
||||||
const SDL_Rect rect = player->getRect();
|
|
||||||
const SDL_Point p1 = {rect.x, rect.y};
|
|
||||||
const SDL_Point p2 = {rect.x + 7, rect.y};
|
|
||||||
const SDL_Point p3 = {rect.x + 7, rect.y + 7};
|
|
||||||
const SDL_Point p4 = {rect.x, rect.y + 7};
|
|
||||||
const SDL_Point p5 = {rect.x, rect.y + 8};
|
|
||||||
const SDL_Point p6 = {rect.x + 7, rect.y + 8};
|
|
||||||
const SDL_Point p7 = {rect.x + 7, rect.y + 15};
|
|
||||||
const SDL_Point p8 = {rect.x, rect.y + 15};
|
|
||||||
|
|
||||||
// Comprueba si ha colisionado con un muro
|
|
||||||
bool wall = false;
|
|
||||||
wall |= (room->getTile(p1) == TILE_SOLID);
|
|
||||||
wall |= (room->getTile(p2) == TILE_SOLID);
|
|
||||||
wall |= (room->getTile(p3) == TILE_SOLID);
|
|
||||||
wall |= (room->getTile(p4) == TILE_SOLID);
|
|
||||||
wall |= (room->getTile(p5) == TILE_SOLID);
|
|
||||||
wall |= (room->getTile(p6) == TILE_SOLID);
|
|
||||||
wall |= (room->getTile(p7) == TILE_SOLID);
|
|
||||||
wall |= (room->getTile(p8) == TILE_SOLID);
|
|
||||||
|
|
||||||
if (wall)
|
|
||||||
{
|
|
||||||
// Si hay colisión, deshace el movimiento y lo pone en modo caída
|
|
||||||
player->undoLastMove();
|
|
||||||
player->setStatus(STATUS_FALLING);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba si ha colisionado con un tile de los que matan al jugador
|
|
||||||
bool death = false;
|
|
||||||
death |= (room->getTile(p1) == TILE_KILL);
|
|
||||||
death |= (room->getTile(p2) == TILE_KILL);
|
|
||||||
death |= (room->getTile(p3) == TILE_KILL);
|
|
||||||
death |= (room->getTile(p4) == TILE_KILL);
|
|
||||||
death |= (room->getTile(p5) == TILE_KILL);
|
|
||||||
death |= (room->getTile(p6) == TILE_KILL);
|
|
||||||
death |= (room->getTile(p7) == TILE_KILL);
|
|
||||||
death |= (room->getTile(p8) == TILE_KILL);
|
|
||||||
|
|
||||||
if (death)
|
|
||||||
{
|
|
||||||
killPlayer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba las colisiones del jugador con los enemigos
|
// Comprueba las colisiones del jugador con los enemigos
|
||||||
bool Game::checkPlayerAndEnemies()
|
bool Game::checkPlayerAndEnemies()
|
||||||
{
|
{
|
||||||
@@ -401,6 +304,11 @@ void Game::checkPlayerAndItems()
|
|||||||
// Mata al jugador
|
// Mata al jugador
|
||||||
void Game::killPlayer()
|
void Game::killPlayer()
|
||||||
{
|
{
|
||||||
|
if (player->getInvincible())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
playerLives--;
|
playerLives--;
|
||||||
|
|
||||||
// Destruye la habitacion y el jugador
|
// Destruye la habitacion y el jugador
|
||||||
@@ -408,8 +316,8 @@ void Game::killPlayer()
|
|||||||
delete player;
|
delete player;
|
||||||
|
|
||||||
// Crea la nueva habitación y el nuevo jugador
|
// 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, debug);
|
||||||
player = new Player(spawnPoint, asset->get("player01.png"), asset->get("player01.ani"), renderer, asset, input, room);
|
player = new Player(spawnPoint, asset->get("player01.png"), asset->get("player01.ani"), renderer, asset, input, room, debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recarga todas las texturas
|
// Recarga todas las texturas
|
||||||
|
|||||||
+8
-9
@@ -13,6 +13,7 @@
|
|||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "jail_audio.h"
|
#include "jail_audio.h"
|
||||||
#include "scoreboard.h"
|
#include "scoreboard.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#ifndef GAME_H
|
#ifndef GAME_H
|
||||||
#define GAME_H
|
#define GAME_H
|
||||||
@@ -30,15 +31,16 @@ private:
|
|||||||
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
||||||
Input *input; // Objeto pata gestionar la entrada
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Text *text; // Objeto para los textos del juego
|
Text *text; // Objeto para los textos del juego
|
||||||
Text *debugText; // Objeto para los textos de debug del juego
|
|
||||||
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
||||||
JA_Music music; // Musica que suena durante el juego
|
JA_Music music; // Musica que suena durante el juego
|
||||||
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
|
bool musicEnabled; // Indica si ha de sonar la musica durante el juego
|
||||||
int ticks; // Contador de ticks para ajustar la velocidad del programa
|
int ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
int ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
int ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
section_t section; // Seccion actual dentro del juego
|
section_t section; // Seccion actual dentro del juego
|
||||||
std::string currentRoom; // Fichero de la habitación actual
|
std::string currentRoom; // Fichero de la habitación actual
|
||||||
player_t spawnPoint; // Lugar de la habitación donde aparece el jugador
|
player_t spawnPoint; // Lugar de la habitación donde aparece el jugador
|
||||||
bool debug; // Indica si el modo debug está activo
|
bool debugEnabled; // Indica si el modo debug está activo
|
||||||
int playerLives; // Lleva la cuenta de ls vidas restantes del jugador
|
int playerLives; // Lleva la cuenta de ls vidas restantes del jugador
|
||||||
int itemsPicked; // Lleva la cuenta de los objetos recogidos
|
int itemsPicked; // Lleva la cuenta de los objetos recogidos
|
||||||
Uint32 clock; // Cuenta el tiempo que dura la partida
|
Uint32 clock; // Cuenta el tiempo que dura la partida
|
||||||
@@ -52,6 +54,9 @@ private:
|
|||||||
// Comprueba los eventos de la cola
|
// Comprueba los eventos de la cola
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Pone la información de debug en pantalla
|
||||||
|
void updateDebugInfo();
|
||||||
|
|
||||||
// Pone la información de debug en pantalla
|
// Pone la información de debug en pantalla
|
||||||
void renderDebugInfo();
|
void renderDebugInfo();
|
||||||
|
|
||||||
@@ -64,12 +69,6 @@ private:
|
|||||||
// Comprueba si el jugador esta en el borde de la pantalla y actua
|
// Comprueba si el jugador esta en el borde de la pantalla y actua
|
||||||
void checkPlayerOnBorder();
|
void checkPlayerOnBorder();
|
||||||
|
|
||||||
// Comprueba si el jugador esta sobre el suelo
|
|
||||||
void checkPlayerOnFloor();
|
|
||||||
|
|
||||||
// Comprueba que el jugador no atraviese ninguna pared
|
|
||||||
void checkPlayerAndWalls();
|
|
||||||
|
|
||||||
// Comprueba las colisiones del jugador con los enemigos
|
// Comprueba las colisiones del jugador con los enemigos
|
||||||
bool checkPlayerAndEnemies();
|
bool checkPlayerAndEnemies();
|
||||||
|
|
||||||
@@ -84,7 +83,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input);
|
Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Game();
|
~Game();
|
||||||
|
|||||||
+1
-1
@@ -177,7 +177,7 @@ bool Input::discoverGameController()
|
|||||||
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
|
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
//mGameController = mConnectedControllers[0];
|
// mGameController = mConnectedControllers[0];
|
||||||
SDL_GameControllerEventState(SDL_ENABLE);
|
SDL_GameControllerEventState(SDL_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -49,8 +49,8 @@ private:
|
|||||||
};
|
};
|
||||||
GameControllerBindings_t mGameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
GameControllerBindings_t mGameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
||||||
|
|
||||||
//SDL_GameController *mGameController; // Manejador para el mando
|
// SDL_GameController *mGameController; // Manejador para el mando
|
||||||
std::vector<SDL_GameController*> mConnectedControllers;
|
std::vector<SDL_GameController *> mConnectedControllers;
|
||||||
std::vector<std::string> mControllerNames;
|
std::vector<std::string> mControllerNames;
|
||||||
int mNumGamepads;
|
int mNumGamepads;
|
||||||
std::string mDBpath; // Ruta al archivo gamecontrollerdb.txt
|
std::string mDBpath; // Ruta al archivo gamecontrollerdb.txt
|
||||||
@@ -72,7 +72,7 @@ public:
|
|||||||
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
||||||
|
|
||||||
// Comprueba si un input esta activo
|
// 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
|
// Comprueba si hay algun mando conectado
|
||||||
bool gameControllerFound();
|
bool gameControllerFound();
|
||||||
|
|||||||
@@ -0,0 +1,239 @@
|
|||||||
|
#include "intro.h"
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||||
|
{
|
||||||
|
// Copia la dirección de los objetos
|
||||||
|
this->renderer = renderer;
|
||||||
|
this->screen = screen;
|
||||||
|
this->asset = asset;
|
||||||
|
|
||||||
|
// Reserva memoria para los punteros
|
||||||
|
eventHandler = new SDL_Event();
|
||||||
|
texture = new LTexture(renderer, asset->get("loading_screen1.png"));
|
||||||
|
texture2 = new LTexture(renderer, asset->get("loading_screen2.png"));
|
||||||
|
sprite = new Sprite(0, 0, texture->getWidth(), texture->getHeight(), texture, renderer);
|
||||||
|
sprite2 = new Sprite(0, 0, texture2->getWidth(), texture2->getHeight(), texture2, renderer);
|
||||||
|
loadingSound1 = JA_LoadMusic(asset->get("loading_sound1.ogg").c_str());
|
||||||
|
loadingSound2 = JA_LoadMusic(asset->get("loading_sound2.ogg").c_str());
|
||||||
|
loadingSound3 = JA_LoadMusic(asset->get("loading_sound3.ogg").c_str());
|
||||||
|
|
||||||
|
// Inicializa variables
|
||||||
|
preCounter = 0;
|
||||||
|
counter = 0;
|
||||||
|
section.name = SECTION_PROG_INTRO;
|
||||||
|
section.subsection = 0;
|
||||||
|
ticks = 0;
|
||||||
|
ticksSpeed = 15;
|
||||||
|
loadCounter = 0;
|
||||||
|
loadCounter = 0;
|
||||||
|
load1 = true;
|
||||||
|
load2 = false;
|
||||||
|
|
||||||
|
// Cambia el color del borde
|
||||||
|
screen->setBorderColor(stringToColor("black"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
Intro::~Intro()
|
||||||
|
{
|
||||||
|
delete texture;
|
||||||
|
delete texture2;
|
||||||
|
delete sprite;
|
||||||
|
delete sprite2;
|
||||||
|
delete eventHandler;
|
||||||
|
JA_DeleteMusic(loadingSound1);
|
||||||
|
JA_DeleteMusic(loadingSound2);
|
||||||
|
JA_DeleteMusic(loadingSound3);
|
||||||
|
|
||||||
|
// delete text;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
void Intro::checkEventHandler()
|
||||||
|
{
|
||||||
|
// Comprueba los eventos que hay en la cola
|
||||||
|
while (SDL_PollEvent(eventHandler) != 0)
|
||||||
|
{
|
||||||
|
// Evento de salida de la aplicación
|
||||||
|
if (eventHandler->type == SDL_QUIT)
|
||||||
|
{
|
||||||
|
section.name = SECTION_PROG_QUIT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cualquier tecla pulsada
|
||||||
|
if ((eventHandler->type == SDL_KEYDOWN) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
||||||
|
{
|
||||||
|
section.name = SECTION_PROG_TITLE;
|
||||||
|
section.subsection = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gestiona el contador de carga
|
||||||
|
void Intro::updateLoad()
|
||||||
|
{
|
||||||
|
if (load1)
|
||||||
|
{
|
||||||
|
loadCounter = counter / 20;
|
||||||
|
if (loadCounter == 25)
|
||||||
|
{
|
||||||
|
load1 = false;
|
||||||
|
load2 = true;
|
||||||
|
loadCounter = 0;
|
||||||
|
JA_PlayMusic(loadingSound3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
loadCounter += 2;
|
||||||
|
loadCounter = std::min(loadCounter, 768);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gestiona el contador interno
|
||||||
|
void Intro::updateCounter()
|
||||||
|
{
|
||||||
|
if (preCounter >= 50)
|
||||||
|
{
|
||||||
|
if (counter == 0)
|
||||||
|
{
|
||||||
|
JA_PlayMusic(loadingSound2);
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
preCounter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dibuja la pantalla de carga
|
||||||
|
void Intro::renderLoad()
|
||||||
|
{
|
||||||
|
// Carga 1 - Blanco y negro
|
||||||
|
if (load1)
|
||||||
|
{
|
||||||
|
sprite->render();
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
|
|
||||||
|
// Muestra las lineas 0..63
|
||||||
|
if (loadCounter < 8)
|
||||||
|
{
|
||||||
|
SDL_Rect rect = {0, 0 + loadCounter, 256, 8 - loadCounter};
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
rect.y += 8;
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
}
|
||||||
|
rect.y += 8;
|
||||||
|
rect.h = 128;
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
}
|
||||||
|
// Muestra las lineas 64..127
|
||||||
|
else if (loadCounter >= 8 && loadCounter < 16)
|
||||||
|
{
|
||||||
|
SDL_Rect rect = {0, 64 + (loadCounter - 8), 256, 8 - (loadCounter - 8)};
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
rect.y += 8;
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
}
|
||||||
|
rect.y += 8;
|
||||||
|
rect.h = 64;
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
}
|
||||||
|
// Muestra las lineas 128..191
|
||||||
|
else if (loadCounter >= 16 && loadCounter < 23)
|
||||||
|
{
|
||||||
|
SDL_Rect rect = {0, 128 + (loadCounter - 16), 256, 8 - (loadCounter - 16)};
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
rect.y += 8;
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// Carga 2 - Color
|
||||||
|
{
|
||||||
|
sprite->render();
|
||||||
|
SDL_Rect rect = {0, 0, 8, 8};
|
||||||
|
for (int i = 0; i < loadCounter; i++)
|
||||||
|
{
|
||||||
|
rect.x = (i * 8) % 256;
|
||||||
|
rect.y = (i / 32) * 8;
|
||||||
|
sprite2->setPos(rect);
|
||||||
|
sprite2->setSpriteClip(rect);
|
||||||
|
sprite2->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza las variables
|
||||||
|
void Intro::update()
|
||||||
|
{
|
||||||
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
|
{
|
||||||
|
// Actualiza el contador de ticks
|
||||||
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
checkEventHandler();
|
||||||
|
|
||||||
|
// Gestiona el contador interno
|
||||||
|
updateCounter();
|
||||||
|
|
||||||
|
// Gestiona el contador de carga
|
||||||
|
updateLoad();
|
||||||
|
|
||||||
|
// Comprueba si ha terminado la intro
|
||||||
|
if (loadCounter >= 768)
|
||||||
|
{
|
||||||
|
section.name = SECTION_PROG_TITLE;
|
||||||
|
section.subsection = 0;
|
||||||
|
JA_StopMusic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dibuja en pantalla
|
||||||
|
void Intro::render()
|
||||||
|
{
|
||||||
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
|
screen->start();
|
||||||
|
|
||||||
|
// Limpia la pantalla
|
||||||
|
screen->clean();
|
||||||
|
|
||||||
|
// Dibuja la pantalla de carga
|
||||||
|
renderLoad();
|
||||||
|
// text->write(0, 0, std::to_string(loadCounter));
|
||||||
|
// text->write(0, 8, std::to_string(loadCounter));
|
||||||
|
|
||||||
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
|
screen->blit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bucle para el logo del juego
|
||||||
|
section_t Intro::run()
|
||||||
|
{
|
||||||
|
// Inicia el sonido de carga
|
||||||
|
JA_PlayMusic(loadingSound1);
|
||||||
|
|
||||||
|
while (section.name == SECTION_PROG_INTRO)
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
render();
|
||||||
|
}
|
||||||
|
|
||||||
|
return section;
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include "const.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "sprite.h"
|
||||||
|
#include "screen.h"
|
||||||
|
#include "asset.h"
|
||||||
|
#include "jail_audio.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "text.h"
|
||||||
|
|
||||||
|
#ifndef INTRO_H
|
||||||
|
#define INTRO_H
|
||||||
|
|
||||||
|
// Clase Intro
|
||||||
|
class Intro
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
|
LTexture *texture; // Textura con los graficos "JAILGAMES"
|
||||||
|
LTexture *texture2; // Textura con los graficos "Since 1998"
|
||||||
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
|
Sprite *sprite; // Sprite para manejar la textura
|
||||||
|
Sprite *sprite2; // Sprite para manejar la textura2
|
||||||
|
int preCounter; // Contador previo para realizar una pausa inicial
|
||||||
|
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
|
||||||
|
int ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
|
int loadCounter; // Contador para controlar las cargas
|
||||||
|
bool load1, load2;
|
||||||
|
JA_Music loadingSound1, loadingSound2, loadingSound3;
|
||||||
|
|
||||||
|
// Text *text;
|
||||||
|
|
||||||
|
// Actualiza las variables
|
||||||
|
void update();
|
||||||
|
|
||||||
|
// Dibuja en pantalla
|
||||||
|
void render();
|
||||||
|
|
||||||
|
// Comprueba el manejador de eventos
|
||||||
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Gestiona el contador interno
|
||||||
|
void updateCounter();
|
||||||
|
|
||||||
|
// Gestiona el contador de carga
|
||||||
|
void updateLoad();
|
||||||
|
|
||||||
|
// Dibuja la pantalla de carga
|
||||||
|
void renderLoad();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset);
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~Intro();
|
||||||
|
|
||||||
|
// Bucle principal
|
||||||
|
section_t run();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
+2
-2
@@ -10,7 +10,7 @@ Item::Item(item_t item)
|
|||||||
renderer = item.renderer;
|
renderer = item.renderer;
|
||||||
|
|
||||||
// Crea objetos
|
// 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);
|
sprite = new Sprite(item.x, item.y, 8, 8, texture, renderer);
|
||||||
|
|
||||||
// Inicia variables
|
// Inicia variables
|
||||||
@@ -26,7 +26,7 @@ Item::Item(item_t item)
|
|||||||
c = stringToColor("red");
|
c = stringToColor("red");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("purple");
|
c = stringToColor("magenta");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("green");
|
c = stringToColor("green");
|
||||||
|
|||||||
+119
-106
@@ -49,7 +49,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
|||||||
c = stringToColor("red");
|
c = stringToColor("red");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("purple");
|
c = stringToColor("magenta");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("green");
|
c = stringToColor("green");
|
||||||
@@ -61,8 +61,11 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
|||||||
c = stringToColor("yellow");
|
c = stringToColor("yellow");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("light_white");
|
c = stringToColor("bright_white");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
|
// Cambia el color del borde
|
||||||
|
screen->setBorderColor(stringToColor("black"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -102,6 +105,115 @@ void Logo::checkEventHandler()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gestiona el logo de JAILGAME
|
||||||
|
void Logo::updateJAILGAMES()
|
||||||
|
{
|
||||||
|
if (counter > 30)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < sprite.size(); i++)
|
||||||
|
{
|
||||||
|
const int speed = 8;
|
||||||
|
const int dest = 37;
|
||||||
|
if (sprite[i]->getPosX() != 37)
|
||||||
|
{
|
||||||
|
if (i % 2 == 0)
|
||||||
|
{
|
||||||
|
sprite[i]->incPosX(-speed);
|
||||||
|
if (sprite[i]->getPosX() < dest)
|
||||||
|
{
|
||||||
|
sprite[i]->setPosX(dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprite[i]->incPosX(speed);
|
||||||
|
if (sprite[i]->getPosX() > dest)
|
||||||
|
{
|
||||||
|
sprite[i]->setPosX(dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gestiona el color de las texturas
|
||||||
|
void Logo::updateTextureColors()
|
||||||
|
{
|
||||||
|
const int ini = 70;
|
||||||
|
const int inc = 4;
|
||||||
|
|
||||||
|
if (counter == ini + inc * 0)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
|
}
|
||||||
|
else if (counter == ini + inc * 1)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
|
}
|
||||||
|
else if (counter == ini + inc * 2)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
|
}
|
||||||
|
else if (counter == ini + inc * 3)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
|
}
|
||||||
|
else if (counter == ini + inc * 4)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
|
}
|
||||||
|
else if (counter == ini + inc * 5)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
|
}
|
||||||
|
else if (counter == ini + inc * 6)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == ini + inc * 7)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[7].r, color[7].g, color[7].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == initFade + inc * 0)
|
||||||
|
{
|
||||||
|
texture->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
|
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
|
}
|
||||||
|
else if (counter == initFade + inc * 1)
|
||||||
|
{
|
||||||
|
texture->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
|
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
|
}
|
||||||
|
else if (counter == initFade + inc * 2)
|
||||||
|
{
|
||||||
|
texture->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
|
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
|
}
|
||||||
|
else if (counter == initFade + inc * 3)
|
||||||
|
{
|
||||||
|
texture->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
|
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
|
}
|
||||||
|
else if (counter == initFade + inc * 4)
|
||||||
|
{
|
||||||
|
texture->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
|
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
|
}
|
||||||
|
else if (counter == initFade + inc * 5)
|
||||||
|
{
|
||||||
|
texture->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
|
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
|
}
|
||||||
|
else if (counter == initFade + inc * 6)
|
||||||
|
{
|
||||||
|
texture->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
|
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void Logo::update()
|
void Logo::update()
|
||||||
{
|
{
|
||||||
@@ -117,115 +229,16 @@ void Logo::update()
|
|||||||
// Incrementa el contador
|
// Incrementa el contador
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
// update de JAILGAMES
|
// Gestiona el logo de JAILGAME
|
||||||
if (counter > 30)
|
updateJAILGAMES();
|
||||||
{
|
|
||||||
for (int i = 1; i < sprite.size(); i++)
|
|
||||||
{
|
|
||||||
const int speed = 8;
|
|
||||||
const int dest = 37;
|
|
||||||
if (sprite[i]->getPosX() != 37)
|
|
||||||
{
|
|
||||||
if (i % 2 == 0)
|
|
||||||
{
|
|
||||||
sprite[i]->incPosX(-speed);
|
|
||||||
if (sprite[i]->getPosX() < dest)
|
|
||||||
{
|
|
||||||
sprite[i]->setPosX(dest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprite[i]->incPosX(speed);
|
|
||||||
if (sprite[i]->getPosX() > dest)
|
|
||||||
{
|
|
||||||
sprite[i]->setPosX(dest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update de fade
|
// Gestiona el color de las texturas
|
||||||
{
|
updateTextureColors();
|
||||||
const int ini = 70;
|
|
||||||
const int inc = 4;
|
|
||||||
|
|
||||||
if (counter == ini + inc * 0)
|
|
||||||
{
|
|
||||||
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
|
||||||
}
|
|
||||||
else if (counter == ini + inc * 1)
|
|
||||||
{
|
|
||||||
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
|
||||||
}
|
|
||||||
else if (counter == ini + inc * 2)
|
|
||||||
{
|
|
||||||
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
|
||||||
}
|
|
||||||
else if (counter == ini + inc * 3)
|
|
||||||
{
|
|
||||||
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
|
||||||
}
|
|
||||||
else if (counter == ini + inc * 4)
|
|
||||||
{
|
|
||||||
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
|
||||||
}
|
|
||||||
else if (counter == ini + inc * 5)
|
|
||||||
{
|
|
||||||
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
|
||||||
}
|
|
||||||
else if (counter == ini + inc * 6)
|
|
||||||
{
|
|
||||||
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (counter == ini + inc * 7)
|
|
||||||
{
|
|
||||||
texture2->setColor(color[7].r, color[7].g, color[7].b);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (counter == initFade + inc * 0)
|
|
||||||
{
|
|
||||||
texture->setColor(color[6].r, color[6].g, color[6].b);
|
|
||||||
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
|
||||||
}
|
|
||||||
else if (counter == initFade + inc * 1)
|
|
||||||
{
|
|
||||||
texture->setColor(color[5].r, color[5].g, color[5].b);
|
|
||||||
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
|
||||||
}
|
|
||||||
else if (counter == initFade + inc * 2)
|
|
||||||
{
|
|
||||||
texture->setColor(color[4].r, color[4].g, color[4].b);
|
|
||||||
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
|
||||||
}
|
|
||||||
else if (counter == initFade + inc * 3)
|
|
||||||
{
|
|
||||||
texture->setColor(color[3].r, color[3].g, color[3].b);
|
|
||||||
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
|
||||||
}
|
|
||||||
else if (counter == initFade + inc * 4)
|
|
||||||
{
|
|
||||||
texture->setColor(color[2].r, color[2].g, color[2].b);
|
|
||||||
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
|
||||||
}
|
|
||||||
else if (counter == initFade + inc * 5)
|
|
||||||
{
|
|
||||||
texture->setColor(color[1].r, color[1].g, color[1].b);
|
|
||||||
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
|
||||||
}
|
|
||||||
else if (counter == initFade + inc * 6)
|
|
||||||
{
|
|
||||||
texture->setColor(color[0].r, color[0].g, color[0].b);
|
|
||||||
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba si ha terminado el logo
|
// Comprueba si ha terminado el logo
|
||||||
if (counter == endLogo + postLogo)
|
if (counter == endLogo + postLogo)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_TITLE;
|
section.name = SECTION_PROG_INTRO;
|
||||||
section.subsection = 0;
|
section.subsection = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -24,7 +24,7 @@ private:
|
|||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
||||||
Sprite *sprite2; // Sprite para manejar la textura2
|
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
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
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
|
int ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
@@ -42,6 +42,12 @@ private:
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Gestiona el logo de JAILGAME
|
||||||
|
void updateJAILGAMES();
|
||||||
|
|
||||||
|
// Gestiona el color de las texturas
|
||||||
|
void updateTextureColors();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset);
|
Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset);
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ private:
|
|||||||
SDL_Renderer *renderer; // Renderizador donde dibujar la textura
|
SDL_Renderer *renderer; // Renderizador donde dibujar la textura
|
||||||
int width; // Ancho de la imagen
|
int width; // Ancho de la imagen
|
||||||
int height; // Alto 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:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ Empezado en Castalla el 01/07/2022.
|
|||||||
int main(int argc, char *args[])
|
int main(int argc, char *args[])
|
||||||
{
|
{
|
||||||
printf("Starting the game...\n\n");
|
printf("Starting the game...\n\n");
|
||||||
|
|
||||||
// Crea el objeto Director
|
// Crea el objeto Director
|
||||||
Director *mDirector = new Director(args[0]);
|
Director *mDirector = new Director(args[0]);
|
||||||
|
|
||||||
|
|||||||
+377
-117
@@ -2,15 +2,15 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
// CAUTION!!!!! si no se gasta al final, quitar la referencia a la habitación
|
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Player::Player(player_t ini, std::string tileset, std::string animation, SDL_Renderer *renderer, Asset *asset, Input *input, Room *room)
|
Player::Player(player_t ini, std::string tileset, std::string animation, SDL_Renderer *renderer, Asset *asset, Input *input, Room *room, Debug *debug)
|
||||||
{
|
{
|
||||||
// Obten punteros a objetos
|
// Obten punteros a objetos
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
|
this->room = room;
|
||||||
|
this->debug = debug;
|
||||||
|
|
||||||
// Crea objetos
|
// Crea objetos
|
||||||
texture = new LTexture(renderer, asset->get(tileset));
|
texture = new LTexture(renderer, asset->get(tileset));
|
||||||
@@ -20,21 +20,34 @@ Player::Player(player_t ini, std::string tileset, std::string animation, SDL_Ren
|
|||||||
color = stringToColor("white");
|
color = stringToColor("white");
|
||||||
onBorder = false;
|
onBorder = false;
|
||||||
border = BORDER_TOP;
|
border = BORDER_TOP;
|
||||||
|
invincible = false;
|
||||||
|
|
||||||
jump_ini = ini.jump_ini;
|
jump_ini = ini.jump_ini;
|
||||||
status = ini.status;
|
state = ini.state;
|
||||||
|
|
||||||
|
x = ini.x;
|
||||||
|
y = ini.y;
|
||||||
|
vx = ini.vx;
|
||||||
|
vy = ini.vy;
|
||||||
|
w = 8;
|
||||||
|
h = 16;
|
||||||
|
maxVY = 1.2f;
|
||||||
|
|
||||||
sprite->setPosX(ini.x);
|
sprite->setPosX(ini.x);
|
||||||
sprite->setPosY(ini.y);
|
sprite->setPosY(ini.y);
|
||||||
sprite->setVelX(ini.vx);
|
|
||||||
sprite->setVelY(ini.vy);
|
|
||||||
sprite->setWidth(8);
|
sprite->setWidth(8);
|
||||||
sprite->setHeight(16);
|
sprite->setHeight(16);
|
||||||
|
|
||||||
sprite->setFlip(ini.flip);
|
sprite->setFlip(ini.flip);
|
||||||
|
sprite->setCurrentAnimation("walk");
|
||||||
|
sprite->animate();
|
||||||
|
|
||||||
lastPosition = getRect();
|
lastPosition = getRect();
|
||||||
collider = getRect();
|
colliderBox = getRect();
|
||||||
|
const SDL_Point p = {0, 0};
|
||||||
|
colliderPoints.insert(colliderPoints.end(), {p, p, p, p, p, p, p, p});
|
||||||
|
underFeet.insert(underFeet.end(), {p, p});
|
||||||
|
feet.insert(feet.end(), {p, p});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -54,38 +67,40 @@ void Player::render()
|
|||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
void Player::update()
|
void Player::update()
|
||||||
{
|
{
|
||||||
|
checkInput(); // Comprueba las entradas y modifica variables
|
||||||
setLastPosition(); // Guarda la posición actual en la variable lastPosition
|
move(); // Recalcula la posición del jugador
|
||||||
checkInput(); // Comprueba las entradas y modifica variables
|
animate(); // Establece la animación del jugador
|
||||||
move(); // Recalcula la posición del jugador y su animación
|
checkBorders(); // Comprueba si está situado en alguno de los cuatro bordes de la habitación
|
||||||
checkBorders(); // Comprueba si está situado en alguno de los cuatro bordes de la habitación
|
checkJumpEnd(); // Comprueba si ha finalizado el salto al alcanzar la altura de inicio
|
||||||
applyGravity(); // Aplica gravedad al jugador
|
|
||||||
checkJump(); // Comprueba si ha finalizado el salto
|
|
||||||
collider = getRect(); // Obtiene el rectangulo que delimita al jugador
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las entradas y modifica variables
|
// Comprueba las entradas y modifica variables
|
||||||
void Player::checkInput()
|
void Player::checkInput()
|
||||||
{
|
{
|
||||||
// Solo comprueba las entradas de dirección cuando está de pie
|
// Solo comprueba las entradas de dirección cuando está de pie
|
||||||
if ((input->checkInput(INPUT_LEFT, REPEAT_TRUE)) && (status == STATUS_STANDING))
|
if ((input->checkInput(INPUT_LEFT, REPEAT_TRUE)) && (state == s_standing))
|
||||||
{
|
{
|
||||||
sprite->setVelX(-0.6f);
|
vx = -0.6f;
|
||||||
sprite->setFlip(SDL_FLIP_HORIZONTAL);
|
sprite->setFlip(SDL_FLIP_HORIZONTAL);
|
||||||
}
|
}
|
||||||
else if ((input->checkInput(INPUT_RIGHT, REPEAT_TRUE)) && (status == STATUS_STANDING))
|
else if ((input->checkInput(INPUT_RIGHT, REPEAT_TRUE)) && (state == s_standing))
|
||||||
{
|
{
|
||||||
sprite->setVelX(0.6f);
|
vx = 0.6f;
|
||||||
sprite->setFlip(SDL_FLIP_NONE);
|
sprite->setFlip(SDL_FLIP_NONE);
|
||||||
}
|
}
|
||||||
else if (status == STATUS_STANDING)
|
else if (state == s_standing)
|
||||||
{
|
{
|
||||||
sprite->setVelX(0);
|
vx = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->checkInput(INPUT_UP, REPEAT_TRUE))
|
if (input->checkInput(INPUT_UP, REPEAT_TRUE))
|
||||||
{
|
{
|
||||||
setStatus(STATUS_JUMPING);
|
if (state == s_standing)
|
||||||
|
{
|
||||||
|
state = s_jumping;
|
||||||
|
vy = -maxVY;
|
||||||
|
jump_ini = y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,22 +119,22 @@ int Player::getBorder()
|
|||||||
// Comprueba si está situado en alguno de los cuatro bordes de la habitación
|
// Comprueba si está situado en alguno de los cuatro bordes de la habitación
|
||||||
void Player::checkBorders()
|
void Player::checkBorders()
|
||||||
{
|
{
|
||||||
if (sprite->getPosX() < PLAY_AREA_LEFT)
|
if (x < PLAY_AREA_LEFT)
|
||||||
{
|
{
|
||||||
border = BORDER_LEFT;
|
border = BORDER_LEFT;
|
||||||
onBorder = true;
|
onBorder = true;
|
||||||
}
|
}
|
||||||
else if (sprite->getPosX() > PLAY_AREA_RIGHT - sprite->getWidth())
|
else if (x > PLAY_AREA_RIGHT - w)
|
||||||
{
|
{
|
||||||
border = BORDER_RIGHT;
|
border = BORDER_RIGHT;
|
||||||
onBorder = true;
|
onBorder = true;
|
||||||
}
|
}
|
||||||
else if (sprite->getPosY() < PLAY_AREA_TOP)
|
else if (y < PLAY_AREA_TOP)
|
||||||
{
|
{
|
||||||
border = BORDER_TOP;
|
border = BORDER_TOP;
|
||||||
onBorder = true;
|
onBorder = true;
|
||||||
}
|
}
|
||||||
else if (sprite->getPosY() > PLAY_AREA_BOTTOM - sprite->getHeight())
|
else if (y > PLAY_AREA_BOTTOM - h)
|
||||||
{
|
{
|
||||||
border = BORDER_BOTTOM;
|
border = BORDER_BOTTOM;
|
||||||
onBorder = true;
|
onBorder = true;
|
||||||
@@ -130,92 +145,57 @@ void Player::checkBorders()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Comprueba el estado del jugador
|
||||||
|
void Player::checkState()
|
||||||
|
{
|
||||||
|
if (state == s_falling)
|
||||||
|
{
|
||||||
|
vx = 0.0f;
|
||||||
|
vy = maxVY;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (state == s_standing)
|
||||||
|
{
|
||||||
|
vy = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Cambia al jugador de un borde al opuesto. Util para el cambio de pantalla
|
// Cambia al jugador de un borde al opuesto. Util para el cambio de pantalla
|
||||||
void Player::switchBorders()
|
void Player::switchBorders()
|
||||||
{
|
{
|
||||||
if (border == BORDER_TOP)
|
if (border == BORDER_TOP)
|
||||||
{
|
{
|
||||||
sprite->setPosY(PLAY_AREA_BOTTOM - sprite->getHeight() - 1);
|
y = PLAY_AREA_BOTTOM - h - 1;
|
||||||
jump_ini += 128;
|
jump_ini += 128;
|
||||||
}
|
}
|
||||||
else if (border == BORDER_BOTTOM)
|
else if (border == BORDER_BOTTOM)
|
||||||
{
|
{
|
||||||
sprite->setPosY(PLAY_AREA_TOP + 1);
|
y = PLAY_AREA_TOP + 1;
|
||||||
}
|
}
|
||||||
else if (border == BORDER_RIGHT)
|
else if (border == BORDER_RIGHT)
|
||||||
{
|
{
|
||||||
sprite->setPosX(PLAY_AREA_LEFT + 1);
|
x = PLAY_AREA_LEFT + 1;
|
||||||
}
|
}
|
||||||
if (border == BORDER_LEFT)
|
if (border == BORDER_LEFT)
|
||||||
{
|
{
|
||||||
sprite->setPosX(PLAY_AREA_RIGHT - sprite->getWidth() - 1);
|
x = PLAY_AREA_RIGHT - w - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
onBorder = false;
|
onBorder = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor del pixel inferior izquierdo del jugador
|
|
||||||
SDL_Point Player::getLeftFoot()
|
|
||||||
{
|
|
||||||
SDL_Point point = {(int)sprite->getPosX(), (int)sprite->getPosY() + sprite->getHeight()};
|
|
||||||
return point;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el valor del pixel inferior derecho del jugador
|
|
||||||
SDL_Point Player::getRightFoot()
|
|
||||||
{
|
|
||||||
SDL_Point point = {(int)sprite->getPosX() + sprite->getWidth() - 1, (int)sprite->getPosY() + sprite->getHeight()};
|
|
||||||
return point;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cambia el estado del jugador
|
|
||||||
void Player::setStatus(int value)
|
|
||||||
{
|
|
||||||
// Si quiere cambiar a saltando, ha de ser desde quieto
|
|
||||||
if ((value == STATUS_JUMPING) && (status == STATUS_STANDING))
|
|
||||||
{
|
|
||||||
status = STATUS_JUMPING;
|
|
||||||
sprite->setVelY(-MAX_VY);
|
|
||||||
jump_ini = sprite->getPosY();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modifica el estado a 'cayendo'
|
|
||||||
if (value == STATUS_FALLING)
|
|
||||||
{
|
|
||||||
status = STATUS_FALLING;
|
|
||||||
sprite->setVelY(MAX_VY);
|
|
||||||
sprite->setVelX(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modifica el estado a 'de pie'
|
|
||||||
if (value == STATUS_STANDING)
|
|
||||||
{
|
|
||||||
status = STATUS_STANDING;
|
|
||||||
sprite->setVelY(0.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el estado del jugador
|
|
||||||
int Player::getStatus()
|
|
||||||
{
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene la velocidad en el eje Y del jugador
|
|
||||||
float Player::getVelY()
|
|
||||||
{
|
|
||||||
return sprite->getVelY();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Aplica gravedad al jugador
|
// Aplica gravedad al jugador
|
||||||
void Player::applyGravity()
|
void Player::applyGravity()
|
||||||
{
|
{
|
||||||
if (status == STATUS_JUMPING)
|
const float gf = 0.035f;
|
||||||
|
|
||||||
|
// La gravedad solo se aplica cuando está saltando
|
||||||
|
if (state == s_jumping)
|
||||||
{
|
{
|
||||||
sprite->setVelY(sprite->getVelY() + GRAVITY);
|
vy += gf;
|
||||||
if (sprite->getVelY() > MAX_VY)
|
if (vy > maxVY)
|
||||||
{
|
{
|
||||||
sprite->setVelY(MAX_VY);
|
vy = maxVY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,64 +203,300 @@ void Player::applyGravity()
|
|||||||
// Obtiene el rectangulo que delimita al jugador
|
// Obtiene el rectangulo que delimita al jugador
|
||||||
SDL_Rect Player::getRect()
|
SDL_Rect Player::getRect()
|
||||||
{
|
{
|
||||||
return sprite->getRect();
|
return {(int)x, (int)y, w, h};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el rectangulo de colision del jugador
|
// Obtiene el rectangulo de colision del jugador
|
||||||
SDL_Rect &Player::getCollider()
|
SDL_Rect &Player::getCollider()
|
||||||
{
|
{
|
||||||
return collider;
|
colliderBox = getRect();
|
||||||
}
|
return colliderBox;
|
||||||
|
|
||||||
// Guarda la posición actual en la variable lastPosition
|
|
||||||
void Player::setLastPosition()
|
|
||||||
{
|
|
||||||
lastPosition = getRect();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deshace el ultimo movimiento
|
|
||||||
void Player::undoLastMove()
|
|
||||||
{
|
|
||||||
sprite->setPosX(lastPosition.x);
|
|
||||||
sprite->setPosY(lastPosition.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recalcula la posición del jugador y su animación
|
// Recalcula la posición del jugador y su animación
|
||||||
void Player::move()
|
void Player::move()
|
||||||
{
|
{
|
||||||
sprite->update();
|
const int tileSize = room->getTileSize();
|
||||||
if (sprite->getVelX() != 0)
|
lastPosition = {(int)x, (int)y}; // Guarda la posicion actual antes de modificarla
|
||||||
|
applyGravity(); // Aplica gravedad al jugador
|
||||||
|
checkState(); // Comprueba el estado del jugador
|
||||||
|
|
||||||
|
// Calcula la nueva posición del jugador y compensa en caso de colisión
|
||||||
|
x += vx;
|
||||||
|
|
||||||
|
// Comprueba colisiones con muros
|
||||||
|
if (checkWalls())
|
||||||
{
|
{
|
||||||
sprite->setCurrentAnimation("walk");
|
// Recoloca
|
||||||
|
if (vx > 0.0f)
|
||||||
|
{
|
||||||
|
x = (int)x - ((int)x + w) % tileSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = (int)x + tileSize - ((int)x % tileSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba colisiones con rampas solo si esta quieto o cayendo
|
||||||
|
else if (vy >= 0.0f)
|
||||||
|
{
|
||||||
|
|
||||||
|
tile_e slope = checkSlopes();
|
||||||
|
tile_e slope2 = checkSlopes2();
|
||||||
|
debug->add("SLOPE = " + std::to_string(slope));
|
||||||
|
debug->add("SLOPE2 = " + std::to_string(slope2));
|
||||||
|
if (slope != t_empty)
|
||||||
|
{ // Cuesta hacia la derecha
|
||||||
|
if (slope == t_slope_r)
|
||||||
|
{ // Recoloca
|
||||||
|
y = -h + room->getSlopeHeight(feet[1], t_slope_r);
|
||||||
|
debug->add("feet[1] = " + std::to_string(feet[1].y));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cuesta hacia la izquierda
|
||||||
|
if (slope == t_slope_l)
|
||||||
|
{ // Recoloca
|
||||||
|
y = -h + room->getSlopeHeight(feet[0], t_slope_l);
|
||||||
|
debug->add("feet[0] = " + std::to_string(feet[0].y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (slope2 != t_empty)
|
||||||
|
{ // Cuesta hacia la derecha
|
||||||
|
if (slope2 == t_slope_r)
|
||||||
|
{ // Recoloca
|
||||||
|
y = -h + room->getSlopeHeight(underFeet[1], t_slope_r);
|
||||||
|
debug->add("ufeet[1] = " + std::to_string(underFeet[1].y));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cuesta hacia la izquierda
|
||||||
|
if (slope2 == t_slope_l)
|
||||||
|
{ // Recoloca
|
||||||
|
y = -h + room->getSlopeHeight(underFeet[0], t_slope_l);
|
||||||
|
debug->add("ufeet[0] = " + std::to_string(underFeet[0].y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
y += vy;
|
||||||
|
if (checkWalls())
|
||||||
|
{
|
||||||
|
// Recoloca
|
||||||
|
if (vy > 0.0f)
|
||||||
|
{ // Bajando
|
||||||
|
y -= ((int)y + h) % tileSize;
|
||||||
|
state = s_standing;
|
||||||
|
vy = 0.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Subiendo
|
||||||
|
y += tileSize - ((int)y % tileSize);
|
||||||
|
state = s_falling;
|
||||||
|
vy = maxVY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
// Si no colisiona con los muros, haz comprobaciones extra
|
||||||
{
|
{
|
||||||
sprite->setCurrentAnimation("stand");
|
const int a = (lastPosition.y + h - 1) / tileSize;
|
||||||
|
const int b = ((int)y + h - 1) / tileSize;
|
||||||
|
const bool tile_change = a != b;
|
||||||
|
|
||||||
|
bool going_down = vy >= 0.0f;
|
||||||
|
bool tile_aligned = ((int)y + h) % tileSize == 0;
|
||||||
|
|
||||||
|
// Si está cayendo y hay cambio de tile o está justo sobre uno
|
||||||
|
if (going_down && (tile_aligned || tile_change))
|
||||||
|
{
|
||||||
|
// Comprueba si tiene uno de los pies sobre una superficie
|
||||||
|
if (isOnFloor())
|
||||||
|
{ // Y deja al jugador de pie
|
||||||
|
state = s_standing;
|
||||||
|
vy = 0.0f;
|
||||||
|
|
||||||
|
// Si ademas ha habido un cambio de tile recoloca al jugador
|
||||||
|
if (tile_change && !checkSlopes2())
|
||||||
|
{
|
||||||
|
y = ((int)y - ((int)y % tileSize));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si tiene ambos pies sobre el vacío y no está saltando
|
||||||
|
else if (state != s_jumping)
|
||||||
|
{
|
||||||
|
state = s_falling;
|
||||||
|
vy = maxVY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
going_down = vy >= 0.0f;
|
||||||
|
tile_aligned = ((int)y + h) % tileSize == 0;
|
||||||
|
|
||||||
|
// Si simplemente está cayendo (sin mirar si hay cambio de tile o si está justo sobre uno)
|
||||||
|
if (going_down)
|
||||||
|
{
|
||||||
|
if (state != s_jumping)
|
||||||
|
{
|
||||||
|
state = s_falling;
|
||||||
|
vy = maxVY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si está alineado con el tile mira el suelo (para que no lo mire si está
|
||||||
|
// dentro de un tile atravesable y lo deje a medias)
|
||||||
|
if (tile_aligned)
|
||||||
|
{
|
||||||
|
if (isOnFloor())
|
||||||
|
{
|
||||||
|
state = s_standing;
|
||||||
|
vy = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// EXPERIMENTAL
|
||||||
|
else if (checkSlopes())
|
||||||
|
{
|
||||||
|
state = s_standing;
|
||||||
|
vy = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza la posición del sprite
|
||||||
|
sprite->setPosX(x);
|
||||||
|
sprite->setPosY(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece la animación del jugador
|
||||||
|
void Player::animate()
|
||||||
|
{
|
||||||
|
if (vx != 0)
|
||||||
|
{
|
||||||
|
sprite->animate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si ha finalizado el salto
|
// Comprueba si ha finalizado el salto al alcanzar la altura de inicio
|
||||||
void Player::checkJump()
|
void Player::checkJumpEnd()
|
||||||
{
|
{
|
||||||
if (status == STATUS_JUMPING)
|
if (state == s_jumping)
|
||||||
if (sprite->getVelY() > 0)
|
if (vy > 0)
|
||||||
if (sprite->getPosY() > jump_ini)
|
if (y >= jump_ini)
|
||||||
{
|
{
|
||||||
setStatus(STATUS_FALLING);
|
state = s_falling;
|
||||||
|
vy = maxVY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Comprueba si el jugador tiene suelo debajo de los pies
|
||||||
|
bool Player::isOnFloor()
|
||||||
|
{
|
||||||
|
bool onFloor = false;
|
||||||
|
|
||||||
|
updateFeet();
|
||||||
|
|
||||||
|
for (auto f : underFeet)
|
||||||
|
{
|
||||||
|
const tile_e tile = (room->getTile(f));
|
||||||
|
onFloor |= (tile == t_wall || tile == t_passable || tile == t_slope_l || tile == t_slope_r);
|
||||||
|
}
|
||||||
|
|
||||||
|
return onFloor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba que el jugador no atraviese ninguna pared
|
||||||
|
bool Player::checkWalls()
|
||||||
|
{
|
||||||
|
// Actualiza los puntos de colisión
|
||||||
|
updateColliderPoints();
|
||||||
|
|
||||||
|
// Comprueba si ha colisionado con un muro
|
||||||
|
bool wall = false;
|
||||||
|
|
||||||
|
for (auto c : colliderPoints)
|
||||||
|
{
|
||||||
|
wall |= (room->getTile(c) == t_wall);
|
||||||
|
}
|
||||||
|
|
||||||
|
return wall;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba si el jugador está en una rampa
|
||||||
|
tile_e Player::checkSlopes()
|
||||||
|
{
|
||||||
|
// Actualiza los puntos de colisión
|
||||||
|
updateFeet();
|
||||||
|
|
||||||
|
bool slope_l = false;
|
||||||
|
bool slope_r = false;
|
||||||
|
|
||||||
|
// Comprueba si ha colisionado con una rampa
|
||||||
|
for (auto f : feet)
|
||||||
|
{
|
||||||
|
slope_l |= (room->getTile(f) == t_slope_l);
|
||||||
|
slope_r |= (room->getTile(f) == t_slope_r);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slope_l)
|
||||||
|
{
|
||||||
|
return t_slope_l;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slope_r)
|
||||||
|
{
|
||||||
|
return t_slope_r;
|
||||||
|
}
|
||||||
|
|
||||||
|
return t_empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba si el jugador está en una rampa
|
||||||
|
tile_e Player::checkSlopes2()
|
||||||
|
{
|
||||||
|
// Actualiza los puntos de colisión
|
||||||
|
updateFeet();
|
||||||
|
|
||||||
|
bool slope_l = false;
|
||||||
|
bool slope_r = false;
|
||||||
|
bool wall = false;
|
||||||
|
bool passable = false;
|
||||||
|
|
||||||
|
// Comprueba si ha colisionado con una rampa
|
||||||
|
for (auto f : underFeet)
|
||||||
|
{
|
||||||
|
slope_l |= (room->getTile(f) == t_slope_l);
|
||||||
|
slope_r |= (room->getTile(f) == t_slope_r);
|
||||||
|
wall |= (room->getTile(f) == t_wall);
|
||||||
|
passable |= (room->getTile(f) == t_passable);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wall || passable)
|
||||||
|
{
|
||||||
|
return t_empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slope_l)
|
||||||
|
{
|
||||||
|
return t_slope_l;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slope_r)
|
||||||
|
{
|
||||||
|
return t_slope_r;
|
||||||
|
}
|
||||||
|
|
||||||
|
return t_empty;
|
||||||
|
}
|
||||||
|
|
||||||
// Obtiene algunos parametros del jugador
|
// Obtiene algunos parametros del jugador
|
||||||
player_t Player::getSpawnParams()
|
player_t Player::getSpawnParams()
|
||||||
{
|
{
|
||||||
player_t params;
|
player_t params;
|
||||||
|
|
||||||
params.x = sprite->getPosX();
|
params.x = x;
|
||||||
params.y = sprite->getPosY();
|
params.y = y;
|
||||||
params.vx = sprite->getVelX();
|
params.vx = vx;
|
||||||
params.vy = sprite->getVelY();
|
params.vy = vy;
|
||||||
params.jump_ini = jump_ini;
|
params.jump_ini = jump_ini;
|
||||||
params.status = status;
|
params.state = state;
|
||||||
params.flip = sprite->getFlip();
|
params.flip = sprite->getFlip();
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
@@ -290,4 +506,48 @@ player_t Player::getSpawnParams()
|
|||||||
void Player::reLoadTexture()
|
void Player::reLoadTexture()
|
||||||
{
|
{
|
||||||
texture->reLoad();
|
texture->reLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece el valor de la variable
|
||||||
|
void Player::setRoom(Room *room)
|
||||||
|
{
|
||||||
|
this->room = room;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza los puntos de colisión
|
||||||
|
void Player::updateColliderPoints()
|
||||||
|
{
|
||||||
|
const SDL_Rect rect = getRect();
|
||||||
|
colliderPoints[0] = {rect.x, rect.y};
|
||||||
|
colliderPoints[1] = {rect.x + 7, rect.y};
|
||||||
|
colliderPoints[2] = {rect.x + 7, rect.y + 7};
|
||||||
|
colliderPoints[3] = {rect.x, rect.y + 7};
|
||||||
|
colliderPoints[4] = {rect.x, rect.y + 8};
|
||||||
|
colliderPoints[5] = {rect.x + 7, rect.y + 8};
|
||||||
|
colliderPoints[6] = {rect.x + 7, rect.y + 15};
|
||||||
|
colliderPoints[7] = {rect.x, rect.y + 15};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza los puntos de los pies
|
||||||
|
void Player::updateFeet()
|
||||||
|
{
|
||||||
|
const SDL_Point p = {(int)x, (int)y};
|
||||||
|
|
||||||
|
underFeet[0] = {p.x, p.y + h};
|
||||||
|
underFeet[1] = {p.x + 7, p.y + h};
|
||||||
|
|
||||||
|
feet[0] = {p.x, p.y + h - 1};
|
||||||
|
feet[1] = {p.x + 7, p.y + h - 1};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtiene el valor de la variable
|
||||||
|
bool Player::getInvincible()
|
||||||
|
{
|
||||||
|
return invincible;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece el valor de la variable
|
||||||
|
void Player::setInvincible(bool value)
|
||||||
|
{
|
||||||
|
invincible = value;
|
||||||
}
|
}
|
||||||
+71
-48
@@ -7,18 +7,19 @@
|
|||||||
#include "animatedsprite.h"
|
#include "animatedsprite.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
#include "debug.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifndef PLAYER_H
|
#ifndef PLAYER_H
|
||||||
#define PLAYER_H
|
#define PLAYER_H
|
||||||
|
|
||||||
//#define VX 0.6
|
enum state_e
|
||||||
#define STATUS_STANDING 0
|
{
|
||||||
#define STATUS_JUMPING 1
|
s_standing,
|
||||||
#define STATUS_FALLING 2
|
s_jumping,
|
||||||
|
s_falling
|
||||||
#define GRAVITY 0.035f
|
};
|
||||||
#define MAX_VY 1.2f
|
|
||||||
|
|
||||||
struct player_t
|
struct player_t
|
||||||
{
|
{
|
||||||
@@ -27,24 +28,39 @@ struct player_t
|
|||||||
float vx;
|
float vx;
|
||||||
float vy;
|
float vy;
|
||||||
int jump_ini;
|
int jump_ini;
|
||||||
int status;
|
state_e state;
|
||||||
SDL_RendererFlip flip;
|
SDL_RendererFlip flip;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clase Player
|
// Clase Player
|
||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
LTexture *texture; // Textura con los graficos del enemigo
|
float x; // Posición del jugador en el eje X
|
||||||
Input *input; // Objeto para gestionar la entrada
|
float y; // Posición del jugador en el eje Y
|
||||||
|
float vx; // Velocidad/desplazamiento del jugador en el eje X
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
float vy; // Velocidad/desplazamiento del jugador en el eje Y
|
||||||
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
int w; // Ancho del jugador
|
||||||
color_t color; // Color del jugador
|
int h; // ALto del jugador
|
||||||
SDL_Rect collider; // Caja de colisión
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
|
Input *input; // Objeto para gestionar la entrada
|
||||||
bool onBorder; // Indica si el jugador esta en uno de los cuatro bordes de la pantalla
|
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
||||||
int border; // Indica en cual de los cuatro bordes se encuentra
|
Room *room; // Objeto encargado de gestionar cada habitación del juego
|
||||||
|
LTexture *texture; // Textura con los graficos del enemigo
|
||||||
|
AnimatedSprite *sprite; // Sprite del enemigo
|
||||||
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
|
color_t color; // Color del jugador
|
||||||
|
SDL_Rect colliderBox; // Caja de colisión con los enemigos u objetos
|
||||||
|
std::vector<SDL_Point> colliderPoints; // Puntos de colisión con el mapa
|
||||||
|
std::vector<SDL_Point> underFeet; // Contiene los puntos que hay bajo cada pie del jugador
|
||||||
|
std::vector<SDL_Point> feet; // Contiene los puntos que hay en el pie del jugador
|
||||||
|
state_e state; // Estado en el que se encuentra el jugador. Util apara saber si está saltando o cayendo
|
||||||
|
bool onBorder; // Indica si el jugador esta en uno de los cuatro bordes de la pantalla
|
||||||
|
int border; // Indica en cual de los cuatro bordes se encuentra
|
||||||
|
bool invincible; // Si es invencible, no puede morir
|
||||||
|
SDL_Rect lastPosition; // Contiene la ultima posición del jugador, por si hay que deshacer algun movimiento
|
||||||
|
int jump_ini; // Valor del eje Y en el que se inicia el salto
|
||||||
|
float maxVY; // Velocidad máxima que puede alcanzar al desplazarse en vertical
|
||||||
|
|
||||||
// Comprueba las entradas y modifica variables
|
// Comprueba las entradas y modifica variables
|
||||||
void checkInput();
|
void checkInput();
|
||||||
@@ -52,29 +68,45 @@ private:
|
|||||||
// Comprueba si se halla en alguno de los cuatro bordes
|
// Comprueba si se halla en alguno de los cuatro bordes
|
||||||
void checkBorders();
|
void checkBorders();
|
||||||
|
|
||||||
|
// Comprueba el estado del jugador
|
||||||
|
void checkState();
|
||||||
|
|
||||||
// Asigna velocidad negativa en el eje Y al jugador
|
// Asigna velocidad negativa en el eje Y al jugador
|
||||||
void jump();
|
void jump();
|
||||||
|
|
||||||
// Aplica gravedad al jugador
|
// Aplica gravedad al jugador
|
||||||
void applyGravity();
|
void applyGravity();
|
||||||
|
|
||||||
// Guarda la posición actual en la variable lastPosition
|
|
||||||
void setLastPosition();
|
|
||||||
|
|
||||||
// Recalcula la posición del jugador y su animación
|
// Recalcula la posición del jugador y su animación
|
||||||
void move();
|
void move();
|
||||||
|
|
||||||
// Comprueba si ha finalizado el salto
|
// Establece la animación del jugador
|
||||||
void checkJump();
|
void animate();
|
||||||
|
|
||||||
|
// Comprueba si ha finalizado el salto al alcanzar la altura de inicio
|
||||||
|
void checkJumpEnd();
|
||||||
|
|
||||||
|
// Comprueba si el jugador tiene suelo debajo de los pies
|
||||||
|
bool isOnFloor();
|
||||||
|
|
||||||
|
// Comprueba que el jugador no atraviese ninguna pared
|
||||||
|
bool checkWalls();
|
||||||
|
|
||||||
|
// Comprueba si el jugador está en una rampa
|
||||||
|
tile_e checkSlopes();
|
||||||
|
|
||||||
|
// Comprueba si el jugador está en una rampa
|
||||||
|
tile_e checkSlopes2();
|
||||||
|
|
||||||
|
// Actualiza los puntos de colisión
|
||||||
|
void updateColliderPoints();
|
||||||
|
|
||||||
|
// Actualiza los puntos de los pies
|
||||||
|
void updateFeet();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AnimatedSprite *sprite; // Sprite del enemigo
|
|
||||||
SDL_Rect lastPosition; // Contiene la ultima posición del jugador, por si hay que deshacer algun movimiento
|
|
||||||
int jump_ini; // Valor del eje Y en el que se inicia el salto
|
|
||||||
int status; // Estado en el que se encuentra el jugador. Util apara saber si está saltando o cayendo
|
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Player(player_t ini, std::string tileset, std::string animation, SDL_Renderer *renderer, Asset *asset, Input *input, Room *room);
|
Player(player_t ini, std::string tileset, std::string animation, SDL_Renderer *renderer, Asset *asset, Input *input, Room *room, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Player();
|
~Player();
|
||||||
@@ -94,35 +126,26 @@ public:
|
|||||||
// Cambia al jugador de un borde al opuesto. Util para el cambio de pantalla
|
// Cambia al jugador de un borde al opuesto. Util para el cambio de pantalla
|
||||||
void switchBorders();
|
void switchBorders();
|
||||||
|
|
||||||
// Obtiene el valor del pixel inferior izquierdo del jugador
|
|
||||||
SDL_Point getLeftFoot();
|
|
||||||
|
|
||||||
// Obtiene el valor del pixel inferior derecho del jugador
|
|
||||||
SDL_Point getRightFoot();
|
|
||||||
|
|
||||||
// Cambia el estado del jugador
|
|
||||||
void setStatus(int value);
|
|
||||||
|
|
||||||
// Obtiene el estado del jugador
|
|
||||||
int getStatus();
|
|
||||||
|
|
||||||
// Obtiene la velocidad en el eje Y del jugador
|
|
||||||
float getVelY();
|
|
||||||
|
|
||||||
// Obtiene el rectangulo que delimita al jugador
|
// Obtiene el rectangulo que delimita al jugador
|
||||||
SDL_Rect getRect();
|
SDL_Rect getRect();
|
||||||
|
|
||||||
// Obtiene el rectangulo de colision del jugador
|
// Obtiene el rectangulo de colision del jugador
|
||||||
SDL_Rect &getCollider();
|
SDL_Rect &getCollider();
|
||||||
|
|
||||||
// Deshace el ultimo movimiento
|
|
||||||
void undoLastMove();
|
|
||||||
|
|
||||||
// Obtiene algunos parametros del jugador
|
// Obtiene algunos parametros del jugador
|
||||||
player_t getSpawnParams();
|
player_t getSpawnParams();
|
||||||
|
|
||||||
// Recarga la textura
|
// Recarga la textura
|
||||||
void reLoadTexture();
|
void reLoadTexture();
|
||||||
|
|
||||||
|
// Establece el valor de la variable
|
||||||
|
void setRoom(Room *room);
|
||||||
|
|
||||||
|
// Obtiene el valor de la variable
|
||||||
|
bool getInvincible();
|
||||||
|
|
||||||
|
// Establece el valor de la variable
|
||||||
|
void setInvincible(bool value);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+74
-15
@@ -4,13 +4,15 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
// Constructor
|
// 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, Debug *debug)
|
||||||
{
|
{
|
||||||
// Copia los punteros a objetos
|
// Copia los punteros a objetos
|
||||||
this->asset = asset;
|
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
|
this->asset = asset;
|
||||||
|
this->screen = screen;
|
||||||
this->itemTracker = itemTracker;
|
this->itemTracker = itemTracker;
|
||||||
this->itemsPicked = items;
|
this->itemsPicked = items;
|
||||||
|
this->debug = debug;
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
load(file_path);
|
load(file_path);
|
||||||
@@ -24,6 +26,15 @@ Room::Room(std::string file_path, SDL_Renderer *renderer, Asset *asset, ItemTrac
|
|||||||
|
|
||||||
// Pinta el mapa de la habitación en la textura
|
// Pinta el mapa de la habitación en la textura
|
||||||
fillMapTexture();
|
fillMapTexture();
|
||||||
|
|
||||||
|
// Establece el color del borde
|
||||||
|
screen->setBorderColor(borderColor);
|
||||||
|
|
||||||
|
// Inicializa variables
|
||||||
|
tileSize = 8;
|
||||||
|
mapWidth = 32;
|
||||||
|
mapHeight = 16;
|
||||||
|
tilesetWidth = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -213,6 +224,11 @@ bool Room::setVars(std::string var, std::string value)
|
|||||||
bgColor = stringToColor(value);
|
bgColor = stringToColor(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (var == "border")
|
||||||
|
{
|
||||||
|
borderColor = stringToColor(value);
|
||||||
|
}
|
||||||
|
|
||||||
else if (var == "tileset")
|
else if (var == "tileset")
|
||||||
{
|
{
|
||||||
tileset = value;
|
tileset = value;
|
||||||
@@ -490,29 +506,36 @@ std::string Room::getRoom(int border)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el tipo de tile que hay en ese pixel
|
// Devuelve el tipo de tile que hay en ese pixel
|
||||||
int Room::getTile(SDL_Point point)
|
tile_e Room::getTile(SDL_Point point)
|
||||||
{
|
{
|
||||||
int pos = ((point.y / 8) * 32) + (point.x / 8);
|
const int maxTile = mapWidth * mapHeight;
|
||||||
int tile = TILE_EMPTY;
|
const int pos = ((point.y / tileSize) * mapWidth) + (point.x / tileSize);
|
||||||
|
tile_e tile = t_empty;
|
||||||
|
|
||||||
if (pos < 512)
|
if (pos < maxTile)
|
||||||
{
|
{
|
||||||
// Los tiles entre el 1 y el 80 son solidos
|
// Las filas 0-7 son de tiles t_wall
|
||||||
if ((tilemap[pos] > 0) && (tilemap[pos] < 201))
|
if ((tilemap[pos] > 0) && (tilemap[pos] < 8 * tilesetWidth))
|
||||||
{
|
{
|
||||||
return TILE_SOLID;
|
return t_wall;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Los tiles mayores de 80 son atravesables
|
// La fila 8 es de tiles t_slope_r
|
||||||
if ((tilemap[pos] > 200) && (tilemap[pos] < 381))
|
else if ((tilemap[pos] >= 8 * tilesetWidth) && (tilemap[pos] < 9 * tilesetWidth))
|
||||||
{
|
{
|
||||||
return TILE_TRAVESSABLE;
|
return t_slope_r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Los tiles mayores de 80 son atravesables
|
// La fila 9 es de tiles t_slope_l
|
||||||
if ((tilemap[pos] > 380) && (tilemap[pos] < 400))
|
else if ((tilemap[pos] >= 9 * tilesetWidth) && (tilemap[pos] < 10 * tilesetWidth))
|
||||||
{
|
{
|
||||||
return TILE_KILL;
|
return t_slope_l;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Las filas 10-14 son de tiles t_passable
|
||||||
|
if ((tilemap[pos] >= 10 * tilesetWidth) && (tilemap[pos] < 15 * tilesetWidth))
|
||||||
|
{
|
||||||
|
return t_passable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,4 +589,40 @@ void Room::reLoadTexture()
|
|||||||
{
|
{
|
||||||
item->reLoadTexture();
|
item->reLoadTexture();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obten el tamaño del tile
|
||||||
|
int Room::getTileSize()
|
||||||
|
{
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obten la coordenada de la cuesta a partir de un punto perteneciente a ese tile
|
||||||
|
int Room::getSlopeHeight(SDL_Point p, tile_e slope)
|
||||||
|
{
|
||||||
|
// Calcula la base del tile
|
||||||
|
int base = ((p.y / tileSize) * tileSize) + tileSize;
|
||||||
|
printf("base %i\n", base);
|
||||||
|
debug->add("BASE = " + std::to_string(base));
|
||||||
|
|
||||||
|
// Calcula cuanto se ha entrado en el tile horizontalmente
|
||||||
|
const int pos = (p.x % tileSize); // esto da un valor entre 0 y 7
|
||||||
|
printf("pos %i\n", base);
|
||||||
|
debug->add("POS = " + std::to_string(pos));
|
||||||
|
|
||||||
|
// Se resta a la base la cantidad de pixeles pos en funcion de la rampa
|
||||||
|
if (slope == t_slope_r)
|
||||||
|
{
|
||||||
|
base -= pos + 1;
|
||||||
|
printf("base_R %i\n", base);
|
||||||
|
debug->add("BASE_R = " + std::to_string(base));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base -= (tileSize - pos);
|
||||||
|
printf("base_L %i\n", base);
|
||||||
|
debug->add("BASE_L = " + std::to_string(base));
|
||||||
|
}
|
||||||
|
|
||||||
|
return base;
|
||||||
}
|
}
|
||||||
+56
-34
@@ -3,57 +3,73 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
|
#include "screen.h"
|
||||||
#include "enemy.h"
|
#include "enemy.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "item_tracker.h"
|
#include "item_tracker.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "jail_audio.h"
|
#include "jail_audio.h"
|
||||||
|
#include "debug.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifndef ROOM_H
|
#ifndef ROOM_H
|
||||||
#define ROOM_H
|
#define ROOM_H
|
||||||
|
|
||||||
#define TILE_EMPTY 0
|
|
||||||
#define TILE_SOLID 1
|
|
||||||
#define TILE_TRAVESSABLE 2
|
|
||||||
#define TILE_KILL 3
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Cada habitación se crea y destruye cada vez que se entra o sale de la misma
|
Cada habitación se crea y destruye cada vez que se entra o sale de la misma
|
||||||
Cada habitacion si que tendra lo siguiente:
|
Cada habitacion tiene lo siguiente:
|
||||||
ID (numerico)
|
- ID (numerico)
|
||||||
NOMBRE (texto)
|
- NOMBRE (texto)
|
||||||
COLOR DE FONDO (texto)
|
- COLOR DE FONDO (texto)
|
||||||
SET DE TILES (texto, hace referencia a un png de la colección)
|
- COLOR DEL BORDE (texto)
|
||||||
LIMITE SUPERIOR (ID de la habitación superior), INFERIOR, IZQUIERDO y DERECHO
|
- SET DE TILES (texto, hace referencia a un png de la colección)
|
||||||
MAPA DE TILES (array con los indices de los tiles a utilizar) <-- hay que decidir si cada tile del set ya
|
- LIMITE SUPERIOR (ID de la habitación superior), INFERIOR, IZQUIERDO y DERECHO
|
||||||
tierne propiedades o se ponen en un mapa aparte
|
- MAPA DE TILES (array con los indices de los tiles a utilizar) <-- hay que decidir si cada tile del set ya
|
||||||
LISTADO DE ENEMIGOS (tipo, posicion, dx, dy)
|
tierne propiedades o se ponen en un mapa aparte
|
||||||
LISTADO DE ITEMS (tipo, posicion)
|
- LISTADO DE ENEMIGOS (tipo, posicion, dx, dy)
|
||||||
|
- LISTADO DE ITEMS (tipo, posicion)
|
||||||
*/
|
*/
|
||||||
|
enum tile_e
|
||||||
|
{
|
||||||
|
t_empty,
|
||||||
|
t_wall,
|
||||||
|
t_passable,
|
||||||
|
t_slope_l,
|
||||||
|
t_slope_r,
|
||||||
|
t_death
|
||||||
|
};
|
||||||
|
|
||||||
// Clase Room
|
// Clase Room
|
||||||
class Room
|
class Room
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string name; // Nombre de la habitación
|
std::string name; // Nombre de la habitación
|
||||||
color_t bgColor; // Color de fondo de la habitación
|
color_t bgColor; // Color de fondo de la habitación
|
||||||
std::string roomUp; // Identificador de la habitación que se encuentra arriba
|
color_t borderColor; // Color de fondo de la habitación
|
||||||
std::string roomDown; // Identificador de la habitación que se encuentra abajp
|
std::string roomUp; // Identificador de la habitación que se encuentra arriba
|
||||||
std::string roomLeft; // Identificador de la habitación que se encuentra a la izquierda
|
std::string roomDown; // Identificador de la habitación que se encuentra abajp
|
||||||
std::string roomRight; // Identificador de la habitación que se encuentra a la derecha
|
std::string roomLeft; // Identificador de la habitación que se encuentra a la izquierda
|
||||||
std::string tileset; // Imagen con los graficos para la habitación
|
std::string roomRight; // Identificador de la habitación que se encuentra a la derecha
|
||||||
std::vector<int> tilemap; // Indice de los tiles a dibujar en la habitación
|
std::string tileset; // Imagen con los graficos para la habitación
|
||||||
std::vector<Enemy *> enemies; // Listado con los enemigos de la habitación
|
std::vector<int> tilemap; // Indice de los tiles a dibujar en la habitación
|
||||||
std::vector<Item *> items; // Listado con los items que hay en la habitación
|
std::vector<Enemy *> enemies; // Listado con los enemigos de la habitación
|
||||||
LTexture *texture; // Textura con los graficos de la habitación
|
std::vector<Item *> items; // Listado con los items que hay en la habitación
|
||||||
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
LTexture *texture; // Textura con los graficos de la habitación
|
||||||
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
SDL_Texture *mapTexture; // Textura para dibujar el mapa de la habitación
|
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
||||||
JA_Sound itemSound; // Sonido producido al coger un objeto
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
int *itemsPicked; // Puntero a la cantidad de items recogidos que lleva el juego
|
SDL_Texture *mapTexture; // Textura para dibujar el mapa de la habitación
|
||||||
|
JA_Sound itemSound; // Sonido producido al coger un objeto
|
||||||
|
int *itemsPicked; // Puntero a la cantidad de items recogidos que lleva el juego
|
||||||
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
|
std::vector<SDL_Rect> bottomSurfaces; // Lista con las superficies de colisón inferiores
|
||||||
|
|
||||||
|
int tileSize; // Ancho del tile en pixels
|
||||||
|
int mapWidth; // Ancho del mapa en tiles
|
||||||
|
int mapHeight; // Alto del mapa en tiles
|
||||||
|
int tilesetWidth; // Ancho del tileset en tiles
|
||||||
|
|
||||||
// Carga las variables desde un fichero
|
// Carga las variables desde un fichero
|
||||||
bool load(std::string file_path);
|
bool load(std::string file_path);
|
||||||
@@ -72,7 +88,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// 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, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Room();
|
~Room();
|
||||||
@@ -99,7 +115,7 @@ public:
|
|||||||
std::string getRoom(int border);
|
std::string getRoom(int border);
|
||||||
|
|
||||||
// Devuelve el tipo de tile que hay en ese pixel
|
// Devuelve el tipo de tile que hay en ese pixel
|
||||||
int getTile(SDL_Point point);
|
tile_e getTile(SDL_Point point);
|
||||||
|
|
||||||
// Indica si hay colision con un enemigo a partir de un rectangulo
|
// Indica si hay colision con un enemigo a partir de un rectangulo
|
||||||
bool enemyCollision(SDL_Rect &rect);
|
bool enemyCollision(SDL_Rect &rect);
|
||||||
@@ -109,6 +125,12 @@ public:
|
|||||||
|
|
||||||
// Recarga la textura
|
// Recarga la textura
|
||||||
void reLoadTexture();
|
void reLoadTexture();
|
||||||
|
|
||||||
|
// Obten el tamaño del tile
|
||||||
|
int getTileSize();
|
||||||
|
|
||||||
|
// Obten la coordenada de la cuesta a partir de un punto perteneciente a ese tile
|
||||||
|
int getSlopeHeight(SDL_Point p, tile_e slope);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+11
-11
@@ -29,7 +29,7 @@ ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, int *lives, int *it
|
|||||||
c = stringToColor("red");
|
c = stringToColor("red");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("purple");
|
c = stringToColor("magenta");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("green");
|
c = stringToColor("green");
|
||||||
@@ -44,25 +44,25 @@ ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, int *lives, int *it
|
|||||||
c = stringToColor("white");
|
c = stringToColor("white");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("light_blue");
|
c = stringToColor("bright_blue");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("light_red");
|
c = stringToColor("bright_red");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("light_purple");
|
c = stringToColor("bright_magenta");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("light_green");
|
c = stringToColor("bright_green");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("light_cyan");
|
c = stringToColor("bright_cyan");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("light_yellow");
|
c = stringToColor("bright_yellow");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
|
|
||||||
c = stringToColor("light_white");
|
c = stringToColor("bright_white");
|
||||||
color.push_back(c);
|
color.push_back(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,12 +78,12 @@ ScoreBoard::~ScoreBoard()
|
|||||||
void ScoreBoard::render()
|
void ScoreBoard::render()
|
||||||
{
|
{
|
||||||
// Dibuja el fondo del marcador
|
// Dibuja el fondo del marcador
|
||||||
const SDL_Rect rect = {0, 17 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT};
|
const SDL_Rect rect = {0, 18 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT};
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
SDL_RenderFillRect(renderer, &rect);
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
// Dibuja las vidas
|
// Dibuja las vidas
|
||||||
sprite->setPosY(18 * BLOCK);
|
sprite->setPosY(19 * BLOCK);
|
||||||
int index;
|
int index;
|
||||||
const int desp = (counter / 40) % 8;
|
const int desp = (counter / 40) % 8;
|
||||||
const int frame = desp % 4;
|
const int frame = desp % 4;
|
||||||
@@ -108,7 +108,7 @@ void ScoreBoard::render()
|
|||||||
std::string timeTxt = std::to_string((clock.minutes % 60) / 10) + std::to_string(clock.minutes % 10) + separator + std::to_string((clock.seconds % 60) / 10) + std::to_string(clock.seconds % 10);
|
std::string timeTxt = std::to_string((clock.minutes % 60) / 10) + std::to_string(clock.minutes % 10) + separator + std::to_string((clock.seconds % 60) / 10) + std::to_string(clock.seconds % 10);
|
||||||
std::string text = "Items collected " + itemsTxt + " Time " + timeTxt;
|
std::string text = "Items collected " + itemsTxt + " Time " + timeTxt;
|
||||||
const color_t color = stringToColor("white");
|
const color_t color = stringToColor("white");
|
||||||
this->text->writeColored(BLOCK, 21 * BLOCK, text, color);
|
this->text->writeColored(BLOCK, 22 * BLOCK, text, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
|
|||||||
+3
-3
@@ -8,10 +8,10 @@
|
|||||||
|
|
||||||
struct anchor_t
|
struct anchor_t
|
||||||
{
|
{
|
||||||
int left; // Parte izquierda de la pantalla de juego
|
int left; // Parte izquierda de la pantalla de juego
|
||||||
int right; // Parte drecha 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 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 bottom; // Parte infoerior de la pantalla de juego
|
||||||
int middle; // Parte central vertical de la pantalla de juego
|
int middle; // Parte central vertical de la pantalla de juego
|
||||||
};
|
};
|
||||||
|
|||||||
+2
-2
@@ -172,7 +172,7 @@ void Text::initOffsetFromFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el valor de la variable
|
// Devuelve el valor de la variable
|
||||||
int Text::getCharacterWidth()
|
int Text::getCharacterSize()
|
||||||
{
|
{
|
||||||
return boxWidth;
|
return boxWidth;
|
||||||
}
|
}
|
||||||
@@ -180,5 +180,5 @@ int Text::getCharacterWidth()
|
|||||||
// Recarga la textura
|
// Recarga la textura
|
||||||
void Text::reLoadTexture()
|
void Text::reLoadTexture()
|
||||||
{
|
{
|
||||||
texture->reLoad();
|
texture->reLoad();
|
||||||
}
|
}
|
||||||
+1
-1
@@ -62,7 +62,7 @@ public:
|
|||||||
int lenght(std::string text, int kerning = 1);
|
int lenght(std::string text, int kerning = 1);
|
||||||
|
|
||||||
// Devuelve el valor de la variable
|
// Devuelve el valor de la variable
|
||||||
int getCharacterWidth();
|
int getCharacterSize();
|
||||||
|
|
||||||
// Recarga la textura
|
// Recarga la textura
|
||||||
void reLoadTexture();
|
void reLoadTexture();
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
|||||||
letters.push_back(l);
|
letters.push_back(l);
|
||||||
}
|
}
|
||||||
letters[0].enabled = true;
|
letters[0].enabled = true;
|
||||||
|
|
||||||
|
// Cambia el color del borde
|
||||||
|
screen->setBorderColor(stringToColor("bright_blue"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|||||||
+166
-63
@@ -143,70 +143,173 @@ bool checkCollision(SDL_Point &p, SDL_Rect &r)
|
|||||||
// Devuelve un color_t a partir de un string
|
// Devuelve un color_t a partir de un string
|
||||||
color_t stringToColor(std::string str)
|
color_t stringToColor(std::string str)
|
||||||
{
|
{
|
||||||
color_t color = {0x00, 0x00, 0x00};
|
const std::string palette = "spectrum";
|
||||||
if (str == "black")
|
|
||||||
|
if (palette == "spectrum")
|
||||||
{
|
{
|
||||||
color = {0x00, 0x00, 0x00};
|
if (str == "black")
|
||||||
|
{
|
||||||
|
return {0x00, 0x00, 0x00};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_black")
|
||||||
|
{
|
||||||
|
return {0x00, 0x00, 0x00};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "blue")
|
||||||
|
{
|
||||||
|
return {0x00, 0x00, 0xd8};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_blue")
|
||||||
|
{
|
||||||
|
return {0x00, 0x00, 0xFF};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "red")
|
||||||
|
{
|
||||||
|
return {0xd8, 0x00, 0x00};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_red")
|
||||||
|
{
|
||||||
|
return {0xFF, 0x00, 0x00};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "magenta")
|
||||||
|
{
|
||||||
|
return {0xd8, 0x00, 0xd8};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_magenta")
|
||||||
|
{
|
||||||
|
return {0xFF, 0x00, 0xFF};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "green")
|
||||||
|
{
|
||||||
|
return {0x00, 0xd8, 0x00};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_green")
|
||||||
|
{
|
||||||
|
return {0x00, 0xFF, 0x00};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "cyan")
|
||||||
|
{
|
||||||
|
return {0x00, 0xd8, 0xd8};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_cyan")
|
||||||
|
{
|
||||||
|
return {0x00, 0xFF, 0xFF};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "yellow")
|
||||||
|
{
|
||||||
|
return {0xd8, 0xd8, 0x00};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_yellow")
|
||||||
|
{
|
||||||
|
return {0xFF, 0xFF, 0x00};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "white")
|
||||||
|
{
|
||||||
|
return {0xd8, 0xd8, 0xd8};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_white")
|
||||||
|
{
|
||||||
|
return {0xFF, 0xFF, 0xFF};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (str == "light_black")
|
|
||||||
{
|
else
|
||||||
color = {0x3C, 0x35, 0x1F};
|
{ // zxarne
|
||||||
|
if (str == "black")
|
||||||
|
{
|
||||||
|
return {0x00, 0x00, 0x00};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_black")
|
||||||
|
{
|
||||||
|
return {0x3C, 0x35, 0x1F};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "blue")
|
||||||
|
{
|
||||||
|
return {0x31, 0x33, 0x90};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_blue")
|
||||||
|
{
|
||||||
|
return {0x15, 0x59, 0xDB};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "red")
|
||||||
|
{
|
||||||
|
return {0xA7, 0x32, 0x11};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_red")
|
||||||
|
{
|
||||||
|
return {0xD8, 0x55, 0x25};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "magenta")
|
||||||
|
{
|
||||||
|
return {0xA1, 0x55, 0x89};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_magenta")
|
||||||
|
{
|
||||||
|
return {0xCD, 0x7A, 0x50};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "green")
|
||||||
|
{
|
||||||
|
return {0x62, 0x9A, 0x31};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_green")
|
||||||
|
{
|
||||||
|
return {0x9C, 0xD3, 0x3C};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "cyan")
|
||||||
|
{
|
||||||
|
return {0x28, 0xA4, 0xCB};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_cyan")
|
||||||
|
{
|
||||||
|
return {0x65, 0xDC, 0xD6};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "yellow")
|
||||||
|
{
|
||||||
|
return {0xE8, 0xBC, 0x50};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_yellow")
|
||||||
|
{
|
||||||
|
return {0xF1, 0xE7, 0x82};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "white")
|
||||||
|
{
|
||||||
|
return {0xBF, 0xBF, 0xBD};
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (str == "bright_white")
|
||||||
|
{
|
||||||
|
return {0xF2, 0xF1, 0xED};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (str == "blue")
|
|
||||||
{
|
return {0x00, 0x00, 0x00};
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
@@ -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 (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 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}
|
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) Tiles animados
|
||||||
(A) Crear ascensores
|
(A) Crear ascensores
|
||||||
x (A) Enemigos de diferente tamaño {cm:2022-08-30}
|
x (A) Enemigos de diferente tamaño {cm:2022-08-30}
|
||||||
@@ -23,16 +23,16 @@ 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}
|
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 indicador de si esta sonando la música
|
||||||
(A) Poner en el marcador el numero de habitaciones visitadas
|
(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
|
(A) Añadir a cada habitación el color del nombre de la habitación
|
||||||
|
|
||||||
(A) Crear el logo al estilo del logo de ERBE o TOPO, con lineas que lo formen
|
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
|
x (A) El titulo del juego hacerlo parecido al del Jet Set Willy in Paris
|
||||||
- Ha de generarse como las cargas de pantalla de spectrum
|
x - Ha de generarse como las cargas de pantalla de spectrum
|
||||||
- Luego se colorea
|
x - Luego se colorea
|
||||||
- Finalmente, cada elemento cambia de color como si fueran luces de neon
|
x - Finalmente, cada elemento cambia de color como si fueran luces de neon
|
||||||
(A) En el titulo del juego, por la parte inferior ha de aparecer una marquesina con texto, al estilo demoscene
|
x (A) En el titulo del juego, por la parte inferior ha de aparecer una marquesina con texto, al estilo demoscene
|
||||||
(A) La pantalla de titulo no tiene menu, solo un PRESS ENTER TO PLAY
|
x (A) La pantalla de titulo no tiene menu, solo un PRESS ENTER TO PLAY
|
||||||
|
|
||||||
|
|
||||||
## TEMAS
|
## TEMAS
|
||||||
|
|||||||
Reference in new issue
Block a user