Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 908ffa6d55 | |||
| d230259e42 | |||
| a61c2e8d46 | |||
| 9bb9d26417 | |||
| a96ce4afc9 | |||
| 29a2ebf221 | |||
| bcccfb026f | |||
| aad60d9849 | |||
| 4de0743a77 | |||
| 80e91e7acd |
32
Makefile
@@ -2,13 +2,14 @@ executable = jaildoctors_dilemma
|
|||||||
source = source/*.cpp source/common/*.cpp
|
source = source/*.cpp source/common/*.cpp
|
||||||
appName = JailDoctor's Dilemma
|
appName = JailDoctor's Dilemma
|
||||||
releaseFolder = jdd_release
|
releaseFolder = jdd_release
|
||||||
version = v1.07
|
version = v1.06.2
|
||||||
|
|
||||||
# Release names
|
# Release names
|
||||||
windowsRelease = $(executable)-$(version)-win32-x64.zip
|
windowsRelease = $(executable)-$(version)-win32-x64.zip
|
||||||
macosIntelRelease = $(executable)-$(version)-macos-intel.dmg
|
macosIntelRelease = $(executable)-$(version)-macos-intel.dmg
|
||||||
macosAppleSiliconRelease = $(executable)-$(version)-macos-apple-silicon.dmg
|
macosAppleSiliconRelease = $(executable)-$(version)-macos-apple-silicon.dmg
|
||||||
linuxRelease = $(executable)-$(version)-linux.tar.gz
|
linuxRelease = $(executable)-$(version)-linux.tar.gz
|
||||||
|
opendinguxRelease = $(executable).opk
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
@echo off
|
@echo off
|
||||||
@@ -140,3 +141,32 @@ linux_release:
|
|||||||
|
|
||||||
# Remove data
|
# Remove data
|
||||||
rm -rdf "$(releaseFolder)"
|
rm -rdf "$(releaseFolder)"
|
||||||
|
|
||||||
|
opendingux:
|
||||||
|
/opt/gcw0-toolchain/usr/bin/mipsel-linux-g++ -D GCWZERO -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL2 -D_GNU_SOURCE=1 -D_REENTRANT -lSDL2 -lSDL2_mixer -lstdc++ -std=c++11 $(source) -o "$(executable)"
|
||||||
|
|
||||||
|
opendingux_release:
|
||||||
|
# Remove data
|
||||||
|
rm -rdf "$(releaseFolder)"
|
||||||
|
|
||||||
|
# Create folders
|
||||||
|
mkdir -p "$(releaseFolder)"
|
||||||
|
|
||||||
|
# Copy data
|
||||||
|
cp -R data "$(releaseFolder)"
|
||||||
|
cp -R default.gcw0.desktop "$(releaseFolder)"
|
||||||
|
cp -R icon.png "$(releaseFolder)"
|
||||||
|
|
||||||
|
# Delete data
|
||||||
|
rm -f "$(releaseFolder)/data/room/map.world"
|
||||||
|
rm -f "$(releaseFolder)/data/room/standard.tsx"
|
||||||
|
|
||||||
|
# Build
|
||||||
|
/opt/gcw0-toolchain/usr/bin/mipsel-linux-g++ -D GCWZERO -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL2 -D_GNU_SOURCE=1 -D_REENTRANT -lSDL2 -lSDL2_mixer -lstdc++ -std=c++11 $(source) -o "$(releaseFolder)/$(executable)"
|
||||||
|
|
||||||
|
# Pack files
|
||||||
|
rm -f "$(opendinguxRelease)"
|
||||||
|
cd "$(releaseFolder)" && /opt/gcw0-toolchain/usr/bin/mksquashfs ./default.gcw0.desktop ./icon.png ./data ./$(executable) "../$(opendinguxRelease)" -all-root -noappend -no-exports -no-xattrs
|
||||||
|
|
||||||
|
# Remove data
|
||||||
|
rm -rdf "$(releaseFolder)"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# JailDoctor's Dilemma (v1.07)
|
# JailDoctor's Dilemma (v1.06.2)
|
||||||
|
|
||||||
JailDoc es un Jailer. A los Jailers les gusta empezar proyectos. A nadie le gusta terminarlos. Los Jailers viven en la Jail. A la Jail va uno a empezar proyectos. A la Jail va uno a enseñar sus proyectos. A la Jail va uno a aprender como empezar nuevos proyectos. A la Jail va uno a ayudar a sus compañeros a que empiecen nuevos proyectos.
|
JailDoc es un Jailer. A los Jailers les gusta empezar proyectos. A nadie le gusta terminarlos. Los Jailers viven en la Jail. A la Jail va uno a empezar proyectos. A la Jail va uno a enseñar sus proyectos. A la Jail va uno a aprender como empezar nuevos proyectos. A la Jail va uno a ayudar a sus compañeros a que empiecen nuevos proyectos.
|
||||||
|
|
||||||
|
|||||||
3
build.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
/opt/gcw0-toolchain/usr/bin/mipsel-linux-g++ -D GCWZERO -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL2 -D_GNU_SOURCE=1 -D_REENTRANT -lSDL2 -lstdc++ -std=c++11 source/*.cpp source/common/*.cpp -o jdd
|
||||||
|
sftp root@10.1.1.2:jdd <<< $'put jdd'
|
||||||
|
ssh root@10.1.1.2
|
||||||
@@ -3,7 +3,7 @@ frameHeight=16
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
speed=4
|
speed=8
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3,4,5,6,7
|
frames=0,1,2,3
|
||||||
[/animation]
|
[/animation]
|
||||||
|
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 239 B |
@@ -3,9 +3,9 @@
|
|||||||
<tileset firstgid="1" source="standard.tsx"/>
|
<tileset firstgid="1" source="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">
|
||||||
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
|
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
|
||||||
168,166,185,167,166,185,166,166,168,166,166,167,166,166,185,166,166,43,43,43,43,43,43,43,43,43,43,43,43,43,43,166,
|
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,
|
||||||
211,181,211,213,211,181,211,212,213,211,181,211,211,212,211,213,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
||||||
164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
||||||
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
|
||||||
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,
|
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name=P.A.C.O. ON THE GO
|
name=P.A.C.O. ON THE GO
|
||||||
bgColor=black
|
bgColor=black
|
||||||
border=blue
|
border=black
|
||||||
tileMapFile=42.tmx
|
tileMapFile=42.tmx
|
||||||
tileSetFile=standard.png
|
tileSetFile=standard.png
|
||||||
roomUp=0
|
roomUp=0
|
||||||
@@ -23,7 +23,7 @@ x1=10
|
|||||||
y1=2
|
y1=2
|
||||||
x2=10
|
x2=10
|
||||||
y2=11
|
y2=11
|
||||||
color=magenta
|
color=green
|
||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
36,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,415,421,62,
|
36,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,415,421,62,
|
||||||
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,
|
||||||
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,421,415,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,421,415,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
36,0,0,0,0,0,0,0,306,0,0,0,0,306,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,0,0,0,0,305,0,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
36,0,0,0,306,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
36,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,
|
36,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,
|
||||||
36,0,415,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,0,0,421,415,0,0,0,0,0,0,
|
36,0,415,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,0,0,421,415,0,0,0,0,0,0,
|
||||||
36,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,
|
36,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,
|
||||||
|
|||||||
@@ -11,22 +11,6 @@ itemColor1=red
|
|||||||
itemColor2=magenta
|
itemColor2=magenta
|
||||||
autoSurface=left
|
autoSurface=left
|
||||||
|
|
||||||
[enemy]
|
|
||||||
tileSetFile=batman_fire.png
|
|
||||||
animation=batman_fire.ani
|
|
||||||
width=16
|
|
||||||
height=16
|
|
||||||
x=10
|
|
||||||
y=13
|
|
||||||
vx=1.3
|
|
||||||
vy=0
|
|
||||||
x1=0
|
|
||||||
y1=13
|
|
||||||
x2=29
|
|
||||||
y2=13
|
|
||||||
color=cyan
|
|
||||||
flip=true
|
|
||||||
[/enemy]
|
|
||||||
|
|
||||||
[enemy]
|
[enemy]
|
||||||
tileSetFile=heavy.png
|
tileSetFile=heavy.png
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name=P.A.C.O. WORKSHOP
|
name=P.A.C.O WORKSHOP
|
||||||
bgColor=black
|
bgColor=black
|
||||||
border=yellow
|
border=yellow
|
||||||
tileMapFile=53.tmx
|
tileMapFile=53.tmx
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 7.3 KiB |
10
default.gcw0.desktop
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Version=1.6
|
||||||
|
Type=Application
|
||||||
|
Name=JailDoctor's Dilemma
|
||||||
|
Comment=JailDoctor's Dilemma
|
||||||
|
Icon=icon
|
||||||
|
Exec=jaildoctors_dilemma
|
||||||
|
Categories=games;Game;SDL;
|
||||||
|
Terminal=false
|
||||||
|
|
||||||
@@ -23,11 +23,11 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0.7</string>
|
<string>1.0.6.2</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.0.7</string>
|
<string>1.0.6.2</string>
|
||||||
<key>CSResourcesFileMapped</key>
|
<key>CSResourcesFileMapped</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
@@ -4,7 +4,11 @@
|
|||||||
// Constructor
|
// Constructor
|
||||||
Asset::Asset(std::string executablePath)
|
Asset::Asset(std::string executablePath)
|
||||||
{
|
{
|
||||||
|
#ifdef __MIPSEL
|
||||||
|
this->executablePath = ".";
|
||||||
|
#else
|
||||||
this->executablePath = executablePath.substr(0, executablePath.find_last_of("\\/"));
|
this->executablePath = executablePath.substr(0, executablePath.find_last_of("\\/"));
|
||||||
|
#endif
|
||||||
longestName = 0;
|
longestName = 0;
|
||||||
verbose = true;
|
verbose = true;
|
||||||
}
|
}
|
||||||
|
|||||||
30
source/common/destsurface.cpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#include "destsurface.h"
|
||||||
|
#include "systempalette.h"
|
||||||
|
|
||||||
|
namespace DestSurface
|
||||||
|
{
|
||||||
|
uint8_t *pixels = nullptr;
|
||||||
|
int width, height;
|
||||||
|
|
||||||
|
void init(int width, int height)
|
||||||
|
{
|
||||||
|
if (pixels==nullptr) pixels = new uint8_t[width*height];
|
||||||
|
DestSurface::width = width;
|
||||||
|
DestSurface::height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear(uint32_t color)
|
||||||
|
{
|
||||||
|
SDL_memset(pixels, SystemPalette::getEntry(color), width*height);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t *getPixels()
|
||||||
|
{
|
||||||
|
return pixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getWidth()
|
||||||
|
{
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
}
|
||||||
14
source/common/destsurface.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
|
namespace DestSurface
|
||||||
|
{
|
||||||
|
void init(int width, int height);
|
||||||
|
|
||||||
|
void clear(uint32_t color);
|
||||||
|
|
||||||
|
uint8_t *getPixels();
|
||||||
|
|
||||||
|
int getWidth();
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "destsurface.h"
|
||||||
|
#include "systempalette.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options_t *options)
|
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options_t *options)
|
||||||
@@ -28,7 +30,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
|
|||||||
borderColor = {0x00, 0x00, 0x00};
|
borderColor = {0x00, 0x00, 0x00};
|
||||||
|
|
||||||
// Crea la textura donde se dibujan los graficos del juego
|
// Crea la textura donde se dibujan los graficos del juego
|
||||||
gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth, gameCanvasHeight);
|
gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, gameCanvasWidth, gameCanvasHeight);
|
||||||
if (gameCanvas == nullptr)
|
if (gameCanvas == nullptr)
|
||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
@@ -37,6 +39,8 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DestSurface::init(gameCanvasWidth, gameCanvasHeight);
|
||||||
|
|
||||||
// Establece el modo de video
|
// Establece el modo de video
|
||||||
setVideoMode(options->videoMode);
|
setVideoMode(options->videoMode);
|
||||||
|
|
||||||
@@ -53,26 +57,34 @@ Screen::~Screen()
|
|||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
void Screen::clean(color_t color)
|
void Screen::clean(color_t color)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
DestSurface::clear((color.r<<24) + (color.g<<16) + (color.b<<8) + 255);
|
||||||
SDL_RenderClear(renderer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
void Screen::start()
|
void Screen::start()
|
||||||
{
|
{
|
||||||
SDL_SetRenderTarget(renderer, gameCanvas);
|
//SDL_SetRenderTarget(renderer, gameCanvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
void Screen::blit()
|
void Screen::blit()
|
||||||
{
|
{
|
||||||
// Vuelve a dejar el renderizador en modo normal
|
// Vuelve a dejar el renderizador en modo normal
|
||||||
SDL_SetRenderTarget(renderer, nullptr);
|
//SDL_SetRenderTarget(renderer, nullptr);
|
||||||
|
|
||||||
// Borra el contenido previo
|
// Borra el contenido previo
|
||||||
SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF);
|
SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
uint8_t *destSurface = DestSurface::getPixels();
|
||||||
|
|
||||||
|
Uint32 *pixels;
|
||||||
|
int pitch;
|
||||||
|
int size = gameCanvasWidth*gameCanvasHeight;
|
||||||
|
SDL_LockTexture(gameCanvas, NULL, (void**)&pixels, &pitch);
|
||||||
|
for (int i=0;i<size;++i) pixels[i] = SystemPalette::getRGBA(destSurface[i]);
|
||||||
|
SDL_UnlockTexture(gameCanvas);
|
||||||
|
|
||||||
// Copia la textura de juego en el renderizador en la posición adecuada
|
// Copia la textura de juego en el renderizador en la posición adecuada
|
||||||
SDL_RenderCopy(renderer, gameCanvas, nullptr, &dest);
|
SDL_RenderCopy(renderer, gameCanvas, nullptr, &dest);
|
||||||
|
|
||||||
|
|||||||
60
source/common/systempalette.cpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#include "systempalette.h"
|
||||||
|
|
||||||
|
namespace SystemPalette
|
||||||
|
{
|
||||||
|
|
||||||
|
uint32_t entries[256]; // Las 256 entradas de la paleta
|
||||||
|
uint8_t numEntries; // El número de entradas existente actualmente
|
||||||
|
|
||||||
|
// Vacía la paleta
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
// Fijamos el color transparente en 0 y el blanco en 1
|
||||||
|
entries[0] = 0x00000000; // Transparente
|
||||||
|
entries[1] = 0xffffffff; // Blanco
|
||||||
|
|
||||||
|
numEntries = 2;
|
||||||
|
|
||||||
|
// Ya que 'getRGBA' no comprueba que el índice solicitado sea menor que
|
||||||
|
// 'numentries', rellenamos con 'negro' todas las entradas no usadas.
|
||||||
|
for (int i = 2; i < 256; ++i ) entries[i] = 0x000000ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtenemos el índice de la paleta para el color especificado. Si no existe se crea.
|
||||||
|
uint8_t getEntry(const uint32_t color)
|
||||||
|
{
|
||||||
|
// ATENCIÓN!!! Si intentamos introducir más de 256 colores empezará a
|
||||||
|
// sobreescribir los primeros colores. Al menos no corromperá la
|
||||||
|
// memoria. Pensar la mejor forma de controlar esto.
|
||||||
|
|
||||||
|
// Recorremos la paleta...
|
||||||
|
for (int i = 0; i < numEntries; ++i)
|
||||||
|
{
|
||||||
|
// Si encontramos el color, devolvemos su índice y salimos
|
||||||
|
if (entries[i] == color) return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si no se ha encontrado, lo ponemos al final
|
||||||
|
entries[numEntries] = color;
|
||||||
|
|
||||||
|
// Y devolvemos su índice
|
||||||
|
return numEntries++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Versión de getEntry para obtener el color con los componentes R, G y B
|
||||||
|
uint8_t getEntry(const uint8_t r, const uint8_t g, const uint8_t b)
|
||||||
|
{
|
||||||
|
return getEntry( (r<<24) + (g<<16) + (b<<8) + 255 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dado un índice, devolvemos su color
|
||||||
|
uint32_t getRGBA(const uint8_t entry)
|
||||||
|
{
|
||||||
|
// ATENCIÓN!!! No compruebo que el parámetro 'entry' sea menor que el
|
||||||
|
// miembro 'numEntries', por lo que se puede acceder a colores no
|
||||||
|
// definidos (por ejemplo tener 4 colores y acceder al color 8). La
|
||||||
|
// razón es que necesito que esta función sea lo más rápida posible.
|
||||||
|
// En cualquier caso, nunca se va a salir de la memoria ni nada raro.
|
||||||
|
return entries[entry];
|
||||||
|
}
|
||||||
|
}
|
||||||
17
source/common/systempalette.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace SystemPalette
|
||||||
|
{
|
||||||
|
// Vacía la paleta
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
// Obtenemos el índice de la paleta para el color especificado. Si no existe se crea.
|
||||||
|
uint8_t getEntry(const uint32_t color);
|
||||||
|
|
||||||
|
// Versión de getEntry para obtener el color con los componentes R, G y B
|
||||||
|
uint8_t getEntry(const uint8_t r, const uint8_t g, const uint8_t b);
|
||||||
|
|
||||||
|
// Dado un índice, devolvemos su color
|
||||||
|
uint32_t getRGBA(const uint8_t entry);
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "systempalette.h"
|
||||||
|
#include "destsurface.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose)
|
Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose)
|
||||||
@@ -12,14 +14,15 @@ Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose)
|
|||||||
this->path = path;
|
this->path = path;
|
||||||
|
|
||||||
// Inicializa
|
// Inicializa
|
||||||
texture = nullptr;
|
this->pixels = nullptr;
|
||||||
width = 0;
|
this->width = 0;
|
||||||
height = 0;
|
this->height = 0;
|
||||||
|
this->color = 0xffffffff;
|
||||||
|
|
||||||
// Carga el fichero en la textura
|
// Carga el fichero en la textura
|
||||||
if (path != "")
|
if (path != "")
|
||||||
{
|
{
|
||||||
loadFromFile(path, renderer, verbose);
|
loadFromFile(path, verbose);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +34,7 @@ Texture::~Texture()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga una imagen desde un fichero
|
// Carga una imagen desde un fichero
|
||||||
bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer, bool verbose)
|
bool Texture::loadFromFile(std::string path, bool verbose)
|
||||||
{
|
{
|
||||||
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
|
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
|
||||||
int req_format = STBI_rgb_alpha;
|
int req_format = STBI_rgb_alpha;
|
||||||
@@ -50,90 +53,39 @@ bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer, bool verbos
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int depth, pitch;
|
|
||||||
Uint32 pixel_format;
|
|
||||||
if (req_format == STBI_rgb)
|
|
||||||
{
|
|
||||||
depth = 24;
|
|
||||||
pitch = 3 * width; // 3 bytes por pixel * pixels per linea
|
|
||||||
pixel_format = SDL_PIXELFORMAT_RGB24;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // STBI_rgb_alpha (RGBA)
|
|
||||||
depth = 32;
|
|
||||||
pitch = 4 * width;
|
|
||||||
pixel_format = SDL_PIXELFORMAT_RGBA32;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Limpia
|
// Limpia
|
||||||
unload();
|
unload();
|
||||||
|
|
||||||
// La textura final
|
this->width = width;
|
||||||
SDL_Texture *newTexture = nullptr;
|
this->height = height;
|
||||||
|
const int size = width*height;
|
||||||
// Carga la imagen desde una ruta específica
|
this->pixels = new uint8_t[size];
|
||||||
SDL_Surface *loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom((void *)data, width, height, depth, pitch, pixel_format);
|
for (int i = 0; i < size; ++i) this->pixels[i] = SystemPalette::getEntry(data[i]);
|
||||||
if (loadedSurface == nullptr)
|
|
||||||
{
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
std::cout << "Unable to load image " << path.c_str() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Crea la textura desde los pixels de la surface
|
|
||||||
newTexture = SDL_CreateTextureFromSurface(renderer, loadedSurface);
|
|
||||||
if (newTexture == nullptr)
|
|
||||||
{
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
std::cout << "Unable to create texture from " << path.c_str() << "! SDL Error: " << SDL_GetError() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Obtiene las dimensiones de la imagen
|
|
||||||
this->width = loadedSurface->w;
|
|
||||||
this->height = loadedSurface->h;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Elimina la textura cargada
|
|
||||||
SDL_FreeSurface(loadedSurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return success
|
// Return success
|
||||||
stbi_image_free(data);
|
stbi_image_free(data);
|
||||||
texture = newTexture;
|
return this->pixels != nullptr;
|
||||||
return texture != nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea una textura en blanco
|
// Crea una textura en blanco
|
||||||
bool Texture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess access)
|
bool Texture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess access)
|
||||||
{
|
{
|
||||||
// Crea una textura sin inicializar
|
// Crea una textura sin inicializar
|
||||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, access, width, height);
|
this->pixels = new uint8_t[width*height];
|
||||||
if (texture == nullptr)
|
|
||||||
{
|
|
||||||
std::cout << "Unable to create blank texture! SDL Error: " << SDL_GetError() << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->width = width;
|
this->width = width;
|
||||||
this->height = height;
|
this->height = height;
|
||||||
}
|
|
||||||
|
|
||||||
return texture != nullptr;
|
return this->pixels != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Libera la memoria de la textura
|
// Libera la memoria de la textura
|
||||||
void Texture::unload()
|
void Texture::unload()
|
||||||
{
|
{
|
||||||
// Libera la textura si existe
|
// Libera la textura si existe
|
||||||
if (texture != nullptr)
|
if (pixels != nullptr)
|
||||||
{
|
{
|
||||||
SDL_DestroyTexture(texture);
|
delete[] pixels;
|
||||||
texture = nullptr;
|
pixels = nullptr;
|
||||||
width = 0;
|
width = 0;
|
||||||
height = 0;
|
height = 0;
|
||||||
}
|
}
|
||||||
@@ -142,19 +94,19 @@ void Texture::unload()
|
|||||||
// Establece el color para la modulacion
|
// Establece el color para la modulacion
|
||||||
void Texture::setColor(Uint8 red, Uint8 green, Uint8 blue)
|
void Texture::setColor(Uint8 red, Uint8 green, Uint8 blue)
|
||||||
{
|
{
|
||||||
SDL_SetTextureColorMod(texture, red, green, blue);
|
this->color = (red << 24) + (green << 16) + (blue << 8) + 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el blending
|
// Establece el blending
|
||||||
void Texture::setBlendMode(SDL_BlendMode blending)
|
void Texture::setBlendMode(SDL_BlendMode blending)
|
||||||
{
|
{
|
||||||
SDL_SetTextureBlendMode(texture, blending);
|
//SDL_SetTextureBlendMode(texture, blending);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el alpha para la modulación
|
// Establece el alpha para la modulación
|
||||||
void Texture::setAlpha(Uint8 alpha)
|
void Texture::setAlpha(Uint8 alpha)
|
||||||
{
|
{
|
||||||
SDL_SetTextureAlphaMod(texture, alpha);
|
//SDL_SetTextureAlphaMod(texture, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renderiza la textura en un punto específico
|
// Renderiza la textura en un punto específico
|
||||||
@@ -174,13 +126,24 @@ void Texture::render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip, float
|
|||||||
renderQuad.h = renderQuad.h * zoomH;
|
renderQuad.h = renderQuad.h * zoomH;
|
||||||
|
|
||||||
// Renderiza a pantalla
|
// Renderiza a pantalla
|
||||||
SDL_RenderCopyEx(renderer, texture, clip, &renderQuad, angle, center, flip);
|
//SDL_RenderCopyEx(renderer, texture, clip, &renderQuad, angle, center, flip);
|
||||||
|
|
||||||
|
uint8_t *destSurface = DestSurface::getPixels();
|
||||||
|
int canvasWidth = DestSurface::getWidth();
|
||||||
|
|
||||||
|
int y_inc = 1, y_ini = 0, y_fin = renderQuad.h-1; if (flip && SDL_FLIP_VERTICAL==SDL_FLIP_VERTICAL) { auto tmp=y_ini; y_ini=y_fin; y_fin=tmp; y_inc=-1; }
|
||||||
|
int x_inc = 1, x_ini = 0, x_fin = renderQuad.w-1; if (flip && SDL_FLIP_HORIZONTAL==SDL_FLIP_HORIZONTAL) { auto tmp=x_ini; x_ini=x_fin; x_fin=tmp; x_inc=-1; }
|
||||||
|
for (int yy=y_ini; yy <= y_fin; yy += y_inc) {
|
||||||
|
for (int xx=x_ini; xx <= x_fin; xx += x_inc) {
|
||||||
|
destSurface[ x+xx + y+yy * canvasWidth ] = pixels[ clip->x+xx + clip->y+yy * width ];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la textura como objetivo de renderizado
|
// Establece la textura como objetivo de renderizado
|
||||||
void Texture::setAsRenderTarget(SDL_Renderer *renderer)
|
void Texture::setAsRenderTarget(SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
SDL_SetRenderTarget(renderer, texture);
|
//SDL_SetRenderTarget(renderer, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el ancho de la imagen
|
// Obtiene el ancho de la imagen
|
||||||
@@ -204,5 +167,5 @@ bool Texture::reLoad()
|
|||||||
// Obtiene la textura
|
// Obtiene la textura
|
||||||
SDL_Texture *Texture::getSDLTexture()
|
SDL_Texture *Texture::getSDLTexture()
|
||||||
{
|
{
|
||||||
return texture;
|
return nullptr; //texture;
|
||||||
}
|
}
|
||||||
@@ -11,13 +11,14 @@ class Texture
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Texture *texture; // La textura
|
uint8_t *pixels; // Los pixels de esta textura
|
||||||
SDL_Renderer *renderer; // Renderizador donde dibujar la textura
|
SDL_Renderer *renderer; // Renderizador donde dibujar la textura
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
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
|
||||||
|
uint32_t color; // Color para el pintado de 1 bit (sprites y tal)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -27,7 +28,7 @@ public:
|
|||||||
~Texture();
|
~Texture();
|
||||||
|
|
||||||
// Carga una imagen desde un fichero
|
// Carga una imagen desde un fichero
|
||||||
bool loadFromFile(std::string path, SDL_Renderer *renderer, bool verbose = false);
|
bool loadFromFile(std::string path, bool verbose = false);
|
||||||
|
|
||||||
// Crea una textura en blanco
|
// Crea una textura en blanco
|
||||||
bool createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess = SDL_TEXTUREACCESS_STREAMING);
|
bool createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess = SDL_TEXTUREACCESS_STREAMING);
|
||||||
|
|||||||
@@ -101,7 +101,6 @@ struct cheat_t
|
|||||||
struct online_t
|
struct online_t
|
||||||
{
|
{
|
||||||
bool enabled; // Indica si se quiere usar el modo online o no
|
bool enabled; // Indica si se quiere usar el modo online o no
|
||||||
bool sessionEnabled; // Indica ya se ha hecho login
|
|
||||||
std::string server; // Servidor para los servicios online
|
std::string server; // Servidor para los servicios online
|
||||||
int port; // Puerto del servidor
|
int port; // Puerto del servidor
|
||||||
std::string gameID; // Identificador del juego para los servicios online
|
std::string gameID; // Identificador del juego para los servicios online
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
board.lives = 9;
|
board.lives = 9;
|
||||||
board.items = 0;
|
board.items = 0;
|
||||||
board.rooms = 1;
|
board.rooms = 1;
|
||||||
board.jailEnabled = false;
|
board.jailEnabled = options->cheat.jailEnabled;
|
||||||
board.music = true;
|
board.music = true;
|
||||||
setScoreBoardColor();
|
setScoreBoardColor();
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ void Director::initOptions()
|
|||||||
options->videoMode = 0;
|
options->videoMode = 0;
|
||||||
options->windowSize = 3;
|
options->windowSize = 3;
|
||||||
options->filter = FILTER_NEAREST;
|
options->filter = FILTER_NEAREST;
|
||||||
options->vSync = true;
|
options->vSync = false;
|
||||||
options->integerScale = true;
|
options->integerScale = true;
|
||||||
options->keepAspect = true;
|
options->keepAspect = true;
|
||||||
options->borderEnabled = true;
|
options->borderEnabled = true;
|
||||||
@@ -130,11 +130,11 @@ void Director::initOptions()
|
|||||||
options->palette = p_zxspectrum;
|
options->palette = p_zxspectrum;
|
||||||
|
|
||||||
#ifdef GAME_CONSOLE
|
#ifdef GAME_CONSOLE
|
||||||
options->windowSize = 2;
|
options->windowSize = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Estos valores no se guardan en el fichero de configuraci´ón
|
// Estos valores no se guardan en el fichero de configuraci´ón
|
||||||
options->console = false;
|
options->console = true;
|
||||||
options->cheat.infiniteLives = false;
|
options->cheat.infiniteLives = false;
|
||||||
options->cheat.invincible = false;
|
options->cheat.invincible = false;
|
||||||
options->cheat.jailEnabled = false;
|
options->cheat.jailEnabled = false;
|
||||||
@@ -144,7 +144,6 @@ void Director::initOptions()
|
|||||||
|
|
||||||
// Opciones online
|
// Opciones online
|
||||||
options->online.enabled = true;
|
options->online.enabled = true;
|
||||||
options->online.sessionEnabled = false;
|
|
||||||
options->online.server = "jaildoctor.duckdns.org";
|
options->online.server = "jaildoctor.duckdns.org";
|
||||||
options->online.port = 9911;
|
options->online.port = 9911;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|||||||
@@ -281,11 +281,6 @@ void EnterID::switchPalette()
|
|||||||
// Inicializa los servicios online
|
// Inicializa los servicios online
|
||||||
void EnterID::initOnline()
|
void EnterID::initOnline()
|
||||||
{
|
{
|
||||||
if (options->online.sessionEnabled)
|
|
||||||
{ // Si ya ha iniciado la sesión, que no continue
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options->online.jailerID == "")
|
if (options->online.jailerID == "")
|
||||||
{ // Jailer ID no definido
|
{ // Jailer ID no definido
|
||||||
|
|
||||||
@@ -294,14 +289,10 @@ void EnterID::initOnline()
|
|||||||
else
|
else
|
||||||
{ // Jailer ID iniciado
|
{ // Jailer ID iniciado
|
||||||
|
|
||||||
options->online.enabled = options->online.sessionEnabled = true;
|
options->online.enabled = true;
|
||||||
jscore::init(options->online.server, options->online.port);
|
jscore::init(options->online.server, options->online.port);
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
const std::string caption = options->online.jailerID + " IS LOGGED IN (DEBUG)";
|
|
||||||
#else
|
|
||||||
const std::string caption = options->online.jailerID + " IS LOGGED IN";
|
const std::string caption = options->online.jailerID + " IS LOGGED IN";
|
||||||
#endif
|
|
||||||
screen->showNotification(caption);
|
screen->showNotification(caption);
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,25 +42,6 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
|
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
|
||||||
stats = new Stats(asset->get("stats.csv"), asset->get("stats_buffer.csv"), options);
|
stats = new Stats(asset->get("stats.csv"), asset->get("stats_buffer.csv"), options);
|
||||||
|
|
||||||
// Crea la textura para poner el nombre de la habitación
|
|
||||||
roomNameTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, text->getCharacterSize() * 2);
|
|
||||||
if (roomNameTexture == nullptr)
|
|
||||||
{
|
|
||||||
if (options->console)
|
|
||||||
{
|
|
||||||
std::cout << "Error: roomNameTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el blend mode de la textura
|
|
||||||
SDL_SetTextureBlendMode(roomNameTexture, SDL_BLENDMODE_BLEND);
|
|
||||||
|
|
||||||
// Establece el destino de la textura
|
|
||||||
roomNameRect = {0, PLAY_AREA_HEIGHT, GAMECANVAS_WIDTH, text->getCharacterSize() * 2};
|
|
||||||
|
|
||||||
// Pone el nombre de la habitación en la textura
|
|
||||||
fillRoomNameTexture();
|
|
||||||
|
|
||||||
// Inicializa el resto de variables
|
// Inicializa el resto de variables
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
@@ -97,8 +78,6 @@ Game::~Game()
|
|||||||
delete text;
|
delete text;
|
||||||
delete stats;
|
delete stats;
|
||||||
|
|
||||||
SDL_DestroyTexture(roomNameTexture);
|
|
||||||
|
|
||||||
JA_DeleteMusic(music);
|
JA_DeleteMusic(music);
|
||||||
JA_DeleteSound(deathSound);
|
JA_DeleteSound(deathSound);
|
||||||
}
|
}
|
||||||
@@ -338,8 +317,13 @@ void Game::renderDebugInfo()
|
|||||||
// Escribe el nombre de la pantalla
|
// Escribe el nombre de la pantalla
|
||||||
void Game::renderRoomName()
|
void Game::renderRoomName()
|
||||||
{
|
{
|
||||||
// Dibuja la textura con el nombre de la habitación
|
// Texto en el centro de la pantalla
|
||||||
SDL_RenderCopy(renderer, roomNameTexture, nullptr, &roomNameRect);
|
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2};
|
||||||
|
color_t color = stringToColor(options->palette, "white");
|
||||||
|
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
|
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
|
||||||
@@ -361,9 +345,6 @@ bool Game::changeRoom(std::string file)
|
|||||||
// Crea un objeto habitación nuevo a partir del fichero
|
// Crea un objeto habitación nuevo a partir del fichero
|
||||||
room = new Room(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
|
room = new Room(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
|
||||||
|
|
||||||
// Pone el nombre de la habitación en la textura
|
|
||||||
fillRoomNameTexture();
|
|
||||||
|
|
||||||
// Pone el color del marcador en función del color del borde de la habitación
|
// Pone el color del marcador en función del color del borde de la habitación
|
||||||
setScoreBoardColor();
|
setScoreBoardColor();
|
||||||
|
|
||||||
@@ -559,7 +540,7 @@ void Game::setScoreBoardColor()
|
|||||||
bool Game::checkEndGame()
|
bool Game::checkEndGame()
|
||||||
{
|
{
|
||||||
const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca
|
const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca
|
||||||
const bool haveTheItems = board.items >= int(totalItems * 0.9f) || options->cheat.jailEnabled; // Con mas del 90% de los items recogidos
|
const bool haveTheItems = board.items >= int(totalItems * 0.9f); // Con mas del 90% de los items recogidos
|
||||||
const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
||||||
|
|
||||||
if (haveTheItems)
|
if (haveTheItems)
|
||||||
@@ -567,7 +548,13 @@ bool Game::checkEndGame()
|
|||||||
board.jailEnabled = true;
|
board.jailEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (haveTheItems && isOnTheRoom && isOnTheDoor)
|
if (isOnTheRoom && haveTheItems && isOnTheDoor)
|
||||||
|
{
|
||||||
|
section.name = SECTION_PROG_ENDING;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options->cheat.jailEnabled && isOnTheRoom && isOnTheDoor)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_ENDING;
|
section.name = SECTION_PROG_ENDING;
|
||||||
return true;
|
return true;
|
||||||
@@ -629,12 +616,7 @@ void Game::checkRestoringJail()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
|
|
||||||
if (!paused)
|
|
||||||
{
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
|
||||||
|
|
||||||
if (counter == 100)
|
if (counter == 100)
|
||||||
{
|
{
|
||||||
counter = 0;
|
counter = 0;
|
||||||
@@ -656,21 +638,3 @@ void Game::initStats()
|
|||||||
|
|
||||||
stats->init();
|
stats->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea la textura con el nombre de la habitación
|
|
||||||
void Game::fillRoomNameTexture()
|
|
||||||
{
|
|
||||||
// Pone la textura como destino de renderizado
|
|
||||||
SDL_SetRenderTarget(renderer, roomNameTexture);
|
|
||||||
|
|
||||||
// Rellena la textura de color
|
|
||||||
const color_t color = stringToColor(options->palette, "white");
|
|
||||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
|
||||||
SDL_RenderClear(renderer);
|
|
||||||
|
|
||||||
// Escribe el texto en la textura
|
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, text->getCharacterSize() / 2, room->getName(), 1, room->getBGColor());
|
|
||||||
|
|
||||||
// Deja el renderizador por defecto
|
|
||||||
SDL_SetRenderTarget(renderer, nullptr);
|
|
||||||
}
|
|
||||||
@@ -41,7 +41,6 @@ private:
|
|||||||
Debug *debug; // Objeto para gestionar la información de debug
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
Stats *stats; // Objeto encargado de gestionar las estadísticas
|
Stats *stats; // Objeto encargado de gestionar las estadísticas
|
||||||
SDL_Texture *roomNameTexture; // Textura para escribir el nombre de la habitación
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
JA_Music_t* music; // Musica que suena durante el juego
|
JA_Music_t* music; // Musica que suena durante el juego
|
||||||
@@ -56,7 +55,6 @@ private:
|
|||||||
bool blackScreen; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador
|
bool blackScreen; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador
|
||||||
int blackScreenCounter; // Contador para temporizar la pantalla en negro
|
int blackScreenCounter; // Contador para temporizar la pantalla en negro
|
||||||
int totalItems; // Cantidad total de items que hay en el mapeado del juego
|
int totalItems; // Cantidad total de items que hay en el mapeado del juego
|
||||||
SDL_Rect roomNameRect; // Rectangulo donde pintar la textura con el nombre de la habitación
|
|
||||||
|
|
||||||
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||||
void update();
|
void update();
|
||||||
@@ -135,9 +133,6 @@ private:
|
|||||||
// Inicializa el diccionario de las estadísticas
|
// Inicializa el diccionario de las estadísticas
|
||||||
void initStats();
|
void initStats();
|
||||||
|
|
||||||
// Pone el nombre de la habitación en la textura
|
|
||||||
void fillRoomNameTexture();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug);
|
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug);
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ void Intro::checkEventHandler()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
case SDL_SCANCODE_F5:
|
||||||
//switchPalette();
|
switchPalette();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -473,7 +473,7 @@ Room::Room(room_t *room, SDL_Renderer *renderer, Screen *screen, Asset *asset, o
|
|||||||
setAnimatedTiles();
|
setAnimatedTiles();
|
||||||
|
|
||||||
// Crea la textura para el mapa de tiles de la habitación
|
// Crea la textura para el mapa de tiles de la habitación
|
||||||
mapTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT);
|
mapTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||||
if (mapTexture == nullptr)
|
if (mapTexture == nullptr)
|
||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
@@ -665,8 +665,7 @@ void Room::fillMapTexture()
|
|||||||
void Room::renderMap()
|
void Room::renderMap()
|
||||||
{
|
{
|
||||||
// Dibuja la textura con el mapa en pantalla
|
// Dibuja la textura con el mapa en pantalla
|
||||||
SDL_Rect dest = {0, 0, PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT};
|
SDL_RenderCopy(renderer, mapTexture, nullptr, nullptr);
|
||||||
SDL_RenderCopy(renderer, mapTexture, nullptr, &dest);
|
|
||||||
|
|
||||||
// Dibuja los tiles animados
|
// Dibuja los tiles animados
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -1524,6 +1523,9 @@ void Room::openTheJail()
|
|||||||
{
|
{
|
||||||
if (name == "THE JAIL")
|
if (name == "THE JAIL")
|
||||||
{
|
{
|
||||||
|
// Cambia el color de fondo
|
||||||
|
bgColor = "red";
|
||||||
|
|
||||||
// Elimina el último enemigo (Bry debe ser el ultimo enemigo definido en el fichero)
|
// Elimina el último enemigo (Bry debe ser el ultimo enemigo definido en el fichero)
|
||||||
delete enemies.back();
|
delete enemies.back();
|
||||||
enemies.pop_back();
|
enemies.pop_back();
|
||||||
|
|||||||