117 Commits
v0.1 ... v0.7

Author SHA1 Message Date
1a78020ddd Subido el número de versión 2022-09-11 20:00:17 +02:00
ccb58c169c Añadida mas información al marcador 2022-09-11 19:59:09 +02:00
3eab857267 Sonidos de saltar, caer y morir 2022-09-11 18:20:08 +02:00
37daa9a8a0 Añadiendo efectos de sonido 2022-09-11 13:59:08 +02:00
abb38e490e Merge branch 'master' of https://gitea.sustancia.synology.me/JailDesigner/jaildoctors_dilemma 2022-09-11 11:42:10 +02:00
771ac32a3f Añadidos ficheros de sonido 2022-09-11 11:41:59 +02:00
61e62a625c cafe 2022-09-11 11:10:38 +02:00
cc68a02111 Corregido un bug en las colisiones. El rectangulo era un pixel demasiado bajo o estrecho 2022-09-10 21:04:42 +02:00
c905c348d5 Ya baja por las rampas 2022-09-10 19:18:56 +02:00
0b405e4f99 Solo sube las rampas desde el principio. Las atraviesa al saltar 2022-09-10 18:31:28 +02:00
edaa59af7d Ya sube las rampas. Aun queda por acabar 2022-09-10 18:26:24 +02:00
2ccb02258c Ya se detectan las rampas en el mapa 2022-09-09 19:02:36 +02:00
36fc848779 AHORA SI: Colisiones finalizadas 2022-09-09 14:01:49 +02:00
00b47a5910 Colisiones 2022-09-09 07:53:57 +02:00
197bf71c12 Las colisiones siguen fallando 2022-09-08 23:33:46 +02:00
98916cd1be Completadas las colisiones y estados 2022-09-08 21:31:51 +02:00
88d6471dc8 Trabajando en las colisiones y estados 2022-09-08 14:09:05 +02:00
9fc4c2d8b0 Ahora si, terminado el calculo de superficies 2022-09-08 10:22:52 +02:00
044cf97857 Terminado el cálculo de superficies 2022-09-07 22:47:22 +02:00
a73c11effa Haciendo las superficies verticales 2022-09-07 17:31:40 +02:00
2039b2f8db Creando las superficies del mapa 2022-09-07 14:00:02 +02:00
4193414f10 Antes de rehacer todo el engine de colisiones 2022-09-06 21:58:25 +02:00
247e0060ee Todavía falla MUCHO con las rampas 2022-09-06 21:25:41 +02:00
9af135100c Progresos con las rampas 2022-09-06 20:37:39 +02:00
066a9ab811 Trabajando con las rampas 2022-09-06 14:03:12 +02:00
189b933622 Añadida la clase debug 2022-09-06 13:26:12 +02:00
7e9daddbb6 Voy a implementar una clase para mostrar el informacion de debug en pantalla 2022-09-06 11:25:30 +02:00
16ae06a755 Solucion con checkUpSlopes y checkDownSlopes. No funciona 2022-09-06 11:06:09 +02:00
ce8a4a8050 Ya sube cuestas pero no las baja 2022-09-05 23:22:49 +02:00
b6cfe45872 Empezando a trabajar con slope-tiles 2022-09-05 18:55:36 +02:00
65eac860b1 Corregida la paleta de color zxspectrum 2022-09-05 17:02:17 +02:00
e50aa77514 Añadido color de borde para el logo, intro y titulo 2022-09-05 16:24:16 +02:00
014312732b Merge branch 'master' of https://gitea.sustancia.synology.me/JailDesigner/jaildoctors_dilemma 2022-09-05 16:13:50 +02:00
0e91809429 Cambiado el fichero de tiles con colores de zxspectrum 2022-09-05 16:13:44 +02:00
a121850adb Añadido el color del borde para cada habitación 2022-09-05 13:51:55 +02:00
87d7bd03ff Añadida la paleta de spectrum 2022-09-05 10:15:07 +02:00
73d394388b Terminadas las nuevas colisiones. Ya no se detiene al colisionar horizontalmente 2022-09-04 21:33:42 +02:00
796a31a099 Colisiones casi acabadas 2022-09-04 19:43:43 +02:00
1351943c79 Seguimos con las nuevas colisiones 2022-09-04 18:04:32 +02:00
8630a0ae56 Trabajando en las nuevas colisiones 2022-09-04 15:39:12 +02:00
5eaf44d0b8 Terminada la intro 2022-09-04 09:46:27 +02:00
eba04a32fb Ya colorea la intro 2022-09-04 00:03:44 +02:00
c46637092a Trabajando en la intro 2022-09-03 20:55:55 +02:00
62183d745a Corregido el texto de la marquesina 2022-09-03 18:28:26 +02:00
57c51676a4 Terminada la marquesina del titulo 2022-09-03 18:16:22 +02:00
1571b73c84 Añadida musica al titulo 2022-09-03 17:25:47 +02:00
3c26c98dd5 Trabajando en el titulo 2022-09-03 15:08:57 +02:00
643129b850 Actualizado Makefile 2022-09-03 14:36:53 +02:00
13fa289b42 Trabajando en el titulo 2022-09-03 14:33:16 +02:00
fce356e306 Empezando a trabajar en el titulo 2022-09-03 14:22:05 +02:00
d881220c7e Terminado (mas o menos) lo que quería hacer con el logo 2022-09-03 11:24:51 +02:00
9a9751bfdd Trabajando en el logo. Version con vector de completados 2022-09-03 10:17:02 +02:00
603aa4d653 Merge branch 'master' of https://gitea.sustancia.synology.me/JailDesigner/jaildoctors_dilemma 2022-09-03 07:40:26 +02:00
04d39c579a Empezando a trabajar en el logo 2022-09-03 07:40:11 +02:00
3e79bcb62d Pequeñas optimizaciones 2022-09-02 14:00:08 +02:00
a620d512c2 Añadida habitación sigmasua 2022-09-01 22:53:06 +02:00
3e94633f56 Quitados tres warnings 2022-09-01 21:22:13 +02:00
877b1e56e4 Modificado el todo.txt 2022-09-01 20:35:33 +02:00
31dea2aeea Añadido el procedimiento reLoadTexture a todos los objetos que lo necesitaban 2022-09-01 20:25:25 +02:00
4e219c47f6 Modificadas las llamadas para crear texturas 2022-09-01 19:49:03 +02:00
8f2e04b120 Modificada la clase LTexture 2022-09-01 19:30:56 +02:00
114da1e381 Renombradas variables en la clase text 2022-09-01 19:00:13 +02:00
203391da2d Eliminado el procedimiento loadTextureFromFile() de utils.h 2022-09-01 18:59:18 +02:00
4433cc6943 Invertido el separador del reloj 2022-09-01 13:14:15 +02:00
6a84d114e8 Implementado el temporizador del marcador 2022-09-01 12:50:17 +02:00
62e9a2ad2a Trabajando en el marcador 2022-08-31 22:40:22 +02:00
0087815ced Añadido el sonido de coger objetos 2022-08-31 20:59:52 +02:00
c18a13ec83 Añadida música 2022-08-31 19:51:00 +02:00
f1047a8b07 Trabajando en el marcador 2022-08-31 18:10:34 +02:00
c57fbf7bc3 Trabajando en el marcador 2022-08-31 13:56:17 +02:00
fff400be8f Probando stage changes 2022-08-30 22:53:16 +02:00
7b492b6942 Cambiado a todo.txt 2022-08-30 22:33:15 +02:00
1458658f4d Arreglado el nuevo bug que animaba a los enemigos dos veces 2022-08-30 21:57:01 +02:00
93febf3127 Los items ya brillan a distinto ritmo 2022-08-30 21:44:07 +02:00
38c41193ec Mejorada la información de debug 2022-08-30 20:35:53 +02:00
8616c3e165 Actualizada la clase screen con nuevos procedimientos 2022-08-30 17:31:33 +02:00
cbdc7d9fc3 Clase screen actualizada a la última versión 2022-08-30 16:45:26 +02:00
c5728d0849 Retocando las constantes 2022-08-30 14:01:44 +02:00
add7e5201a Sustituyendo todos los defines de const.h 2022-08-29 21:07:52 +02:00
0d27774c74 Eliminado el fichero const.h 2022-08-29 20:57:28 +02:00
75317a8b46 Modificada la fecha de inicio de programación en el codigo fuente 2022-08-29 20:16:21 +02:00
a1dad5d841 Actualizado jail_adudio y Menu 2022-08-29 20:11:46 +02:00
2af7b66a99 Borrado el fichero ifdefs.h 2022-08-29 20:06:50 +02:00
05311f7a00 Actualizada la clase asset 2022-08-29 20:04:53 +02:00
9c2140b274 Actualizadas las clases sprite, movingsprite y animatedsprite 2022-08-29 20:02:46 +02:00
47c57a9f44 Borradas clases que no se utilizaban 2022-08-29 18:29:39 +02:00
9a20d5fc1b Renombrado de variables 2022-08-29 18:16:14 +02:00
822386c269 Actualizada la clase Text 2022-08-29 17:47:06 +02:00
21c844a925 modificado director.h. El método init se ha hecho privado 2022-08-08 19:59:25 +02:00
04068466b1 modificados los archivos de tiled 2022-08-07 15:49:52 +02:00
446f130f3e cambios en los ficheros de las habitaciones 2022-08-07 15:42:03 +02:00
c0b24b9cc7 renombrats alguns fitxers de recursos 2022-08-07 15:18:32 +02:00
01d96ec1ce Arreglado un fallo en el salto al cambiar de pantalla hacia arriba 2022-07-14 19:17:31 +02:00
446dc9941f Añadidos nuevos tamaños para los enemigos 2022-07-14 18:09:06 +02:00
d95645e930 Creados tiles que matan 2022-07-14 16:37:58 +02:00
8f3fc5b52a Ya lleva la cuenta de los objetos recogidos 2022-07-14 11:03:35 +02:00
e752e90630 Añadida la clase item_tracker 2022-07-14 10:36:24 +02:00
6152dc4255 Ya se pueden pillar los items. Falta llevar el control de los iterms conseguidos 2022-07-12 19:33:09 +02:00
f8db0e3a90 Clase item creada. Ya dibuja items en pantalla 2022-07-12 18:39:00 +02:00
ae841a45ee Retocadas las clases Sprite e hijas 2022-07-12 17:32:12 +02:00
834d3a09a4 Rehaciendo las clases Sprite y sus hijas 2022-07-12 14:47:25 +02:00
6d7f8035bb Creación de nuevos tiles 2022-07-11 19:29:29 +02:00
8101c33526 Muerte y reaparición del jugador 2022-07-11 18:08:48 +02:00
4f6a99f670 Creadas las colisiones con los enemigos 2022-07-11 14:18:30 +02:00
4d41ef53f1 Ya realiza bien las colisiones con todos los tiles 2022-07-11 12:31:04 +02:00
38f95d9724 El salto ya hace el arco y luego cae 2022-07-11 10:52:20 +02:00
783689c368 Modificado el metodo de carga de habitaciones 2022-07-11 09:37:58 +02:00
6059a3b894 Arco de salto mejorado 2022-07-10 21:36:48 +02:00
8d49c78519 Ya funcionan los tiles atravesables 2022-07-10 21:10:45 +02:00
bade27edc4 Calibrando el salto. Aun no está perfeccionado del todo 2022-07-10 19:05:30 +02:00
64ebf24408 Ya no cambia de borde el jugador si tampoco puede cambiar de habitación 2022-07-10 18:51:59 +02:00
f931890e95 Ya realiza bien las colisiones en el salto 2022-07-10 18:49:26 +02:00
216fc1e19c Depurando los saltos con colisiones 2022-07-07 20:07:29 +02:00
9ecab3ea59 Trabajando en las colisiones con el mapeado 2022-07-07 17:44:22 +02:00
90bbe77f39 Colision con el suelo terminada 2022-07-06 21:04:45 +02:00
edba97cfc7 Preparandose para añadir gravedad y colisiones y pasarle el mapa al jugador 2022-07-06 09:10:11 +02:00
4243f89dc0 El jugador ya cambia de pantalla 2022-07-05 20:44:35 +02:00
139 changed files with 6490 additions and 3684 deletions

View File

@@ -1,5 +1,8 @@
executable = jaildoctors_dilemma
windows:
mkdir bin
g++ -std=c++11 -Wall -O2 -lSDL2 -lmingw32 -lSDL2main -mwindows source/*.cpp -o bin/$(executable).exe
macos:
mkdir -p bin
g++ -std=c++11 -Wall -O2 source/*.cpp -o bin/$(executable)_macos -lSDL2

View File

@@ -1,10 +0,0 @@
tileset=enemy01.png
x=8
y=8
vx=0.1
vy=0
x1=8
x2=200
y1=8
y2=8
color=red

View File

@@ -1,37 +1,102 @@
id=1
name=Test Room
bg_color=black
tileset=room1.png
room_up=0
room_down=0
room_left=0
room_right=02.room
tilemap=41,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,41,41,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,41,41,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,41,41,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,41,41,0,0,0,0,41,41,41,41,41,41,41,41,41,41,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,41,0,0,41,41,41,41,41,0,0,0,0,0,0,0,0,0,81,0,0,0,0,0,0,0,0,0,0,0,0,0,41,41,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,41,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,41,0,0,0,0,0,0,0,0,0,0,0,0,41,41,41,41,0,0,0,0,0,0,0,0,0,0,0,41,41,41,41,41,41,41,41,0,0,0,0,0,0,0,0,0,41,41,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,41,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,0,0,0,0,0,41,41,0,0,0,0,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,0,0,0,0,0,41,0,0,0,0,0,0,0,0,0,81,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,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41
name=void main
bgColor=black
border=red
tileset=standard.png
roomUp=0
roomDown=0
roomLeft=06.room
roomRight=02.room
[tilemap]
01.tmx
[/tilemap]
[enemy]
tileset=enemy01.png
x=8
tileset=diskette.png
animation=diskette.ani
width=16
height=16
x=1
y=0
vx=0
vy=0.3
x1=8
x2=8
x1=1
y1=0
y2=48
x2=1
y2=6
color=red
[enemy-end]
[/enemy]
[enemy]
tileset=enemy01.png
x=40
y=72
vx=0.3
tileset=diskette.png
animation=diskette.ani
width=16
height=16
x=5
y=9
vx=0.6
vy=0
x1=40
x2=184
y1=72
y2=72
x1=5
y1=9
x2=22
y2=9
color=yellow
[enemy-end]
[/enemy]
item=1,10,10
[item]
tileset=items.png
tile=1
x=1
y=7
counter=6
[/item]
[item]
tileset=items.png
tile=1
x=17
y=8
counter=7
[/item]
[item]
tileset=items.png
tile=1
x=12
y=12
counter=1
[/item]
[item]
tileset=items.png
tile=1
x=13
y=12
counter=2
[/item]
[item]
tileset=items.png
tile=1
x=14
y=12
counter=3
[/item]
[item]
tileset=items.png
tile=1
x=15
y=12
counter=4
[/item]
[item]
tileset=items.png
tile=1
x=16
y=12
counter=5
[/item]

24
data/room/01.tmx Normal file
View File

@@ -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">
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,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,21,21,21,21,21,21,21,21,21,21,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
21,0,0,21,21,21,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,
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,21,21,0,0,0,0,0,0,0,0,0,0,0,0,0,
21,21,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,21,21,21,21,0,0,0,0,0,21,21,21,21,21,
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,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,
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,
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
</data>
</layer>
</map>

View File

@@ -1,12 +1,35 @@
id=2
name=Test Room 2
bg_color=black
tileset=room1.png
room_up=0
room_down=0
room_left=01.room
room_right=0
tilemap=43,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,43,43,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,43,43,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,43,43,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,43,43,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,43,43,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,43,43,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,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,43,43,43,43,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,43,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,43,0,0,0,0,0,0,0,83,83,83,83,83,83,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,83,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63
enemy=1,0,0,0,1
enemy=2,10,0,0,1
item=1,10,10
name=case switch
bgColor=black
border=green
tileset=standard.png
roomUp=0
roomDown=04.room
roomLeft=01.room
roomRight=03.room
[tilemap]
02.tmx
[/tilemap]
[enemy]
tileset=paco.png
animation=paco.ani
width=16
height=16
x=14
y=0
vx=0
vy=1
x1=14
y1=0
x2=14
y2=12
color=magenta
[/enemy]
[item]
tileset=items.png
tile=1
x=19
y=6
[/item]

24
data/room/02.tmx Normal file
View File

@@ -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">
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,24,
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,24,
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,24,
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,24,
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,24,
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,24,
0,0,0,0,0,0,0,0,0,0,0,203,203,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,24,24,24,24,0,0,0,0,0,0,0,0,0,24,
24,24,24,24,24,24,0,0,0,203,0,0,0,0,0,0,0,0,0,24,0,0,0,0,203,203,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,24,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,203,0,0,0,0,0,0,0,0,0,24,0,0,0,0,203,203,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,24,0,0,0,0,0,0,0,0,0,203,203,24,
0,0,0,0,0,0,0,203,203,203,203,203,203,0,0,0,0,0,0,24,0,0,0,0,203,203,0,0,0,0,0,24,
0,0,0,0,0,203,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,24,
44,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,84,84,84,84,84,84,84,84,84,84,84,84,
44,44,44,44,44,44,44,44,44,44,44,44,44,44,223,0,0,223,44,44,44,44,44,44,44,44,44,44,44,44,44,44
</data>
</layer>
</map>

67
data/room/03.room Normal file
View File

@@ -0,0 +1,67 @@
name=the edge
bgColor=bright_black
border=black
tileset=standard.png
roomUp=0
roomDown=05.room
roomLeft=02.room
roomRight=0
[tilemap]
03.tmx
[/tilemap]
[enemy]
tileset=chip.png
animation=chip.ani
width=8
height=16
x=4
y=5
vx=0
vy=1
x1=4
y1=2
x2=4
y2=13
color=green
[/enemy]
[enemy]
tileset=chip.png
animation=chip.ani
width=8
height=16
x=10
y=4
vx=0
vy=1
x1=10
y1=2
x2=10
y2=13
color=bright_blue
[/enemy]
[enemy]
tileset=chip.png
animation=chip.ani
width=8
height=16
x=16
y=3
vx=0
vy=1
x1=16
y1=2
x2=16
y2=13
color=magenta
[/enemy]
[item]
tileset=items.png
tile=5
x=12
y=2
[/item]

24
data/room/03.tmx Normal file
View File

@@ -0,0 +1,24 @@
<?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">
<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,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,
26,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,
26,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,
26,0,0,0,0,0,0,0,0,0,0,0,271,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
26,0,0,0,0,0,0,0,0,271,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
26,0,0,0,0,0,271,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,
26,0,0,271,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,
26,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,271,271,271,271,271,271,271,271,271,271,271,271,271,271,271,271,271,271,0,232,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,232,0,0,0,0,0,0,0,0,0,
26,26,26,0,0,0,26,26,26,0,0,0,26,26,26,0,0,0,26,26,26,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
</map>

82
data/room/04.room Normal file
View File

@@ -0,0 +1,82 @@
name=The Fridge
bgColor=blue
border=blue
tileset=standard.png
roomUp=02.room
roomDown=0
roomLeft=0
roomRight=05.room
[tilemap]
04.tmx
[/tilemap]
[enemy]
tileset=chip.png
animation=chip.ani
width=8
height=16
x=1
y=3
vx=1
vy=0
x1=1
y1=3
x2=14
y2=3
color=magenta
[/enemy]
[enemy]
tileset=chip.png
animation=chip.ani
width=8
height=16
x=30
y=7
vx=-0.8
vy=0
x1=10
y1=7
x2=30
y2=7
color=bright_white
[/enemy]
[enemy]
tileset=wave.png
animation=wave.ani
width=8
height=8
x=15
y=12
vx=0.5
vy=0
x1=15
y1=12
x2=30
y2=12
color=bright_magenta
[/enemy]
[item]
tileset=items.png
tile=6
x=2
y=2
[/item]
[item]
tileset=items.png
tile=6
x=29
y=5
[/item]
[item]
tileset=items.png
tile=6
x=21
y=12
[/item]

24
data/room/04.tmx Normal file
View File

@@ -0,0 +1,24 @@
<?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">
<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">
25,249,249,249,249,249,249,249,249,249,249,249,249,249,0,0,0,0,249,249,249,249,249,249,249,249,249,249,249,249,249,25,
25,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,25,
25,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,25,
25,0,0,0,0,0,0,0,0,0,0,0,0,0,230,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,
25,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,25,
25,25,25,25,0,25,25,25,25,25,0,25,25,25,25,0,0,230,0,0,0,0,0,0,0,0,0,0,0,0,0,25,
25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,270,270,270,270,270,270,270,0,0,270,0,25,
25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,290,0,0,0,0,0,0,0,25,
25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,290,0,0,0,0,0,0,0,25,
25,0,0,0,0,0,0,0,0,0,0,25,25,25,25,0,0,25,25,25,25,25,25,25,0,0,0,0,0,0,0,25,
25,0,0,0,0,229,229,229,229,229,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,
25,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,25,
25,249,249,249,249,249,249,249,249,249,249,249,249,249,249,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,
22,0,0,0,0,0,289,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,
22,0,0,0,0,0,289,0,0,0,0,0,0,0,0,0,0,0,381,0,0,0,0,0,0,381,0,0,0,0,0,0,
25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25
</data>
</layer>
</map>

108
data/room/05.room Normal file
View File

@@ -0,0 +1,108 @@
name=sigmasua
bgColor=black
border=blue
tileset=standard.png
roomUp=03.room
roomDown=0
roomLeft=04.room
roomRight=0
[tilemap]
05.tmx
[/tilemap]
[enemy]
tileset=sigmasua.png
animation=sigmasua.ani
width=16
height=16
x=15
y=7
vx=0.8
vy=0
x1=9
y1=7
x2=25
y2=7
color=red
[/enemy]
[enemy]
tileset=sigmasua.png
animation=sigmasua.ani
width=16
height=16
x=3
y=8
vx=0
vy=0.4
x1=3
y1=5
x2=3
y2=12
color=red
[/enemy]
[enemy]
tileset=sigmasua.png
animation=sigmasua.ani
width=16
height=16
x=10
y=10
vx=0
vy=0.3
x1=10
y1=10
x2=10
y2=13
color=bright_red
[/enemy]
[enemy]
tileset=sigmasua.png
animation=sigmasua.ani
width=16
height=16
x=23
y=13
vx=0
vy=-0.3
x1=23
y1=10
x2=23
y2=13
color=bright_red
[/enemy]
[item]
tileset=items.png
tile=9
counter=1
x=21
y=3
[/item]
[item]
tileset=items.png
tile=9
counter=2
x=1
y=8
[/item]
[item]
tileset=items.png
tile=9
counter=3
x=26
y=14
[/item]
[item]
tileset=items.png
tile=9
counter=4
x=18
y=5
[/item]

24
data/room/05.tmx Normal file
View File

@@ -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">
62,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,
62,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,
62,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,
62,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,
62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,0,0,68,0,0,68,0,0,0,0,0,0,0,
62,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,
62,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,
62,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,
62,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,
62,222,0,0,0,0,0,222,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,222,0,0,0,
62,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,68,0,0,0,0,
62,0,0,0,0,0,0,222,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,222,0,0,0,
62,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,68,0,0,0,0,
0,0,0,0,0,0,0,222,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,222,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,68,0,0,0,0,
68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68
</data>
</layer>
</map>

12
data/room/06.room Normal file
View File

@@ -0,0 +1,12 @@
name=the test room
bgColor=black
border=blue
tileset=standard.png
roomUp=0
roomDown=0
roomLeft=0
roomRight=01.room
[tilemap]
06.tmx
[/tilemap]

24
data/room/06.tmx Normal file
View File

@@ -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,86,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,86,86,86,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,86,0,86,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,86,0,86,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,62,62,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,0,0,0,0,0,62,62,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,0,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,0,0,0,0,22,22,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,0,0,0,0,0,0,0,0,0,
26,0,0,0,0,161,0,0,0,0,0,0,0,0,0,0,81,289,81,0,0,0,0,0,0,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>

10
media/enemies/chip.ani Normal file
View File

@@ -0,0 +1,10 @@
frames_per_row=4
frame_width=8
frame_height=16
[animation]
name=default
speed=8
loop=0
frames=0,1,2,3
[/animation]

BIN
media/enemies/chip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

View File

@@ -0,0 +1,10 @@
frames_per_row=4
frame_width=16
frame_height=16
[animation]
name=default
speed=8
loop=0
frames=0,1,2,3
[/animation]

BIN
media/enemies/diskette.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

10
media/enemies/paco.ani Normal file
View File

@@ -0,0 +1,10 @@
frames_per_row=4
frame_width=16
frame_height=16
[animation]
name=default
speed=8
loop=0
frames=0,1,2,3
[/animation]

View File

Before

Width:  |  Height:  |  Size: 239 B

After

Width:  |  Height:  |  Size: 239 B

View File

@@ -0,0 +1,10 @@
frames_per_row=4
frame_width=16
frame_height=16
[animation]
name=default
speed=8
loop=0
frames=0,1,2,3
[/animation]

BIN
media/enemies/sigmasua.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

10
media/enemies/wave.ani Normal file
View File

@@ -0,0 +1,10 @@
frames_per_row=4
frame_width=8
frame_height=8
[animation]
name=default
speed=8
loop=0
frames=0,1,2,3
[/animation]

BIN
media/enemies/wave.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

BIN
media/font/debug.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

View File

@@ -1,194 +1,194 @@
# box width
8
# box height
8
# 32 espacio ( )
2
# 33 !
2
# 34 "
5
# box height
5
# 32 espacio ( )
3
# 33 !
1
# 34 "
3
# 35 #
6
3
# 36 $
6
3
# 37 %
6
3
# 38 &
6
3
# 39 '
2
1
# 40 (
3
2
# 41 )
3
2
# 42 *
4
3
# 43 +
3
# 44 ,
2
1
# 45 -
3
# 46 .
2
1
# 47 /
4
3
# 48 0
6
3
# 49 1
6
3
# 50 2
6
3
# 51 3
6
3
# 52 4
6
3
# 53 5
6
3
# 54 6
6
3
# 55 7
6
3
# 56 8
6
3
# 57 9
6
3
# 58 :
2
1
# 59 ;
2
1
# 60 <
4
3
# 61 =
3
# 62 >
4
3
# 63 ?
6
3
# 64 @
8
3
# 65 A
6
3
# 66 B
6
3
# 67 C
6
3
# 68 D
6
3
# 69 E
6
3
# 70 F
6
3
# 71 G
6
3
# 72 H
6
3
# 73 I
6
3
# 74 J
6
3
# 75 K
6
3
# 76 L
6
3
# 77 M
6
3
# 78 N
6
3
# 79 O
6
3
# 80 P
6
3
# 81 Q
6
3
# 82 R
6
3
# 83 S
6
3
# 84 T
6
3
# 85 U
6
3
# 86 V
5
3
# 87 W
6
3
# 88 X
6
3
# 89 Y
6
3
# 90 Z
6
3
# 91 [
3
2
# 92 \
5
# 93 ]
3
# 93 ]
2
# 94 ^
4
3
# 95 _
6
3
# 96 `
2
# 97 a
5
3
# 98 b
5
3
# 99 c
5
3
# 100 d
5
3
# 101 e
5
3
# 102 f
5
3
# 103 g
5
3
# 104 h
5
3
# 105 i
4
3
# 106 j
5
3
# 107 k
5
3
# 108 l
5
3
# 109 m
6
3
# 110 n
5
3
# 111 o
5
3
# 112 p
5
3
# 113 q
5
3
# 114 r
5
3
# 115 s
5
3
# 116 t
4
3
# 117 u
5
3
# 118 v
5
3
# 119 w
6
3
# 120 x
4
3
# 121 y
4
3
# 122 z
5
3
# 123 {
3
# 124 |
2
3
# 125 }
3
# 126 ~
3
5

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -1,194 +0,0 @@
# box width
10
# box height
10
# 32 espacio ( )
5
# 33 !
4
# 34 "
5
# 35 #
7
# 36 $
7
# 37 %
8
# 38 &
8
# 39 '
3
# 40 (
5
# 41 )
5
# 42 *
7
# 43 +
7
# 44 ,
4
# 45 -
6
# 46 .
4
# 47 /
5
# 48 0
7
# 49 1
5
# 50 2
7
# 51 3
7
# 52 4
7
# 53 5
7
# 54 6
7
# 55 7
7
# 56 8
7
# 57 9
7
# 58 :
4
# 59 ;
4
# 60 <
6
# 61 =
6
# 62 >
6
# 63 ?
7
# 64 @
8
# 65 A
7
# 66 B
7
# 67 C
7
# 68 D
7
# 69 E
7
# 70 F
7
# 71 G
7
# 72 H
7
# 73 I
4
# 74 J
6
# 75 K
8
# 76 L
6
# 77 M
9
# 78 N
8
# 79 O
8
# 80 P
7
# 81 Q
8
# 82 R
7
# 83 S
6
# 84 T
8
# 85 U
7
# 86 V
8
# 87 W
9
# 88 X
8
# 89 Y
8
# 90 Z
7
# 91 [
4
# 92 \
5
# 93 ]
4
# 94 ^
5
# 95 _
8
# 96 `
4
# 97 a
7
# 98 b
7
# 99 c
6
# 100 d
7
# 101 e
7
# 102 f
5
# 103 g
7
# 104 h
7
# 105 i
4
# 106 j
5
# 107 k
7
# 108 l
4
# 109 m
10
# 110 n
7
# 111 o
7
# 112 p
7
# 113 q
7
# 114 r
6
# 115 s
6
# 116 t
5
# 117 u
7
# 118 v
7
# 119 w
9
# 120 x
7
# 121 y
7
# 122 z
7
# 123 { -> ñ
7
# 124 | -> ç
7
# 125 }
0
# 126 ~
0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -1,194 +0,0 @@
# box width
10
# box height
10
# 32 espacio ( )
5
# 33 !
4
# 34 "
5
# 35 #
7
# 36 $
7
# 37 %
8
# 38 &
8
# 39 '
3
# 40 (
5
# 41 )
5
# 42 *
7
# 43 +
7
# 44 ,
4
# 45 -
6
# 46 .
4
# 47 /
5
# 48 0
7
# 49 1
5
# 50 2
7
# 51 3
7
# 52 4
7
# 53 5
7
# 54 6
7
# 55 7
7
# 56 8
7
# 57 9
7
# 58 :
4
# 59 ;
4
# 60 <
6
# 61 =
6
# 62 >
6
# 63 ?
7
# 64 @
8
# 65 A
7
# 66 B
7
# 67 C
7
# 68 D
7
# 69 E
7
# 70 F
7
# 71 G
7
# 72 H
7
# 73 I
4
# 74 J
6
# 75 K
8
# 76 L
6
# 77 M
9
# 78 N
8
# 79 O
8
# 80 P
7
# 81 Q
8
# 82 R
7
# 83 S
6
# 84 T
8
# 85 U
7
# 86 V
8
# 87 W
9
# 88 X
8
# 89 Y
8
# 90 Z
7
# 91 [
4
# 92 \
5
# 93 ]
4
# 94 ^
5
# 95 _
8
# 96 `
4
# 97 a
7
# 98 b
7
# 99 c
6
# 100 d
7
# 101 e
7
# 102 f
5
# 103 g
7
# 104 h
7
# 105 i
4
# 106 j
5
# 107 k
7
# 108 l
4
# 109 m
10
# 110 n
7
# 111 o
7
# 112 p
7
# 113 q
7
# 114 r
6
# 115 s
6
# 116 t
5
# 117 u
7
# 118 v
7
# 119 w
9
# 120 x
7
# 121 y
7
# 122 z
7
# 123 { -> ñ
7
# 124 | -> ç
7
# 125 }
0
# 126 ~
0

BIN
media/items/items.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

View File

@@ -1,158 +0,0 @@
## 0 - MENU DEL TITULO
JUGAR
## 1 - MENU DEL TITULO
OPCIONS
## 2 - MENU DEL TITULO
INSTRUCCIONS
## 3 - MENU DEL TITULO
EIXIR
## 4 - MENU DE OPCIONES
FINESTRA
## 5 - MENU DE OPCIONES
PANTALLA COMPLETA
## 6 - MENU DE OPCIONES
PANTALLA COMPLETA FALSA
## 7 - MENU DE OPCIONES
TAMANY DE FINESTRA
## 8 - MENU DE OPCIONES
IDIOMA
## 9 - MENU DE OPCIONES
[ ACEPTAR ]
## 10 - MENU DE OPCIONES
[ CANCELAR ]
## 11 - INSTRUCCIONES
OBJECTIU
## 12 - INSTRUCCIONES
HAS D'EXPLOTAR
## 13 - INSTRUCCIONES
TANTS GLOBUS COM PUGUES
## 14 - INSTRUCCIONES
LA DIFICULTAT AUGMENTA
## 15 - INSTRUCCIONES
A MESURA QUE VAS PUNTUANT
## 16 - INSTRUCCIONES
OBJECTES
## 17 - INSTRUCCIONES
1.000 PUNTS
## 18 - INSTRUCCIONES
2.500 PUNTS
## 19 - INSTRUCCIONES
5.000 PUNTS
## 20 - INSTRUCCIONES
PARA EL TEMPS
## 21 - INSTRUCCIONES
VIDA EXTRA
## 22 - INSTRUCCIONES
PREM UNA TECLA PER A TORNAR
## 23 - TITULO
PREM QUALSEVOL TECLA
## 24 - MENU SELECCION DE IDIOMA
ESPA{OL (ESPANYOL)
## 25 - MENU SELECCION DE IDIOMA
BALOONCIA
## 26 - MENU SELECCION DE IDIOMA
ENGLISH (ANGLES)
## 27 - INTRO
Un dia qualsevol de l'any 2000
## 28 - INTRO
Tot esta tranquil a la UPV
## 29 - INTRO
Fins que un desaprensiu...
## 30 - INTRO
HEY! ME ANE A FERME UN CORTAET...
## 31 - INTRO
UAAAAAAAAAAAAA!!!
## 32 - INTRO
Espera un moment...
## 33 - INTRO
Si resulta que no tinc solt!
## 34 - INTRO
MERDA DE MAQUINA!
## 35 - INTRO
Blop... blop... blop...
## 36 - TEXTOS DEL JUEGO
Temps detes:
## 37 - TEXTOS DEL JUEGO
D E M O
## 38 - TEXTOS DEL JUEGO
Pantalla
## 39 - MARCADOR
PUNTS
## 40 - MARCADOR
MAX.PUNT.
## 41 - MARCADOR
MULT
## 42 - MARCADOR
PANTALLA
## 43 - PANTALLA DE GAME OVER
FI DEL JOC
## 44 - PANTALLA DE GAME OVER
ELS TEUS PUNTS:
## 45 - PANTALLA DE GAME OVER
REINTENTAR?
## 46 - MENU DE PAUSA
CONTINUAR
## 47 - MENU DE PAUSA
EIXIR DEL JOC
## 48 - MENU GAME OVER
SI
## 49 - MENU GAME OVER
NO
## 50 - TEXTO DE COMPLETAR EL JUEGO
Felicitats!!
## 51 - MENU DEL TITULO
1 JUGADOR
## 52 - MENU DEL TITULO
2 JUGADORS
## 53 MARCADOR
jugador 1
## 54 MARCADOR
jugador 2
## 55 MARCADOR
mult
## 56 MARCADOR
max. puntuacio
## 57 MARCADOR
pantalla
## 58 - MENU DE OPCIONES
MODE DE VISUALITZACIO
## 59 - MENU DE OPCIONES
DIFICULTAT
## 60 - MENU DE OPCIONES
FILTRE
## 61 - MENU DE OPCIONES
SINC. VERTICAL
## 62 - MENU DE OPCIONES
CONTROLS DEL JUGADOR 1
## 63 - MENU DE OPCIONES
CONTROLS DEL JUGADOR 2
## 64 - MENU DE OPCIONES
TECLAT
## 65 - MENU DE OPCIONES
MANDO
## 66 - MENU DE OPCIONES
FACIL
## 67 - MENU DE OPCIONES
NORMAL
## 68 - MENU DE OPCIONES
DIFICIL
## 69 - MENU DE OPCIONES
TECLAT
## 70 - MENU DE OPCIONES
MANDO
## 71 - MENU DE OPCIONES
LINEAL
## 72 - MENU DE OPCIONES
NEAREST
## 73 - MENU DE OPCIONES
ACTIVADA
## 74 - MENU DE OPCIONES
DESACTIVADA
## 75 - JUEGO
Endavant!
## 76 - JUEGO
1.000.000 de punts!
## 77 - PANTALLA DE GAME OVER
PUNTS J1:
## 78 - PANTALLA DE GAME OVER
PUNTS J2:

View File

@@ -1,158 +0,0 @@
## 0 - MENU DEL TITULO
PLAY
## 1 - MENU DEL TITULO
OPTIONS
## 2 - MENU DEL TITULO
HOW TO PLAY
## 3 - MENU DEL TITULO
QUIT
## 4 - MENU DE OPCIONES
WINDOW
## 5 - MENU DE OPCIONES
FULLSCREEN
## 6 - MENU DE OPCIONES
FAKE FULLSCREEN
## 7 - MENU DE OPCIONES
WINDOW SIZE
## 8 - MENU DE OPCIONES
LANGUAGE
## 9 - MENU DE OPCIONES
[ ACCEPT ]
## 10 - MENU DE OPCIONES
[ CANCEL ]
## 11 - INSTRUCCIONES
OBJECTIVE
## 12 - INSTRUCCIONES
YOU HAVE TO POP AS MANY
## 13 - INSTRUCCIONES
BALLOONS AS YOU CAN
## 14 - INSTRUCCIONES
DIFFICULTY WILL BE INCREASED
## 15 - INSTRUCCIONES
AS YOU SCORE POINTS
## 16 - INSTRUCCIONES
ITEMS
## 17 - INSTRUCCIONES
1.000 POINTS
## 18 - INSTRUCCIONES
2.500 POINTS
## 19 - INSTRUCCIONES
5.000 POINTS
## 20 - INSTRUCCIONES
TIME STOPPER
## 21 - INSTRUCCIONES
EXTRA HIT
## 22 - INSTRUCCIONES
PRESS ANY KEY TO RETURN
## 23 - TITULO
PRESS ANY KEY
## 24 - MENU SELECCION DE IDIOMA
ESPA{OL (SPANISH)
## 25 - MENU SELECCION DE IDIOMA
BALOONCIA (VALENCIAN)
## 26 - MENU SELECCION DE IDIOMA
ENGLISH
## 27 - INTRO
Any day of the year 2000
## 28 - INTRO
Everything is quiet at the UPV
## 29 - INTRO
Until a bastard arrives...
## 30 - INTRO
YO! GONNA TAKE A CAFELITO...
## 31 - INTRO
AAAAAAAARGHHHH!!!
## 32 - INTRO
Wait a moment...
## 33 - INTRO
I don't have any loose!
## 34 - INTRO
FUCKING MACHINE!
## 35 - INTRO
Blop... blop... blop...
## 36 - TEXTOS DEL JUEGO
Time stopped:
## 37 - TEXTOS DEL JUEGO
D E M O
## 38 - TEXTOS DEL JUEGO
Stage
## 39 - MARCADOR
SCORE
## 40 - MARCADOR
HI-SCORE
## 41 - MARCADOR
MULT
## 42 - MARCADOR
STAGE
## 43 - PANTALLA DE GAME OVER
GAME OVER
## 44 - PANTALLA DE GAME OVER
YOUR SCORE:
## 45 - PANTALLA DE GAME OVER
RETRY?
## 46 - MENU DE PAUSA
CONTINUE
## 47 - MENU DE PAUSA
LEAVE GAME
## 48 - MENU GAME OVER
YES
## 49 - MENU GAME OVER
NO
## 50 - TEXTO DE COMPLETAR EL JUEGO
Congratulations!!
## 51 - MENU DEL TITULO
1 PLAYER
## 52 - MENU DEL TITULO
2 PLAYERS
## 53 - MARCADOR
player 1
## 54 - MARCADOR
player 2
## 55 - MARCADOR
mult
## 56 - MARCADOR
high score
## 57 - MARCADOR
stage
## 58 - MENU DE OPCIONES
DISPLAY MODE
## 59 - MENU DE OPCIONES
DIFFICULTY
## 60 - MENU DE OPCIONES
FILTER
## 61 - MENU DE OPCIONES
VSYNC
## 62 - MENU DE OPCIONES
PLAYER 1 CONTROLS
## 63 - MENU DE OPCIONES
PLAYER 2 CONTROLS
## 64 - MENU DE OPCIONES
KEYBOARD
## 65 - MENU DE OPCIONES
GAME CONTROLLER
## 66 - MENU DE OPCIONES
EASY
## 67 - MENU DE OPCIONES
NORMAL
## 68 - MENU DE OPCIONES
HARD
## 69 - MENU DE OPCIONES
KEYBOARD
## 70 - MENU DE OPCIONES
GAME CONTROLLER
## 71 - MENU DE OPCIONES
LINEAL
## 72 - MENU DE OPCIONES
NEAREST
## 73 - MENU DE OPCIONES
ON
## 74 - MENU DE OPCIONES
OFF
## 75 - JUEGO
Get Ready!
## 76 - JUEGO
1.000.000 points!
## 77 - PANTALLA DE GAME OVER
PLAYER1 SCORE:
## 78 - PANTALLA DE GAME OVER
PLAYER2 SCORE:

View File

@@ -1,158 +0,0 @@
## 0 - MENU DEL TITULO
JUGAR
## 1 - MENU DEL TITULO
OPCIONES
## 2 - MENU DEL TITULO
INSTRUCCIONES
## 3 - MENU DEL TITULO
SALIR
## 4 - MENU DE OPCIONES
VENTANA
## 5 - MENU DE OPCIONES
PANTALLA COMPLETA
## 6 - MENU DE OPCIONES
PANTALLA COMPLETA FALSA
## 7 - MENU DE OPCIONES
TAMA{O DE VENTANA
## 8 - MENU DE OPCIONES
IDIOMA
## 9 - MENU DE OPCIONES
[ ACEPTAR ]
## 10 - MENU DE OPCIONES
[ CANCELAR ]
## 11 - INSTRUCCIONES
OBJETIVO
## 12 - INSTRUCCIONES
TIENES QUE EXPLOTAR
## 13 - INSTRUCCIONES
TANTOS GLOBOS COMO PUEDAS
## 14 - INSTRUCCIONES
LA DIFICULTAD SE INCREMENTA
## 15 - INSTRUCCIONES
A MEDIDA QUE VAS PUNTUANDO
## 16 - INSTRUCCIONES
OBJETOS
## 17 - INSTRUCCIONES
1.000 PUNTOS
## 18 - INSTRUCCIONES
2.500 PUNTOS
## 19 - INSTRUCCIONES
5.000 PUNTOS
## 20 - INSTRUCCIONES
DETIENE EL TIEMPO
## 21 - INSTRUCCIONES
VIDA EXTRA
## 22 - INSTRUCCIONES
PULSA UNA TECLA PARA VOLVER
## 23 - TITULO
PULSA CUALQUIER TECLA
## 24 - MENU SELECCION DE IDIOMA
ESPA{OL
## 25 - MENU SELECCION DE IDIOMA
BALOONCIA (VALENCIANO)
## 26 - MENU SELECCION DE IDIOMA
ENGLISH (INGLES)
## 27 - INTRO
Un dia cualquiera del a{o 2000
## 28 - INTRO
Todo esta tranquilo en la UPV
## 29 - INTRO
Hasta que un desaprensivo...
## 30 - INTRO
HEY! VOY A SACARME UN TALLADET...
## 31 - INTRO
UAAAAAAAAAAAAA!!!
## 32 - INTRO
Espera un momento...
## 33 - INTRO
Si no llevo suelto encima!
## 34 - INTRO
MIERDA DE MAQUINA!
## 35 - INTRO
Blop... blop... blop...
## 36 - TEXTOS DEL JUEGO
Tiempo:
## 37 - TEXTOS DEL JUEGO
D E M O
## 38 - TEXTOS DEL JUEGO
Fase
## 39 - MARCADOR
PUNTOS
## 40 - MARCADOR
MAX.PUNT.
## 41 - MARCADOR
MULT
## 42 - MARCADOR
FASE
## 43 - PANTALLA DE GAME OVER
FIN DE JUEGO
## 44 - PANTALLA DE GAME OVER
TU PUNTUACION:
## 45 - PANTALLA DE GAME OVER
REINTENTAR?
## 46 - MENU DE PAUSA
CONTINUAR
## 47 - MENU DE PAUSA
SALIR DEL JUEGO
## 48 - MENU GAME OVER
SI
## 49 - MENU GAME OVER
NO
## 50 - TEXTO DE COMPLETAR EL JUEGO
Felicidades!!
## 51 - MENU DEL TITULO
1 JUGADOR
## 52 - MENU DEL TITULO
2 JUGADORES
## 53 - MARCADOR
jugador 1
## 54 - MARCADOR
jugador 2
## 55 - MARCADOR
mult
## 56 - MARCADOR
max. puntuacion
## 57 - MARCADOR
fase
## 58 - MENU DE OPCIONES
MODO DE VISUALIZACION
## 59 - MENU DE OPCIONES
DIFICULTAD
## 60 - MENU DE OPCIONES
FILTRO
## 61 - MENU DE OPCIONES
SINC. VERTICAL
## 62 - MENU DE OPCIONES
CONTROLES DEL JUGADOR 1
## 63 - MENU DE OPCIONES
CONTROLES DEL JUGADOR 2
## 64 - MENU DE OPCIONES
TECLADO
## 65 - MENU DE OPCIONES
MANDO
## 66 - MENU DE OPCIONES
FACIL
## 67 - MENU DE OPCIONES
NORMAL
## 68 - MENU DE OPCIONES
DIFICIL
## 69 - MENU DE OPCIONES
TECLADO
## 70 - MENU DE OPCIONES
MANDO
## 71 - MENU DE OPCIONES
LINEAL
## 72 - MENU DE OPCIONES
NEAREST
## 73 - MENU DE OPCIONES
ACTIVADA
## 74 - MENU DE OPCIONES
DESACTIVADA
## 75 - JUEGO
Adelante!
## 76 - JUEGO
1.000.000 de puntos!
## 77 - PANTALLA DE GAME OVER
PUNTUACION J1:
## 78 - PANTALLA DE GAME OVER
PUNTUACION J2:

BIN
media/logo/jailgames.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

BIN
media/logo/seagull.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

BIN
media/logo/since_1998.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

BIN
media/music/game.ogg Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
media/music/title.ogg Normal file

Binary file not shown.

24
media/player/player.ani Normal file
View File

@@ -0,0 +1,24 @@
frames_per_row=4
frame_width=8
frame_height=16
[animation]
name=stand
speed=8
loop=0
frames=0
[/animation]
[animation]
name=walk
speed=8
loop=0
frames=0,1,2,3
[/animation]
[animation]
name=walk_menu
speed=0
loop=0
frames=0,1,2,3
[/animation]

BIN
media/player/player.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

24
media/player/player2.ani Normal file
View File

@@ -0,0 +1,24 @@
frames_per_row=8
frame_width=8
frame_height=16
[animation]
name=stand
speed=8
loop=0
frames=0
[/animation]
[animation]
name=walk
speed=8
loop=0
frames=0,1,2,3,4,5,6,7
[/animation]
[animation]
name=walk_menu
speed=0
loop=0
frames=0,1,2,3,4,5,6,7
[/animation]

BIN
media/player/player2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

BIN
media/sound/death.wav Normal file

Binary file not shown.

BIN
media/sound/item.wav Normal file

Binary file not shown.

BIN
media/sound/jump1.wav Normal file

Binary file not shown.

BIN
media/sound/jump10.wav Normal file

Binary file not shown.

BIN
media/sound/jump11.wav Normal file

Binary file not shown.

BIN
media/sound/jump12.wav Normal file

Binary file not shown.

BIN
media/sound/jump13.wav Normal file

Binary file not shown.

BIN
media/sound/jump14.wav Normal file

Binary file not shown.

BIN
media/sound/jump15.wav Normal file

Binary file not shown.

BIN
media/sound/jump16.wav Normal file

Binary file not shown.

BIN
media/sound/jump17.wav Normal file

Binary file not shown.

BIN
media/sound/jump18.wav Normal file

Binary file not shown.

BIN
media/sound/jump19.wav Normal file

Binary file not shown.

BIN
media/sound/jump2.wav Normal file

Binary file not shown.

BIN
media/sound/jump20.wav Normal file

Binary file not shown.

BIN
media/sound/jump21.wav Normal file

Binary file not shown.

BIN
media/sound/jump22.wav Normal file

Binary file not shown.

BIN
media/sound/jump23.wav Normal file

Binary file not shown.

BIN
media/sound/jump24.wav Normal file

Binary file not shown.

BIN
media/sound/jump3.wav Normal file

Binary file not shown.

BIN
media/sound/jump4.wav Normal file

Binary file not shown.

BIN
media/sound/jump5.wav Normal file

Binary file not shown.

BIN
media/sound/jump6.wav Normal file

Binary file not shown.

BIN
media/sound/jump7.wav Normal file

Binary file not shown.

BIN
media/sound/jump8.wav Normal file

Binary file not shown.

BIN
media/sound/jump9.wav Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 583 B

BIN
media/tilesets/standard.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@@ -1,121 +1,278 @@
#include "const.h"
#include "animatedsprite.h"
// Constructor
AnimatedSprite::AnimatedSprite(LTexture *texture, SDL_Renderer *renderer)
AnimatedSprite::AnimatedSprite(LTexture *texture, SDL_Renderer *renderer, std::string file)
{
mRenderer = renderer;
mTexture = texture;
// Copia los punteros
setTexture(texture);
setRenderer(renderer);
// Carga las animaciones
load(file);
// Inicializa variables
currentAnimation = 0;
}
// Destructor
AnimatedSprite::~AnimatedSprite()
{
for (auto &a : animation)
{
a.frames.clear();
}
animation.clear();
}
// Iniciador
void AnimatedSprite::init()
// Obtiene el indice de la animación a partir del nombre
int AnimatedSprite::getIndex(std::string name)
{
for (int i = 0; i < 20; i++)
int index = -1;
/*for (int i = 0; i < (int)animation.size(); i++)
{
mAnimation[i].numFrames = 0;
mAnimation[i].speed = 0;
mAnimation[i].loop = true;
mAnimation[i].completed = false;
for (int j = 0; i < 20; i++)
if (animation[i].name == name)
{
mAnimation[i].frames[j].x = 0;
mAnimation[i].frames[j].y = 0;
mAnimation[i].frames[j].w = 0;
mAnimation[i].frames[j].h = 0;
index = i;
}
}*/
for (auto a : animation)
{
index++;
if (a.name == name)
{
return index;
}
}
mCurrentFrame = 0;
mAnimationCounter = 0;
printf("** Warning: could not find \"%s\" animation\n", name.c_str());
index = 0;
return -1;
}
// Calcula el frame correspondiente a la animación
void AnimatedSprite::animate(int index)
void AnimatedSprite::animate()
{
if (mEnabled)
if (!enabled || animation[currentAnimation].speed == 0)
{
// Calculamos el frame actual a partir del contador
mCurrentFrame = mAnimationCounter / mAnimation[index].speed;
return;
}
// Si alcanzamos el final de la animación, reiniciamos el contador de la animación
// en función de la variable loop
if (mCurrentFrame >= mAnimation[index].numFrames)
// Calcula el frame actual a partir del contador
animation[currentAnimation].currentFrame = animation[currentAnimation].counter / animation[currentAnimation].speed;
// Si alcanza el final de la animación, reinicia el contador de la animación
// en función de la variable loop y coloca el nuevo frame
if (animation[currentAnimation].currentFrame >= animation[currentAnimation].frames.size())
{
if (mAnimation[index].loop)
mAnimationCounter = 0;
if (animation[currentAnimation].loop == -1)
{ // Si no hay loop, deja el último frame
animation[currentAnimation].currentFrame = animation[currentAnimation].frames.size();
animation[currentAnimation].completed = true;
}
else
mCurrentFrame = mAnimation[index].numFrames;
{ // Si hay loop, vuelve al frame indicado
animation[currentAnimation].counter = 0;
animation[currentAnimation].currentFrame = animation[currentAnimation].loop;
}
}
// En caso contrario
else
{
// Escogemos el frame correspondiente de la animación
setSpriteClip(mAnimation[index].frames[mCurrentFrame]);
// Escoge el frame correspondiente de la animación
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
// Incrementamos el contador de la animacion
mAnimationCounter++;
}
// Incrementa el contador de la animacion
animation[currentAnimation].counter++;
}
}
// Establece el frame actual de la animación
void AnimatedSprite::setCurrentFrame(Uint8 num)
void AnimatedSprite::setCurrentFrame(int num)
{
mCurrentFrame = num;
animation[currentAnimation].currentFrame = num;
// Escoge el frame correspondiente de la animación
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
}
// Establece el valor del contador
void AnimatedSprite::setAnimationCounter(Uint16 num)
void AnimatedSprite::setAnimationCounter(std::string name, int num)
{
mAnimationCounter = num;
}
// Establece el rectangulo para un frame de una animación
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
{
mAnimation[index_animation].frames[index_frame].x = x;
mAnimation[index_animation].frames[index_frame].y = y;
mAnimation[index_animation].frames[index_frame].w = w;
mAnimation[index_animation].frames[index_frame].h = h;
animation[getIndex(name)].counter = num;
}
// Establece la velocidad de una animación
void AnimatedSprite::setAnimationSpeed(Uint8 index, Uint8 speed)
void AnimatedSprite::setAnimationSpeed(std::string name, int speed)
{
mAnimation[index].speed = speed;
}
// Establece el numero de frames de una animación
void AnimatedSprite::setAnimationNumFrames(Uint8 index, Uint8 num)
{
mAnimation[index].numFrames = num;
animation[getIndex(name)].counter = speed;
}
// Establece si la animación se reproduce en bucle
void AnimatedSprite::setAnimationLoop(Uint8 index, bool loop)
void AnimatedSprite::setAnimationLoop(std::string name, int loop)
{
mAnimation[index].loop = loop;
animation[getIndex(name)].loop = loop;
}
// Establece el valor de la variable
void AnimatedSprite::setCompleted(Uint8 index, bool value)
void AnimatedSprite::setAnimationCompleted(std::string name, bool value)
{
mAnimation[index].completed = value;
animation[getIndex(name)].completed = value;
}
// Comprueba si ha terminado la animación
bool AnimatedSprite::isCompleted(Uint8 index)
bool AnimatedSprite::animationIsCompleted()
{
return mAnimation[index].completed;
return animation[currentAnimation].completed;
}
// Devuelve el rectangulo de una animación y frame concreto
SDL_Rect AnimatedSprite::getAnimationClip(Uint8 index_animation, Uint8 index_frame)
SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
{
return mAnimation[index_animation].frames[index_frame];
return animation[getIndex(name)].frames[index];
}
// Carga la animación desde un fichero
bool AnimatedSprite::load(std::string filePath)
{
int frames_per_row = 0;
int frame_width = 0;
int frame_height = 0;
// Indicador de éxito en la carga
bool success = true;
const std::string filename = filePath.substr(filePath.find_last_of("\\/") + 1);
std::ifstream file(filePath);
std::string line;
// El fichero se puede abrir
if (file.good())
{
// Procesa el fichero linea a linea
printf("Reading file %s\n", filename.c_str());
while (std::getline(file, line))
{
// Si la linea contiene el texto [enemy] se realiza el proceso de carga de un enemigo
if (line == "[animation]")
{
t_animation buffer;
buffer.counter = 0;
buffer.currentFrame = 0;
buffer.completed = false;
do
{
std::getline(file, line);
// Encuentra la posición del caracter '='
int pos = line.find("=");
// Procesa las dos subcadenas
if (pos != line.npos)
{
if (line.substr(0, pos) == "name")
{
buffer.name = line.substr(pos + 1, line.length());
}
else if (line.substr(0, pos) == "speed")
{
buffer.speed = std::stoi(line.substr(pos + 1, line.length()));
}
else if (line.substr(0, pos) == "loop")
{
buffer.loop = std::stoi(line.substr(pos + 1, line.length()));
}
else if (line.substr(0, pos) == "frames")
{
// Se introducen los valores separados por comas en un vector
std::stringstream ss(line.substr(pos + 1, line.length()));
std::string tmp;
SDL_Rect rect = {0, 0, frame_width, frame_height};
while (getline(ss, tmp, ','))
{
int num_tile = std::stoi(tmp);
rect.x = (num_tile % frames_per_row) * frame_width;
rect.y = (num_tile / frames_per_row) * frame_height;
buffer.frames.push_back(rect);
}
}
else
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
success = false;
}
}
} while (line != "[/animation]");
// Añade el enemigo al vector de enemigos
animation.push_back(buffer);
}
// En caso contrario se parsea el fichero para buscar las variables y los valores
else
{
// Encuentra la posición del caracter '='
int pos = line.find("=");
// Procesa las dos subcadenas
if (pos != line.npos)
{
if (line.substr(0, pos) == "frames_per_row")
{
frames_per_row = std::stoi(line.substr(pos + 1, line.length()));
}
else if (line.substr(0, pos) == "frame_width")
{
frame_width = std::stoi(line.substr(pos + 1, line.length()));
}
else if (line.substr(0, pos) == "frame_height")
{
frame_height = std::stoi(line.substr(pos + 1, line.length()));
}
else
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
success = false;
}
}
}
}
// Cierra el fichero
printf("Closing file %s\n\n", filename.c_str());
file.close();
}
// El fichero no se puede abrir
else
{
printf("Warning: Unable to open %s file\n", filename.c_str());
success = false;
}
// Pone un valor por defecto
setPos({0, 0, frame_width, frame_height});
return success;
}
// Establece la animacion actual
void AnimatedSprite::setCurrentAnimation(std::string name)
{
const int newAnimation = getIndex(name);
if (currentAnimation != newAnimation)
{
currentAnimation = newAnimation;
animation[currentAnimation].currentFrame = 0;
animation[currentAnimation].counter = 0;
animation[currentAnimation].completed = false;
}
}
// Actualiza las variables del objeto
void AnimatedSprite::update()
{
animate();
MovingSprite::update();
}

View File

@@ -1,69 +1,74 @@
#pragma once
#include "ifdefs.h"
#include <SDL2/SDL.h>
#include "movingsprite.h"
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
#ifndef ANIMATEDSPRITE_H
#define ANIMATEDSPRITE_H
#define MAX_FRAMES 30
#define MAX_ANIMATIONS 20
// Clase AnimatedSprite
class AnimatedSprite : public MovingSprite
{
private:
struct sAnimation
struct t_animation
{
SDL_Rect frames[MAX_FRAMES]; // Cada uno de los frames que componen la animación
Uint8 numFrames; // Numero de frames que componen la animación
Uint8 speed; // Velocidad de la animación
bool loop; // Indica si la animación se reproduce en bucle
std::string name; // Nombre de la animacion
std::vector<SDL_Rect> frames; // Cada uno de los frames que componen la animación
int speed; // Velocidad de la animación
int loop; // Indica a que frame vuelve la animación al terminar. -1 para que no vuelva
bool completed; // Indica si ha finalizado la animación
int currentFrame; // Frame actual
int counter; // Contador para las animaciones
};
sAnimation mAnimation[MAX_ANIMATIONS]; // Vector con las diferentes animaciones
Uint8 mCurrentFrame; // Frame actual
Uint16 mAnimationCounter; // Contador para las animaciones
std::vector<t_animation> animation; // Vector con las diferentes animaciones
int currentAnimation; // Animacion activa
public:
// Constructor
AnimatedSprite(LTexture *texture, SDL_Renderer *renderer);
AnimatedSprite(LTexture *texture = nullptr, SDL_Renderer *renderer = nullptr, std::string file = "");
// Destructor
~AnimatedSprite();
// Iniciador
void init();
// Calcula el frame correspondiente a la animación
void animate(int index);
// Calcula el frame correspondiente a la animación actual
void animate();
// Establece el frame actual de la animación
void setCurrentFrame(Uint8 num);
void setCurrentFrame(int num);
// Establece el valor del contador
void setAnimationCounter(Uint16 num);
// Establece el rectangulo para un frame de una animación
void setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h);
void setAnimationCounter(std::string name, int num);
// Establece la velocidad de una animación
void setAnimationSpeed(Uint8 index, Uint8 speed);
void setAnimationSpeed(std::string name, int speed);
// Establece el numero de frames de una animación
void setAnimationNumFrames(Uint8 index, Uint8 num);
// Establece si la animación se reproduce en bucle
void setAnimationLoop(Uint8 index, bool loop);
// Establece el frame al que vuelve la animación al finalizar
void setAnimationLoop(std::string name, int loop);
// Establece el valor de la variable
void setCompleted(Uint8 index, bool value);
void setAnimationCompleted(std::string name, bool value);
// Comprueba si ha terminado la animación
bool isCompleted(Uint8 index);
bool animationIsCompleted();
// Devuelve el rectangulo de una animación y frame concreto
SDL_Rect getAnimationClip(Uint8 index_animation, Uint8 index_frame);
SDL_Rect getAnimationClip(std::string name, Uint8 index);
// Obtiene el indice de la animación a partir del nombre
int getIndex(std::string name);
// Carga la animación desde un fichero
bool load(std::string filePath);
// Establece la animacion actual
void setCurrentAnimation(std::string name = "default");
// Actualiza las variables del objeto
void update();
};
#endif

View File

@@ -4,6 +4,7 @@
Asset::Asset(std::string path)
{
mExecutablePath = path;
longest_name = 0;
}
// Destructor
@@ -19,6 +20,9 @@ void Asset::add(std::string file, enum assetType type, bool required)
temp.type = type;
temp.required = required;
mFileList.push_back(temp);
const std::string filename = file.substr(file.find_last_of("\\/") + 1);
longest_name = SDL_max(longest_name, filename.size());
}
// Devuelve el fichero de un elemento de la lista a partir de una cadena
@@ -37,8 +41,20 @@ bool Asset::check()
{
bool success = true;
printf("\n** Checking files.\n");
// Comprueba la lista de ficheros clasificandolos por tipo
for (int type = 0; type < maxAssetType; type++)
{
// Comprueba si hay ficheros de ese tipo
bool any = false;
for (int i = 0; i < mFileList.size(); i++)
if ((mFileList[i].required) && (mFileList[i].type == type))
any = true;
// Si hay ficheros de ese tipo, comprueba si existen
if (any)
{
printf("\n>> %s FILES\n", getTypeName(type).c_str());
@@ -46,6 +62,7 @@ bool Asset::check()
if ((mFileList[i].required) && (mFileList[i].type == type))
success &= checkFile(mFileList[i].file);
}
}
// Resultado
if (success)
@@ -59,7 +76,8 @@ bool Asset::check()
// Comprueba que existe un fichero
bool Asset::checkFile(std::string path)
{
bool success = true;
bool success = false;
std::string result = "ERROR";
// Comprueba si existe el fichero
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
@@ -67,14 +85,13 @@ bool Asset::checkFile(std::string path)
if (file != NULL)
{
printf("Checking file %-20s [OK]\n", filename.c_str());
result = "OK";
success = true;
SDL_RWclose(file);
}
else
{
printf("Checking file %-20s [ERROR]\n", filename.c_str());
success = false;
}
const std::string s = "Checking file %-" + std::to_string(longest_name) + "s [" + result + "]\n";
printf(s.c_str(), filename.c_str());
return success;
}

View File

@@ -1,5 +1,6 @@
#pragma once
#include "ifdefs.h"
#include <SDL2/SDL.h>
#include <string>
#include <vector>
@@ -32,6 +33,8 @@ private:
bool required; // Indica si es un fichero que debe de existir
};
int longest_name; // Contiene la longitud del nombre de fichero mas largo
std::vector<item_t> mFileList;
std::string mExecutablePath;

View File

@@ -1,4 +1,5 @@
#pragma once
#include <SDL2/SDL.h>
#include <string>
#include "utils.h"
@@ -9,29 +10,21 @@
// Textos
#define WINDOW_CAPTION "JailDoctor's Dilemma"
#define TEXT_COPYRIGHT "@2022 JailDesigner"
#define VERSION "0.1"
#define VERSION "0.7"
// Tamaño de bloque
#define BLOCK 8
#define HALF_BLOCK 4
// Tamaño de la pantalla real
#define SCREEN_WIDTH 256
#define SCREEN_HEIGHT 192
// Tamaño de la pantalla virtual
#define GAMECANVAS_WIDTH 256
#define GAMECANVAS_HEIGHT 192
// Tamaño de la pantalla que se muestra
const int VIEW_WIDTH = SCREEN_WIDTH * 3;
const int VIEW_HEIGHT = SCREEN_HEIGHT * 3;
// Zona de juego
const int PLAY_AREA_TOP = (0 * BLOCK);
const int PLAY_AREA_BOTTOM = GAMECANVAS_HEIGHT - (4 * BLOCK);
const int PLAY_AREA_BOTTOM = (16 * BLOCK);
const int PLAY_AREA_LEFT = (0 * BLOCK);
const int PLAY_AREA_RIGHT = GAMECANVAS_WIDTH - (0 * BLOCK);
const int PLAY_AREA_RIGHT = (32 * BLOCK);
const int PLAY_AREA_WIDTH = PLAY_AREA_RIGHT - PLAY_AREA_LEFT;
const int PLAY_AREA_HEIGHT = PLAY_AREA_BOTTOM - PLAY_AREA_TOP;
const int PLAY_AREA_CENTER_X = PLAY_AREA_LEFT + (PLAY_AREA_WIDTH / 2);
@@ -41,6 +34,11 @@ const int PLAY_AREA_CENTER_Y = PLAY_AREA_TOP + (PLAY_AREA_HEIGHT / 2);
const int PLAY_AREA_FIRST_QUARTER_Y = PLAY_AREA_HEIGHT / 4;
const int PLAY_AREA_THIRD_QUARTER_Y = (PLAY_AREA_HEIGHT / 4) * 3;
#define BORDER_TOP 0
#define BORDER_RIGHT 1
#define BORDER_BOTTOM 2
#define BORDER_LEFT 3
// Anclajes de pantalla
const int GAMECANVAS_CENTER_X = GAMECANVAS_WIDTH / 2;
const int GAMECANVAS_FIRST_QUARTER_X = GAMECANVAS_WIDTH / 4;
@@ -56,37 +54,8 @@ const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3;
#define SECTION_PROG_GAME 3
#define SECTION_PROG_QUIT 4
// Subsecciones
#define SECTION_GAME_PLAY 0
#define SECTION_GAME_PAUSE 1
#define SECTION_GAME_GAMEOVER 2
#define SECTION_TITLE_1 3
#define SECTION_TITLE_2 4
#define SECTION_TITLE_3 5
#define SECTION_TITLE_INSTRUCTIONS 6
// Estados de cada elemento que pertenece a un evento
#define EVENT_WAITING 1
#define EVENT_RUNNING 2
#define EVENT_COMPLETED 3
// Estados de entrada
#define INPUT_NULL 0
#define INPUT_FIRE_LEFT 7
#define INPUT_FIRE_UP 8
#define INPUT_FIRE_RIGHT 9
#define INPUT_PAUSE 10
// Zona muerta del mando analógico
#define JOYSTICK_DEAD_ZONE 8000
// Colores
const color_t bgColor = {0x27, 0x27, 0x36};
const color_t noColor = {0xFF, 0xFF, 0xFF};
const color_t shdwTxtColor = {0x43, 0x43, 0x4F};
// Tipo de filtro
#define FILTER_NEAREST 0
#define FILTER_LINEAL 1
const color_t borderColor = {0x27, 0x27, 0x36};
const color_t black = {0xFF, 0xFF, 0xFF};
#endif

85
source/debug.cpp Normal file
View File

@@ -0,0 +1,85 @@
#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;
enabled = false;
}
// 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();
}
// Establece el valor de la variable
void Debug::setEnabled(bool value)
{
enabled = value;
}
// Obtiene el valor de la variable
bool Debug::getEnabled()
{
return enabled;
}
// Cambia el valor de la variable
void Debug::switchEnabled()
{
enabled = !enabled;
}

60
source/debug.h Normal file
View File

@@ -0,0 +1,60 @@
#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
bool enabled; // Indica si esta activo el modo 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();
// Establece el valor de la variable
void setEnabled(bool value);
// Obtiene el valor de la variable
bool getEnabled();
// Cambia el valor de la variable
void switchEnabled();
};
#endif

View File

@@ -1,4 +1,4 @@
#include "const.h"
#include "utils.h"
#include "director.h"
#include <iostream>
@@ -7,39 +7,30 @@
// Constructor
Director::Director(std::string path)
{
// Inicializa la ruta
setExecutablePath(path);
// Crea el objeto que controla los ficheros de recursos
mAsset = new Asset(mExecutablePath);
// Establece la lista de ficheros
setFileList();
asset = new Asset(path.substr(0, path.find_last_of("\\/")));
// Si falta algún fichero no inicia el programa
Uint8 section = SECTION_PROG_GAME;
if (!mAsset->check())
section = SECTION_PROG_QUIT;
// Inicializa el objeto de idioma
mLang = new Lang(mAsset);
// Crea el puntero a la estructura y carga el fichero de configuración
mOptions = new options_t;
if (!loadConfigFile())
if (!setFileList())
{
mOptions->fullScreenMode = 0;
mOptions->windowSize = 3;
mOptions->language = en_UK;
mOptions->difficulty = DIFFICULTY_NORMAL;
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
mOptions->filter = FILTER_NEAREST;
mOptions->vSync = true;
section.name = SECTION_PROG_QUIT;
}
else
{
section.name = SECTION_PROG_GAME;
section.subsection = 0;
}
// Crea los objetos
mInput = new Input(mAsset->get("gamecontrollerdb.txt"));
// Crea el puntero a la estructura y carga el fichero de configuración
options = new options_t;
options->fullScreenMode = 0;
options->windowSize = 3;
options->filter = FILTER_NEAREST;
options->vSync = true;
options->screenWidth = GAMECANVAS_WIDTH * options->windowSize;
options->screenHeight = GAMECANVAS_HEIGHT * options->windowSize;
options->integerScale = true;
options->keepAspect = true;
// Inicializa SDL
initSDL();
@@ -47,69 +38,50 @@ Director::Director(std::string path)
// Inicializa JailAudio
initJailAudio();
// Aplica las opciones
SDL_SetWindowFullscreen(mWindow, mOptions->fullScreenMode);
SDL_SetWindowSize(mWindow, SCREEN_WIDTH * mOptions->windowSize, SCREEN_HEIGHT * mOptions->windowSize);
mLang->setLang(mOptions->language);
// Inicializa el resto de variables
init(section);
// Crea los objetos
input = new Input(asset->get("gamecontrollerdb.txt"));
initInput();
screen = new Screen(window, renderer, options, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
screen->setBorderColor(borderColor);
debug = new Debug(renderer, screen, asset);
}
Director::~Director()
{
saveConfigFile();
delete mInput;
mInput = nullptr;
delete mLang;
mLang = nullptr;
delete mOptions;
mOptions = nullptr;
delete mAsset;
mAsset = nullptr;
SDL_DestroyRenderer(mRenderer);
SDL_DestroyWindow(mWindow);
mRenderer = nullptr;
mWindow = nullptr;
delete options;
delete asset;
delete input;
delete screen;
delete debug;
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
}
// Inicia las variables necesarias para arrancar el programa
void Director::init(Uint8 name)
void Director::initInput()
{
// Sección
mSection.name = name;
mSection.subsection = 0;
input->bindKey(INPUT_UP, SDL_SCANCODE_UP);
input->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN);
input->bindKey(INPUT_LEFT, SDL_SCANCODE_LEFT);
input->bindKey(INPUT_RIGHT, SDL_SCANCODE_RIGHT);
input->bindKey(INPUT_ACCEPT, SDL_SCANCODE_RETURN);
input->bindKey(INPUT_CANCEL, SDL_SCANCODE_ESCAPE);
input->bindKey(INPUT_BUTTON_1, SDL_SCANCODE_SPACE);
input->bindKey(INPUT_BUTTON_2, SDL_SCANCODE_D);
input->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE);
input->bindKey(INPUT_BUTTON_ESCAPE, SDL_SCANCODE_ESCAPE);
// Textos
mLang->setLang(mOptions->language);
// Controles
mInput->bindKey(INPUT_UP, SDL_SCANCODE_UP);
mInput->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN);
mInput->bindKey(INPUT_LEFT, SDL_SCANCODE_LEFT);
mInput->bindKey(INPUT_RIGHT, SDL_SCANCODE_RIGHT);
mInput->bindKey(INPUT_ACCEPT, SDL_SCANCODE_RETURN);
mInput->bindKey(INPUT_CANCEL, SDL_SCANCODE_ESCAPE);
mInput->bindKey(INPUT_BUTTON_1, SDL_SCANCODE_SPACE);
mInput->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE);
mInput->bindKey(INPUT_BUTTON_ESCAPE, SDL_SCANCODE_ESCAPE);
mInput->bindGameControllerButton(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
mInput->bindGameControllerButton(INPUT_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
mInput->bindGameControllerButton(INPUT_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
mInput->bindGameControllerButton(INPUT_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
mInput->bindGameControllerButton(INPUT_ACCEPT, SDL_CONTROLLER_BUTTON_B);
mInput->bindGameControllerButton(INPUT_CANCEL, SDL_CONTROLLER_BUTTON_A);
mInput->bindGameControllerButton(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_B);
mInput->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE);
mInput->bindGameControllerButton(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE);
input->bindGameControllerButton(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
input->bindGameControllerButton(INPUT_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
input->bindGameControllerButton(INPUT_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
input->bindGameControllerButton(INPUT_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
input->bindGameControllerButton(INPUT_ACCEPT, SDL_CONTROLLER_BUTTON_B);
input->bindGameControllerButton(INPUT_CANCEL, SDL_CONTROLLER_BUTTON_A);
input->bindGameControllerButton(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_B);
input->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE);
input->bindGameControllerButton(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE);
}
// Inicializa JailAudio
@@ -126,7 +98,6 @@ bool Director::initSDL()
// Inicializa SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO) < 0)
//if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
printf("SDL could not initialize!\nSDL Error: %s\n", SDL_GetError());
success = false;
@@ -137,14 +108,14 @@ bool Director::initSDL()
std::srand(static_cast<unsigned int>(SDL_GetTicks()));
// Establece el filtro de la textura a nearest
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(mOptions->filter).c_str()))
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(options->filter).c_str()))
{
printf("Warning: Nearest texture filtering not enabled!\n");
}
// Crea la ventana
mWindow = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, VIEW_WIDTH, VIEW_HEIGHT, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
if (mWindow == NULL)
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, options->screenWidth, options->screenHeight, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
if (window == NULL)
{
printf("Window could not be created!\nSDL Error: %s\n", SDL_GetError());
success = false;
@@ -152,12 +123,12 @@ bool Director::initSDL()
else
{
// Crea un renderizador para la ventana. El vsync se activa en funcion de las opciones
if (mOptions->vSync)
mRenderer = SDL_CreateRenderer(mWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (options->vSync)
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
else
mRenderer = SDL_CreateRenderer(mWindow, -1, SDL_RENDERER_ACCELERATED);
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if (mRenderer == NULL)
if (renderer == NULL)
{
printf("Renderer could not be created!\nSDL Error: %s\n", SDL_GetError());
success = false;
@@ -165,13 +136,13 @@ bool Director::initSDL()
else
{
// Inicializa el color de renderizado
SDL_SetRenderDrawColor(mRenderer, 0x00, 0x00, 0x00, 0xFF);
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
// Establece el tamaño del buffer de renderizado
SDL_RenderSetLogicalSize(mRenderer, SCREEN_WIDTH, SCREEN_HEIGHT);
SDL_RenderSetLogicalSize(renderer, options->screenWidth, options->screenHeight);
// Establece el modo de mezcla
SDL_SetRenderDrawBlendMode(mRenderer, SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
}
}
}
@@ -181,186 +152,143 @@ bool Director::initSDL()
}
// Crea el indice de ficheros
void Director::setFileList()
bool Director::setFileList()
{
mAsset->add("/media/font/8bithud.png", font);
mAsset->add("/media/font/8bithud.txt", font);
mAsset->add("/media/font/nokia.png", font);
mAsset->add("/media/font/nokia.txt", font);
mAsset->add("/media/font/nokia2.png", font);
mAsset->add("/media/font/nokia2.txt", font);
mAsset->add("/media/font/smb2.png", font);
mAsset->add("/media/font/smb2.txt", font);
mAsset->add("/media/lang/es_ES.txt", lang);
mAsset->add("/media/lang/en_UK.txt", lang);
mAsset->add("/media/lang/ba_BA.txt", lang);
mAsset->add("/data/gamecontrollerdb.txt", data);
mAsset->add("/data/config.bin", data, false);
mAsset->add("/data/room/01.room", room);
mAsset->add("/data/room/02.room", room);
mAsset->add("/media/tilesets/room1.png", bitmap);
mAsset->add("/media/enemies/enemy01.png", bitmap);
}
asset->add("/media/font/smb2.png", font);
asset->add("/media/font/smb2.txt", font);
asset->add("/media/font/debug.png", font);
asset->add("/media/font/debug.txt", font);
// Carga el fichero de configuración
bool Director::loadConfigFile()
{
// Pone unos valores por defecto
mOptions->fullScreenMode = 0;
mOptions->windowSize = 3;
mOptions->language = en_UK;
mOptions->difficulty = DIFFICULTY_NORMAL;
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
mOptions->filter = FILTER_NEAREST;
mOptions->vSync = true;
asset->add("/data/gamecontrollerdb.txt", data);
// Indicador de éxito en la carga
bool success = true;
asset->add("/data/room/01.room", room);
asset->add("/data/room/02.room", room);
asset->add("/data/room/03.room", room);
asset->add("/data/room/04.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/02.tmx", room);
asset->add("/data/room/03.tmx", room);
asset->add("/data/room/04.tmx", room);
asset->add("/data/room/05.tmx", room);
asset->add("/data/room/06.tmx", room);
const std::string p = mAsset->get("config.bin");
std::string filename = p.substr(p.find_last_of("\\/") + 1);
SDL_RWops *file = SDL_RWFromFile(p.c_str(), "r+b");
asset->add("/media/tilesets/standard.png", bitmap);
// El fichero no existe
if (file == NULL)
{
printf("Warning: Unable to open %s file\n", filename.c_str());
asset->add("/media/enemies/paco.png", bitmap);
asset->add("/media/enemies/paco.ani", data);
asset->add("/media/enemies/chip.png", bitmap);
asset->add("/media/enemies/chip.ani", data);
asset->add("/media/enemies/wave.png", bitmap);
asset->add("/media/enemies/wave.ani", data);
asset->add("/media/enemies/sigmasua.png", bitmap);
asset->add("/media/enemies/sigmasua.ani", data);
asset->add("/media/enemies/diskette.png", bitmap);
asset->add("/media/enemies/diskette.ani", data);
// Crea el fichero para escritura
file = SDL_RWFromFile(p.c_str(), "w+b");
if (file != NULL)
{
printf("New file (%s) created!\n", filename.c_str());
asset->add("/media/player/player.png", bitmap);
asset->add("/media/player/player.ani", data);
// Escribe los datos
SDL_RWwrite(file, &mOptions->fullScreenMode, sizeof(mOptions->fullScreenMode), 1);
SDL_RWwrite(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
SDL_RWwrite(file, &mOptions->language, sizeof(mOptions->language), 1);
SDL_RWwrite(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
SDL_RWwrite(file, &mOptions->input[0].deviceType, sizeof(mOptions->input[0].deviceType), 1);
SDL_RWwrite(file, &mOptions->input[1].deviceType, sizeof(mOptions->input[1].deviceType), 1);
SDL_RWwrite(file, &mOptions->filter, sizeof(mOptions->filter), 1);
SDL_RWwrite(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
asset->add("/media/items/items.png", bitmap);
// Cierra el fichero
SDL_RWclose(file);
}
else
{
printf("Error: Unable to create file %s\n", filename.c_str());
success = false;
}
}
// El fichero existe
else
{
// Carga los datos
printf("Reading file %s\n", filename.c_str());
SDL_RWread(file, &mOptions->fullScreenMode, sizeof(mOptions->fullScreenMode), 1);
SDL_RWread(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
SDL_RWread(file, &mOptions->language, sizeof(mOptions->language), 1);
SDL_RWread(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
SDL_RWread(file, &mOptions->input[0].deviceType, sizeof(mOptions->input[0].deviceType), 1);
SDL_RWread(file, &mOptions->input[1].deviceType, sizeof(mOptions->input[1].deviceType), 1);
SDL_RWread(file, &mOptions->filter, sizeof(mOptions->filter), 1);
SDL_RWread(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
asset->add("/media/music/title.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);
// Normaliza los valores
if (!((mOptions->fullScreenMode == 0) ||
(mOptions->fullScreenMode == SDL_WINDOW_FULLSCREEN) ||
(mOptions->fullScreenMode == SDL_WINDOW_FULLSCREEN_DESKTOP)))
mOptions->fullScreenMode = 0;
if ((mOptions->windowSize < 1) || (mOptions->windowSize > 4))
mOptions->windowSize = 3;
if ((mOptions->language < 0) || (mOptions->language > MAX_LANGUAGES))
mOptions->language = en_UK;
asset->add("/media/sound/item.wav", sound);
asset->add("/media/sound/death.wav", sound);
asset->add("/media/sound/jump1.wav", sound);
asset->add("/media/sound/jump2.wav", sound);
asset->add("/media/sound/jump3.wav", sound);
asset->add("/media/sound/jump4.wav", sound);
asset->add("/media/sound/jump5.wav", sound);
asset->add("/media/sound/jump6.wav", sound);
asset->add("/media/sound/jump7.wav", sound);
asset->add("/media/sound/jump8.wav", sound);
asset->add("/media/sound/jump9.wav", sound);
asset->add("/media/sound/jump10.wav", sound);
asset->add("/media/sound/jump11.wav", sound);
asset->add("/media/sound/jump12.wav", sound);
asset->add("/media/sound/jump13.wav", sound);
asset->add("/media/sound/jump14.wav", sound);
asset->add("/media/sound/jump15.wav", sound);
asset->add("/media/sound/jump16.wav", sound);
asset->add("/media/sound/jump17.wav", sound);
asset->add("/media/sound/jump18.wav", sound);
asset->add("/media/sound/jump19.wav", sound);
asset->add("/media/sound/jump20.wav", sound);
asset->add("/media/sound/jump21.wav", sound);
asset->add("/media/sound/jump22.wav", sound);
asset->add("/media/sound/jump23.wav", sound);
asset->add("/media/sound/jump24.wav", sound);
// Cierra el fichero
SDL_RWclose(file);
}
asset->add("/media/logo/jailgames.png", bitmap);
asset->add("/media/logo/since_1998.png", bitmap);
asset->add("/media/logo/seagull.png", bitmap);
return success;
}
asset->add("/media/title/loading_screen1.png", bitmap);
asset->add("/media/title/loading_screen2.png", bitmap);
// Guarda el fichero de configuración
bool Director::saveConfigFile()
{
bool success = true;
const std::string p = mAsset->get("config.bin");
std::string filename = p.substr(p.find_last_of("\\/") + 1);
SDL_RWops *file = SDL_RWFromFile(p.c_str(), "w+b");
if (file != NULL)
{
// Guarda los datos
SDL_RWwrite(file, &mOptions->fullScreenMode, sizeof(mOptions->fullScreenMode), 1);
SDL_RWwrite(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
SDL_RWwrite(file, &mOptions->language, sizeof(mOptions->language), 1);
SDL_RWwrite(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
SDL_RWwrite(file, &mOptions->input[0].deviceType, sizeof(mOptions->input[0].deviceType), 1);
SDL_RWwrite(file, &mOptions->input[1].deviceType, sizeof(mOptions->input[1].deviceType), 1);
SDL_RWwrite(file, &mOptions->filter, sizeof(mOptions->filter), 1);
SDL_RWwrite(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
printf("Writing file %s\n", filename.c_str());
// Cierra el fichero
SDL_RWclose(file);
}
else
{
printf("Error: Unable to save %s file! %s\n", filename.c_str(), SDL_GetError());
}
return success;
}
// Establece el valor de la variable
void Director::setExecutablePath(std::string path)
{
mExecutablePath = path.substr(0, path.find_last_of("\\/"));
return asset->check();
}
// Obtiene el valor de la variable
Uint8 Director::getSubsection()
{
return mSection.subsection;
return section.subsection;
}
// Obtiene el valor de la variable
Uint8 Director::getSection()
{
return mSection.name;
return section.name;
}
// Establece el valor de la variable
void Director::setSection(section_t section)
{
mSection = section;
this->section = section;
}
// Ejecuta la seccion de juego con el logo
void Director::runLogo()
{
logo = new Logo(renderer, screen, asset);
setSection(logo->run());
delete logo;
}
// Ejecuta la seccion de juego de la introducción
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
void Director::runTitle()
{
title = new Title(renderer, screen, asset);
setSection(title->run());
delete title;
}
// Ejecuta la seccion de juego donde se juega
void Director::runGame()
{
mGame = new Game(mWindow, mRenderer, mAsset, mLang, mInput);
setSection(mGame->run());
delete mGame;
game = new Game(renderer, screen, asset, input, debug);
setSection(game->run());
delete game;
}
void Director::run()
{
// Bucle principal
while (!(getSection() == SECTION_PROG_QUIT))
while (getSection() != SECTION_PROG_QUIT)
{
switch (getSection())
{

View File

@@ -1,40 +1,41 @@
#pragma once
#include "ifdefs.h"
#include <SDL2/SDL.h>
#include "sprite.h"
#include "movingsprite.h"
#include "text.h"
#include "writer.h"
#include "menu.h"
#include "const.h"
#include "jail_audio.h"
#include "utils.h"
#include "input.h"
#include "fade.h"
#include "game.h"
#include "logo.h"
#include "title.h"
#include "intro.h"
#include "asset.h"
#include "lang.h"
#include "debug.h"
#include "const.h"
#ifndef DIRECTOR_H
#define DIRECTOR_H
#define MAX_FILE_LIST 100
// Director
class Director
{
private:
SDL_Window *mWindow; // La ventana donde dibujamos
SDL_Renderer *mRenderer; // El renderizador de la ventana
SDL_Window *window; // La ventana donde dibujamos
SDL_Renderer *renderer; // El renderizador de la ventana
Screen *screen; // Objeto encargado de dibujar en pantalla
Input *input; // Objeto Input para gestionar las entradas
Game *game; // Objeto para gestionar la sección del juego
Logo *logo; // Objeto para gestionar la sección del logo del programa
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
Debug *debug; // Objeto para getsionar la información de debug
Input *mInput; // Objeto Input para gestionar las entradas
Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas
Game *mGame; // Objeto para la sección del juego
Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos
struct options_t *options; // Variable con todas las opciones del programa
struct options_t *mOptions; // Variable con todas las opciones del programa
std::string mExecutablePath; // Path del ejecutable
section_t mSection; // Sección y subsección actual del programa;
std::string executablePath; // Path del ejecutable
section_t section; // Sección y subsección actual del programa;
// Inicializa jail_audio
void initJailAudio();
@@ -42,20 +43,11 @@ private:
// Arranca SDL y crea la ventana
bool initSDL();
// Inicializa el objeto Input
void initInput();
// Crea el indice de ficheros
void setFileList();
// Comprueba que todos los ficheros existen
bool checkFileList();
// Carga el fichero de configuración
bool loadConfigFile();
// Guarda el fichero de configuración
bool saveConfigFile();
// Establece el valor de la variable
void setExecutablePath(std::string path);
bool setFileList();
// Obtiene el valor de la variable
Uint8 getSubsection();
@@ -78,9 +70,6 @@ private:
// Ejecuta la seccion de juego donde se juega
void runGame();
// Comprueba los ficheros del vector de ficheros que coinciden con una ruta dada
bool checkFolder(std::string name, std::string path);
public:
// Constructor
Director(std::string path);
@@ -88,9 +77,6 @@ public:
// Destructor
~Director();
// Inicia las variables necesarias para arrancar el programa
void init(Uint8 name);
// Bucle principal
void run();
};

View File

@@ -10,11 +10,8 @@ Enemy::Enemy(enemy_t enemy)
renderer = enemy.renderer;
// Crea objetos
texture = new LTexture();
sprite = new AnimatedSprite(texture, renderer);
// Carga la textura
loadTextureFromFile(texture, asset->get(enemy.tileset), renderer);
texture = new LTexture(renderer, asset->get(enemy.tileset));
sprite = new AnimatedSprite(texture, renderer, asset->get(enemy.animation));
// Obten el resto de valores
x1 = enemy.x1;
@@ -26,35 +23,21 @@ Enemy::Enemy(enemy_t enemy)
sprite->setPosY(enemy.y);
sprite->setVelX(enemy.vx);
sprite->setVelY(enemy.vy);
sprite->setWidth(enemy.w);
sprite->setHeight(enemy.h);
// Inicializa el sprite con el resto de parametros comunes
sprite->setWidth(16);
sprite->setHeight(16);
sprite->setCurrentFrame(0);
sprite->setAnimationCounter(0);
sprite->setAnimationNumFrames(0, 4);
sprite->setAnimationSpeed(0, 5);
sprite->setAnimationLoop(0, true);
sprite->setAnimationFrames(0, 0, 16 * 0, 0, 16, 16);
sprite->setAnimationFrames(0, 1, 16 * 1, 0, 16, 16);
sprite->setAnimationFrames(0, 2, 16 * 2, 0, 16, 16);
sprite->setAnimationFrames(0, 3, 16 * 3, 0, 16, 16);
sprite->setSpriteClip(sprite->getAnimationClip(0, 0));
collider = getRect();
}
// Destructor
Enemy::~Enemy()
{
texture->unload();
delete texture;
texture = nullptr;
delete sprite;
sprite = nullptr;
}
// Pinta el enemigo en pantalla
void Enemy::draw()
void Enemy::render()
{
sprite->getTexture()->setColor(color.r, color.g, color.b);
sprite->render();
@@ -65,8 +48,9 @@ void Enemy::draw()
void Enemy::update()
{
sprite->update();
sprite->animate(0);
// sprite->animate();
checkPath();
collider = getRect();
}
// Comprueba si ha llegado al limite del recorrido para darse media vuelta
@@ -74,13 +58,29 @@ void Enemy::checkPath()
{
if (sprite->getPosX() > x2 || sprite->getPosX() < x1)
{
//sprite->setPosX(sprite->getPosX() - sprite->getVelX());
sprite->setVelX(sprite->getVelX() * (-1));
}
if (sprite->getPosY() > y2 || sprite->getPosY() < y1)
{
//sprite->setPosY(sprite->getPosY() - sprite->getVelY());
sprite->setVelY(sprite->getVelY() * (-1));
}
}
// Devuelve el rectangulo que contiene al enemigo
SDL_Rect Enemy::getRect()
{
return sprite->getRect();
}
// Obtiene el rectangulo de colision del enemigo
SDL_Rect &Enemy::getCollider()
{
return collider;
}
// Recarga la textura
void Enemy::reLoadTexture()
{
texture->reLoad();
}

View File

@@ -1,5 +1,5 @@
#pragma once
#include "ifdefs.h"
#include <SDL2/SDL.h>
#include "utils.h"
#include "asset.h"
#include "animatedsprite.h"
@@ -29,6 +29,9 @@ struct enemy_t
SDL_Renderer *renderer; // El renderizador de la ventana
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
std::string tileset; // Fichero con los graficos del enemigo
std::string animation; // Fichero con las animaciones del enemigo
int w; // Anchura del enemigo
int h; // Altura del enemigo
float x; // Posición inicial en el eje X
float y; // Posición inicial en el eje Y
float vx; // Velocidad en el eje X
@@ -54,6 +57,7 @@ private:
int x2; // Limite derecho de la ruta en el eje X
int y1; // Limite superior de la ruta en el eje Y
int y2; // Limite inferior de la ruta en el eje Y
SDL_Rect collider; // Caja de colisión
// Comprueba si ha llegado al limite del recorrido para darse media vuelta
void checkPath();
@@ -66,10 +70,19 @@ public:
~Enemy();
// Pinta el enemigo en pantalla
void draw();
void render();
// Actualiza las variables del objeto
void update();
// Devuelve el rectangulo que contiene al enemigo
SDL_Rect getRect();
// Obtiene el rectangulo de colision del enemigo
SDL_Rect &getCollider();
// Recarga la textura
void reLoadTexture();
};
#endif

View File

@@ -1,169 +0,0 @@
#include "fade.h"
#include "const.h"
// Constructor
Fade::Fade(SDL_Renderer *renderer)
{
mRenderer = renderer;
mBackbuffer = SDL_CreateTexture(mRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, SCREEN_WIDTH, SCREEN_HEIGHT);
if (mBackbuffer == NULL)
printf("Backbuffer could not be created!\nSDL Error: %s\n", SDL_GetError());
}
// Destructor
Fade::~Fade()
{
SDL_DestroyTexture(mBackbuffer);
mBackbuffer = nullptr;
}
// Inicializa las variables
void Fade::init(Uint8 r, Uint8 g, Uint8 b)
{
mFadeType = FADE_CENTER;
mEnabled = false;
mFinished = false;
mCounter = 0;
mR = r;
mG = g;
mB = b;
}
// Pinta una transición en pantalla
void Fade::render()
{
if (mEnabled && !mFinished)
{
switch (mFadeType)
{
case FADE_FULLSCREEN:
mRect1 = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
for (int i = 0; i < 256; i += 4)
{
// Dibujamos sobre el renderizador
SDL_SetRenderTarget(mRenderer, NULL);
// Copia el backbuffer con la imagen que había al renderizador
SDL_RenderCopy(mRenderer, mBackbuffer, NULL, NULL);
SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, i);
SDL_RenderFillRect(mRenderer, &mRect1);
// Vuelca el renderizador en pantalla
SDL_RenderPresent(mRenderer);
}
// Deja todos los buffers del mismo color
SDL_SetRenderTarget(mRenderer, mBackbuffer);
SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, 255);
SDL_RenderClear(mRenderer);
SDL_SetRenderTarget(mRenderer, NULL);
SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, 255);
SDL_RenderClear(mRenderer);
break;
case FADE_CENTER:
mRect1 = {0, 0, SCREEN_WIDTH, 0};
mRect2 = {0, 0, SCREEN_WIDTH, 0};
SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, 64);
for (int i = 0; i < mCounter; i++)
{
mRect1.h = mRect2.h = i * 4;
mRect2.y = SCREEN_HEIGHT - (i * 4);
SDL_RenderFillRect(mRenderer, &mRect1);
SDL_RenderFillRect(mRenderer, &mRect2);
}
if ((mCounter * 4) > SCREEN_HEIGHT)
mFinished = true;
break;
case FADE_RANDOM_SQUARE:
mRect1 = {0, 0, 32, 32};
for (Uint16 i = 0; i < 50; i++)
{
// Crea un color al azar
mR = 255 * (rand() % 2);
mG = 255 * (rand() % 2);
mB = 255 * (rand() % 2);
SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, 64);
// Dibujamos sobre el backbuffer
SDL_SetRenderTarget(mRenderer, mBackbuffer);
mRect1.x = rand() % (SCREEN_WIDTH - mRect1.w);
mRect1.y = rand() % (SCREEN_HEIGHT - mRect1.h);
SDL_RenderFillRect(mRenderer, &mRect1);
// Volvemos a usar el renderizador de forma normal
SDL_SetRenderTarget(mRenderer, NULL);
// Copiamos el backbuffer al renderizador
SDL_RenderCopy(mRenderer, mBackbuffer, NULL, NULL);
// Volcamos el renderizador en pantalla
SDL_RenderPresent(mRenderer);
SDL_Delay(100);
}
break;
default:
break;
}
}
if (mFinished)
{
SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, 255);
SDL_RenderClear(mRenderer);
}
}
// Actualiza las variables internas
void Fade::update()
{
if (mEnabled)
mCounter++;
}
// Activa el fade
void Fade::activateFade()
{
mEnabled = true;
mFinished = false;
mCounter = 0;
}
// Comprueba si está activo
bool Fade::isEnabled()
{
return mEnabled;
}
// Comprueba si ha terminado la transicion
bool Fade::hasEnded()
{
if (mFinished)
{
//mEnabled = false;
//mFinished = false;
return true;
}
else
{
return false;
}
}
// Establece el tipo de fade
void Fade::setFadeType(Uint8 fadeType)
{
mFadeType = fadeType;
}

View File

@@ -1,55 +0,0 @@
#pragma once
#include "ifdefs.h"
#include "ltexture.h"
#ifndef FADE_H
#define FADE_H
#define FADE_FULLSCREEN 0
#define FADE_CENTER 1
#define FADE_RANDOM_SQUARE 2
// Fade
class Fade
{
private:
SDL_Renderer *mRenderer; // El renderizador de la ventana
SDL_Texture *mBackbuffer; // Textura para usar como backbuffer
Uint8 mFadeType; // Tipo de fade a realizar
Uint16 mCounter; // Contador interno
bool mEnabled; // Indica si el fade está activo
bool mFinished; // Indica si ha terminado la transición
Uint8 mR, mG, mB; // Colores para el fade
SDL_Rect mRect1; // Rectangulo usado para crear los efectos de transición
SDL_Rect mRect2; // Rectangulo usado para crear los efectos de transición
public:
// Constructor
Fade(SDL_Renderer *renderer);
// Destructor
~Fade();
// Inicializa las variables
void init(Uint8 r, Uint8 g, Uint8 b);
// Pinta una transición en pantalla
void render();
// Actualiza las variables internas
void update();
// Activa el fade
void activateFade();
// Comprueba si ha terminado la transicion
bool hasEnded();
// Comprueba si está activo
bool isEnabled();
// Establece el tipo de fade
void setFadeType(Uint8 fadeType);
};
#endif

View File

@@ -1,149 +1,256 @@
#include "game.h"
// Constructor
Game::Game(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Lang *lang, Input *input)
Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Debug *debug)
{
// Copia los punteros
mRenderer = renderer;
mAsset = asset;
mLang = lang;
mInput = input;
// Inicia algunas variables
board.iniClock = SDL_GetTicks();
currentRoom = "01.room";
spawnPoint = {16, 96, 0, 0, 0, s_standing, SDL_FLIP_NONE};
mScreen = new Screen(window, renderer);
mRoom = new Room(mAsset->get("01.room"), mRenderer, mAsset);
mEventHandler = new SDL_Event();
mTextureText = new LTexture();
mText = new Text(mAsset->get("smb2.txt"), mTextureText, renderer);
mFade = new Fade(renderer);
// Copia los punteros
this->renderer = renderer;
this->asset = asset;
this->screen = screen;
this->input = input;
this->debug = debug;
//this->debug->setEnabled(true);
//currentRoom = "06.room";
//spawnPoint = {240, 96, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
// Crea los objetos
scoreboard = new ScoreBoard(renderer, asset, &board);
itemTracker = new ItemTracker();
roomTracker = new RoomTracker();
room = new Room(asset->get(currentRoom), renderer, screen, asset, itemTracker, &board.items, debug);
player = new Player(spawnPoint, asset->get("player.png"), asset->get("player.ani"), renderer, asset, input, room, debug);
eventHandler = new SDL_Event();
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
music = JA_LoadMusic(asset->get("game.ogg").c_str());
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
test = new Test(renderer, screen, asset, debug);
// Inicializa el resto de variables
ticks = 0;
ticksSpeed = 15;
board.lives = 9;
board.items = 0;
board.rooms = 1;
roomTracker->addRoom(currentRoom);
player->setInvincible(debug->getEnabled());
board.music = !debug->getEnabled();
section.name = SECTION_PROG_GAME;
section.subsection = SUBSECTION_GAME_PLAY;
}
Game::~Game()
{
mRenderer = nullptr;
mAsset = nullptr;
mLang = nullptr;
mInput = nullptr;
// Borra las referencias a los punteros
renderer = nullptr;
asset = nullptr;
input = nullptr;
delete mEventHandler;
mEventHandler = nullptr;
// Libera la memoria de los objetos
delete scoreboard;
delete itemTracker;
delete roomTracker;
delete room;
delete player;
delete eventHandler;
delete text;
mTextureText->unload();
delete mTextureText;
mTextureText = nullptr;
JA_DeleteMusic(music);
JA_DeleteSound(deathSound);
delete mScreen;
mScreen = nullptr;
delete mRoom;
mRoom = nullptr;
delete mText;
mText = nullptr;
delete mFade;
mFade = nullptr;
delete test;
}
// Inicializa las variables necesarias para la sección 'Game'
void Game::init()
// Comprueba los eventos de la cola
void Game::checkEventHandler()
{
// Carga los recursos
loadMedia();
// 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;
screen->setBorderColor(stringToColor("black"));
break;
}
else if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0))
{
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_TITLE;
break;
mTicks = 0;
mTicksSpeed = 15;
case SDL_SCANCODE_D:
debug->switchEnabled();
player->setInvincible(debug->getEnabled());
board.music = !debug->getEnabled();
board.music ? JA_ResumeMusic() : JA_PauseMusic();
break;
mSection.name = SECTION_PROG_GAME;
mSection.subsection = SECTION_GAME_PLAY;
}
case SDL_SCANCODE_M:
board.music = !board.music;
board.music ? JA_ResumeMusic() : JA_PauseMusic();
break;
// Carga los recursos necesarios para la sección 'Game'
bool Game::loadMedia()
{
bool success = true;
case SDL_SCANCODE_F:
screen->switchVideoMode();
reLoadTextures();
break;
// Texturas
success &= loadTextureFromFile(mTextureText, mAsset->get("smb2.png"), mRenderer);
case SDL_SCANCODE_F1:
screen->setWindowSize(1);
reLoadTextures();
break;
return success;
case SDL_SCANCODE_F2:
screen->setWindowSize(2);
reLoadTextures();
break;
case SDL_SCANCODE_F3:
screen->setWindowSize(3);
reLoadTextures();
break;
case SDL_SCANCODE_F4:
screen->setWindowSize(4);
reLoadTextures();
break;
default:
break;
}
}
}
}
// Bucle para el juego
section_t Game::run()
{
init();
JA_PlayMusic(music);
if (!board.music)
{
JA_PauseMusic();
}
while (mSection.name == SECTION_PROG_GAME)
while (section.name == SECTION_PROG_GAME)
{
// Sección juego jugando
if (mSection.subsection == SECTION_GAME_PLAY)
if (section.subsection == SUBSECTION_GAME_PLAY)
{
update();
draw();
render();
}
}
return mSection;
JA_StopMusic();
return section;
}
// Actualiza el juego, las variables, comprueba la entrada, etc.
void Game::update()
{
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
if (SDL_GetTicks() - mTicks > mTicksSpeed)
if (SDL_GetTicks() - ticks > ticksSpeed)
{
// Actualiza el contador de ticks
mTicks = SDL_GetTicks();
ticks = SDL_GetTicks();
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(mEventHandler) != 0)
{
// Evento de salida de la aplicación
if (mEventHandler->type == SDL_QUIT)
{
mSection.name = SECTION_PROG_QUIT;
break;
}
}
// Comprueba los eventos de la cola
checkEventHandler();
checkInput();
mRoom->update();
// Actualiza los objetos
debug->clear();
room->update();
player->update();
checkPlayerOnBorder();
checkPlayerAndItems();
checkPlayerAndEnemies();
scoreboard->update();
updateDebugInfo();
}
}
// Pinta los objetos en pantalla
void Game::draw()
void Game::render()
{
// Prepara para dibujar el frame
const color_t color = {0xAA, 0x55, 0x55};
mScreen->start();
mScreen->clean(color);
mScreen->clean(mRoom->getBGColor());
screen->start();
screen->clean(room->getBGColor());
mRoom->drawMap();
mRoom->drawEnemies();
room->renderMap();
room->renderEnemies();
room->renderItems();
player->render();
renderRoomName();
scoreboard->render();
// Texto en el centro de la pantalla
mText->writeCentered(GAMECANVAS_CENTER_X, 18 * 8, mRoom->getName());
// Debug info
renderDebugInfo();
// test->render();
// Actualiza la pantalla
mScreen->blit();
screen->blit();
}
// Comprueba la entrada
void Game::checkInput()
// Pasa la información de debug
void Game::updateDebugInfo()
{
if (mInput->checkInput(INPUT_UP, REPEAT_FALSE))
changeRoom(mRoom->getRoomUp());
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));
}
if (mInput->checkInput(INPUT_DOWN, REPEAT_FALSE))
changeRoom(mRoom->getRoomDown());
// Pone la información de debug en pantalla
void Game::renderDebugInfo()
{
if (!debug->getEnabled())
{
return;
}
if (mInput->checkInput(INPUT_LEFT, REPEAT_FALSE))
changeRoom(mRoom->getRoomLeft());
// 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);
if (mInput->checkInput(INPUT_RIGHT, REPEAT_FALSE))
changeRoom(mRoom->getRoomRight());
// Pinta la rejilla
/*SDL_SetRenderDrawColor(renderer, 255, 255, 255, 32);
for (int i = 0; i < PLAY_AREA_BOTTOM; i += 8)
{ // Lineas horizontales
SDL_RenderDrawLine(renderer, 0, i, PLAY_AREA_RIGHT, i);
}
for (int i = 0; i < PLAY_AREA_RIGHT; i += 8)
{ // Lineas verticales
SDL_RenderDrawLine(renderer, i, 0, i, PLAY_AREA_BOTTOM - 1);
}*/
// Pinta el texto
debug->setPos({1, 18 * 8});
debug->render();
}
// Escribe el nombre de la pantalla
void Game::renderRoomName()
{
// Texto en el centro de la pantalla
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2};
color_t color = stringToColor("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
@@ -154,17 +261,89 @@ bool Game::changeRoom(std::string file)
// En las habitaciones los limites tienen la cadena del fichero o un 0 en caso de no limitar con nada
if (file != "0")
// Verifica que exista el fichero que se va a cargar
if (mAsset->get(file) != "")
if (asset->get(file) != "")
{
// Elimina la habitación actual
delete mRoom;
mRoom = nullptr;
delete room;
room = nullptr;
// Crea un objeto habitación nuevo a partir del fichero
mRoom = new Room(mAsset->get(file), mRenderer, mAsset);
room = new Room(asset->get(file), renderer, screen, asset, itemTracker, &board.items, debug);
// Actualiza el marcador
if (roomTracker->addRoom(file))
{
board.rooms++;
}
// Pasa la nueva habitación al jugador
player->setRoom(room);
success = true;
}
return success;
}
// Comprueba si el jugador esta en el borde de la pantalla
void Game::checkPlayerOnBorder()
{
if (player->getOnBorder())
{
const std::string room_name = room->getRoom(player->getBorder());
if (changeRoom(room_name))
{
player->switchBorders();
currentRoom = room_name;
spawnPoint = player->getSpawnParams();
}
}
}
// Comprueba las colisiones del jugador con los enemigos
bool Game::checkPlayerAndEnemies()
{
const bool death = room->enemyCollision(player->getCollider());
if (death)
{
killPlayer();
}
return death;
}
// Comprueba las colisiones del jugador con los objetos
void Game::checkPlayerAndItems()
{
room->itemCollision(player->getCollider());
}
// Mata al jugador
void Game::killPlayer()
{
if (player->getInvincible())
{
return;
}
board.lives--;
// Destruye la habitacion y el jugador
delete room;
delete player;
// Sonido
JA_PlaySound(deathSound);
// Crea la nueva habitación y el nuevo jugador
room = new Room(asset->get(currentRoom), renderer, screen, asset, itemTracker, &board.items, debug);
player = new Player(spawnPoint, asset->get("player.png"), asset->get("player.ani"), renderer, asset, input, room, debug);
}
// Recarga todas las texturas
void Game::reLoadTextures()
{
player->reLoadTexture();
room->reLoadTexture();
scoreboard->reLoadTexture();
text->reLoadTexture();
}

View File

@@ -1,20 +1,21 @@
#pragma once
#include "ifdefs.h"
#include "const.h"
#include "utils.h"
#include <SDL2/SDL.h>
#include "utils.h"
#include "sprite.h"
#include "movingsprite.h"
#include "animatedsprite.h"
#include "text.h"
#include "writer.h"
#include "menu.h"
#include "input.h"
#include "fade.h"
#include "lang.h"
#include "screen.h"
#include "asset.h"
#include "room.h"
#include "item_tracker.h"
#include "room_tracker.h"
#include "player.h"
#include "jail_audio.h"
#include "scoreboard.h"
#include "debug.h"
#include "test.h"
#ifndef GAME_H
#define GAME_H
@@ -23,41 +24,68 @@
class Game
{
private:
SDL_Renderer *mRenderer; // El renderizador de la ventana
SDL_Event *mEventHandler; // Manejador de eventos
Screen *mScreen; // Objeto encargado de manejar el renderizador
Room *mRoom; // Objeto encargado de gestionar cada habitación del juego
Asset *mAsset; // Objeto con la ruta a todos los ficheros de recursos
Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas
Input *mInput; // Objeto pata gestionar la entrada
Text *mText; // Objeto para los textos del juego
Fade *mFade; // Objeto para renderizar fades
LTexture *mTextureText; // Textura para la fuente de texto
Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa
Uint8 mTicksSpeed; // Velocidad a la que se repiten los bucles del programa
section_t mSection; // Seccion actual dentro del juego
// Inicializa las variables
void init();
// Carga los recursos
bool loadMedia();
SDL_Renderer *renderer; // El renderizador de la ventana
SDL_Event *eventHandler; // Manejador de eventos
Screen *screen; // Objeto encargado de manejar el renderizador
Room *room; // Objeto encargado de gestionar cada habitación del juego
Player *player; // Objeto con el jugador
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
RoomTracker *roomTracker; // Lleva el control de las habitaciones visitadas
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada
Text *text; // Objeto para los textos del juego
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
JA_Music music; // Musica que suena durante el juego
Debug *debug; // Objeto para gestionar la información de debug
int ticks; // Contador de ticks para ajustar la velocidad del programa
int ticksSpeed; // Velocidad a la que se repiten los bucles del programa
section_t section; // Seccion actual dentro del juego
std::string currentRoom; // Fichero de la habitación actual
player_t spawnPoint; // Lugar de la habitación donde aparece el jugador
Uint32 clock; // Cuenta el tiempo que dura la partida
JA_Sound deathSound; // Sonido a reproducir cuando muere el jugador
board_t board; // Estructura con los datos del marcador
Test *test;
// Actualiza el juego, las variables, comprueba la entrada, etc.
void update();
// Pinta los objetos en pantalla
void draw();
void render();
// Comprueba la entrada
void checkInput();
// Comprueba los eventos de la cola
void checkEventHandler();
// Pone la información de debug en pantalla
void updateDebugInfo();
// Pone la información de debug en pantalla
void renderDebugInfo();
// Escribe el nombre de la pantalla
void renderRoomName();
// Cambia de habitación
bool changeRoom(std::string file);
// Comprueba si el jugador esta en el borde de la pantalla y actua
void checkPlayerOnBorder();
// Comprueba las colisiones del jugador con los enemigos
bool checkPlayerAndEnemies();
// Comprueba las colisiones del jugador con los objetos
void checkPlayerAndItems();
// Mata al jugador
void killPlayer();
// Recarga todas las texturas
void reLoadTextures();
public:
// Constructor
Game(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Lang *lang, Input *input);
Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Debug *debug);
// Destructor
~Game();

View File

@@ -1,13 +0,0 @@
#include <SDL2/SDL.h>
#ifdef __APPLE__
#include "/Library/Frameworks/SDL2.framework/Versions/A/Headers/SDL.h"
#endif
#ifdef __linux__
#ifdef __MIPSEL__
#include "SDL.h"
#else
#include <SDL2/SDL.h>
#endif
#endif

View File

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

View File

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

239
source/intro.cpp Normal file
View File

@@ -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;
}

70
source/intro.h Normal file
View File

@@ -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

81
source/item.cpp Normal file
View File

@@ -0,0 +1,81 @@
#include "item.h"
#include <fstream>
#include <sstream>
// Constructor
Item::Item(item_t item)
{
// Obten punteros a objetos
asset = item.asset;
renderer = item.renderer;
// Crea objetos
texture = new LTexture(renderer, asset->get(item.tileset));
sprite = new Sprite(item.x, item.y, 8, 8, texture, renderer);
// Inicia variables
sprite->setSpriteClip(item.tile * 8, 0, 8, 8);
collider = sprite->getRect();
colorChangeSpeed = 4;
counter = item.counter * colorChangeSpeed;
// Inicializa los colores
color_t c = stringToColor("blue");
color.push_back(c);
c = stringToColor("red");
color.push_back(c);
c = stringToColor("magenta");
color.push_back(c);
c = stringToColor("green");
color.push_back(c);
c = stringToColor("cyan");
color.push_back(c);
c = stringToColor("yellow");
color.push_back(c);
}
// Destructor
Item::~Item()
{
delete texture;
delete sprite;
}
// Pinta el objeto en pantalla
void Item::render()
{
const int index = (counter / colorChangeSpeed) % color.size();
sprite->getTexture()->setColor(color[index].r, color[index].g, color[index].b);
sprite->render();
sprite->getTexture()->setColor(255, 255, 255);
}
// Actualiza las variables del objeto
void Item::update()
{
counter++;
}
// Obtiene el rectangulo de colision del objeto
SDL_Rect &Item::getCollider()
{
return collider;
}
// Obtiene su ubicación
SDL_Point Item::getPos()
{
const SDL_Point p = {sprite->getPosX(), sprite->getPosY()};
return p;
}
// Recarga la textura
void Item::reLoadTexture()
{
texture->reLoad();
}

Some files were not shown because too many files have changed in this diff Show More