Compare commits

...

131 Commits

Author SHA1 Message Date
944784b329 Actualizado el número de versión 2024-02-22 16:58:16 +01:00
df4c1366fe Corregidos dos pequeños errores de sintaxis 2024-02-15 13:18:33 +01:00
1ee1ea560b Aumentado el tiempo que se muestra la pantalla de carga.
Posibilidad de saltar la pantalla ya cargada en el menu de titulo
2024-02-07 18:51:00 +01:00
5c7f72253c El gamestate_title ya puede empezar en diferentes estados 2024-02-07 18:34:19 +01:00
e2e41cf435 Arreglada la separación entre el titulo y el fade 2024-02-07 17:22:22 +01:00
674323d445 Commit de antes de cambiar experimentalmente muchas cosas 2024-02-07 16:52:21 +01:00
f4e2c11f1b Actualizados los ficheros gráficos del titulo 2024-02-07 16:01:16 +01:00
1b130feb85 Corregido bug en el fade de paleta. El color azul no se propagaba 2024-02-07 15:55:49 +01:00
5f3ecbbd79 Ya funciona el fade de la pantalla de carga 2024-02-07 18:48:53 +01:00
250efd69bf Ya se dibuja correctamente el gif en la pantalla 2024-02-07 17:45:22 +01:00
7cd5fec3f8 Modificado el tamaño del gif 2024-02-07 17:02:13 +01:00
8e612aaa2e Ya se dibuja el gif en pantalla 2024-02-07 16:59:25 +01:00
2d045642ff Añadidos paleta.cpp y paleta.h 2024-02-07 16:00:23 +01:00
01dff96fdc Añadido gif.c 2024-02-07 15:49:14 +01:00
62d1a566c0 Añadida nueva imagen para gestionar el fade de la pantalla de carga 2024-02-07 14:01:00 +01:00
39016a3912 Modificado el menu para que sea mas claro qué modo online está seleccionado 2024-02-07 13:46:50 +01:00
866cb56f1b Se establece el online deshabilitado por defecto al crear el fichero de configuración 2024-02-07 13:29:40 +01:00
6de3050255 Se me ha ocurrido y lo he hecho antes que nadie: poner prefijo a los .cpp i .h que definen cada uno de los estados del juego 2023-10-10 17:46:02 +02:00
f602b5ff7a FIX: No se estaba haciendo jscore::init, pero todo funcionaba correctamente 2023-10-09 23:11:25 +02:00
c34b4d8944 La sección del título se termina al pasar cierto tiempo, no cuando se termina la marquesina 2023-10-09 22:56:43 +02:00
c835f943b5 Ya gestiona correctamente los datos online para diferentes usuarios 2023-10-09 22:20:34 +02:00
9b265c6cca Intentando guardar las estadisticas y logros online. Algo hay MUY MAL y no se que es. Ya lo miraré con calma. 2023-10-09 15:28:51 +02:00
6a526df9b3 Finalizada la clase Online
Eliminado de director la parte que ejecutaba el enter_id
2023-10-09 13:47:36 +02:00
3def97bcb8 Empezada la clase Online para la gestión de los datos almacenados en el servidor 2023-10-09 13:01:39 +02:00
0a07edcb5c Modificado gitignore 2023-10-09 12:36:05 +02:00
62d90a605f Modificada la fuente subatomic
Modificado el aspecto y el comportamiento del menu de logros
2023-10-09 10:25:36 +02:00
d718e20767 Añadida fuente subatomic 2023-10-09 09:34:14 +02:00
20c63c7ef5 Añadida función para pasar cadenas a mayúsculas 2023-10-09 09:02:44 +02:00
a68ffa8e21 Los menus ya reflejan el cambio de usuario online 2023-10-09 08:49:21 +02:00
693939a6d5 Cambiado el tamaño del texto JAILDOCTOR'S en la pantalla de carga 2023-10-09 08:21:39 +02:00
031e4b99f4 Cambiada la tipografía del menu 2023-10-08 22:16:56 +02:00
1a095d292f Modificados los colores de enter_id 2023-10-08 22:14:33 +02:00
d51d564642 Mejorada la apariencia visual de la lista de logros 2023-10-08 22:13:06 +02:00
bafde2a778 Las entradas de teclado del menu de titulo ya funcionan correctamente 2023-10-08 21:13:10 +02:00
7dcc1d7809 El menu ya es funcional, com mucho margen de mejora 2023-10-08 21:07:06 +02:00
38aadb984d Ya dibuja el nuevo menu. Falta pulir un par de cosas en el dibujado 2023-10-08 16:17:47 +02:00
e259313cc9 Añadida fuente gauntlet 2023-10-08 15:16:51 +02:00
c49323cfdf Añadido efectos en el borde para imitar la carga de la pantalla como en el spectrum 2023-10-08 14:24:18 +02:00
619acbc9b4 Ya se puede dibujar en el borde. Útil para poner wallpapers o cualquier otro efectillo 2023-10-08 12:14:54 +02:00
e39806f1a3 Añadidos los graficos de la nueva pantalla de carga 2023-10-08 11:07:02 +02:00
e2618f40db Añadido versión del juego en la pantalla de titulo 2023-10-03 23:42:46 +02:00
97a6ba474f Actualizado README.md 2023-10-03 23:27:28 +02:00
07054544e4 Actualizado info.plist 2023-10-03 23:23:43 +02:00
99f6ea7dd4 Modificado MAKEFILE 2023-10-03 23:22:40 +02:00
45b75dc75f Modificado el fichero de licencia 2023-10-03 23:21:51 +02:00
a4fd00794d Ya se puede modificar el JailerID desde la pantalla de titulo, aunque hay que pulirlo un poco 2023-10-03 23:18:56 +02:00
ee261f4509 Las notificaciones simultaneas aparecen de forma escalonada 2023-10-03 21:48:24 +02:00
eb713006c6 Corregido el orden de ejecución update-checkEvents-render en todas las secciones del juego para evitar que el juego tarde en actualizarse cuando hay muchos eventos 2023-09-19 20:28:48 +02:00
a07eeff6e4 Fix: la variable showCheevos no se inicializaba correctamente 2023-09-17 17:09:43 +02:00
cce0ccba76 Añadidos std:: a title.cpp 2023-09-16 16:54:07 +02:00
0ea7eb0b9c Revert "Eliminados todos los std:: del código"
This reverts commit 4a2d27dc59.
2023-09-16 16:44:15 +02:00
4a2d27dc59 Eliminados todos los std:: del código 2023-09-16 12:44:40 +02:00
71be364141 Acabada la primera versión de la lista de logros 2023-09-16 12:29:52 +02:00
16cc725cb3 Terminado el desplazamiento por la lista de logros 2023-09-16 11:02:56 +02:00
a05dbc7581 Ya es posible desplazarse de forma prematura por la lista de logros 2023-09-15 23:02:42 +02:00
2db0b43d23 Mejoras en la presentación de la lista de logros 2023-09-15 22:33:59 +02:00
d6c100379e La pantalla de titulo ya no acaba cuando termina la marquesina si la lista de logros está activa 2023-09-15 22:00:52 +02:00
22e8579337 Ya muestra la lista de logros de forma preliminar 2023-09-15 21:31:23 +02:00
d0c0715640 Añadido: la clase cheevos devuelve una lista de los logros 2023-09-15 17:05:00 +02:00
38e0573a0e Fix: Guarda los logros también cuando se desbloquean 2023-09-15 17:00:32 +02:00
f259fbb3a5 Actualizado gitignore 2023-09-15 16:27:47 +02:00
663e1ed32e Añadida barra de información en el titulo 2023-09-15 11:44:51 +02:00
b1887fe6da Fix: No se limpiaba la pantalla tras entrar el JailerID 2023-09-15 07:45:21 +02:00
3fcf3b23e0 Actualizado .gitignore 2023-05-06 18:52:54 +02:00
284f7d5bad Cambiada la carpeta common a jail_engine 2023-05-06 18:06:29 +02:00
adab0b420c - Modificada la carpeta de guardar datos al estandar de jailgames 2023-02-12 18:05:53 +01:00
4f9d8bec42 - Cambiados los textos de los creditos/instrucciones para reflejar las nuevas teclas
- Cambiados los textos de los creditos/instrucciones para la versión de consola
2023-02-12 17:44:00 +01:00
31e657d138 - Cambiadas las teclas de cambiar el tamaño de ventana para adecuarse al estandar de jailgames 2023-02-12 17:28:48 +01:00
8b3d257baf - La ventana ya no se destruye al cambiar de tamaño de ventana
- La ventana aparece centrada al cambiar de tamaño
2023-02-12 17:05:16 +01:00
d1143b9dfe - Trabajando en la creación y destrucción de la ventana
- FIX: la clase screen no liberaba la textura gameCanvas al finalizar
2023-02-10 22:55:36 +01:00
68ebff722e - FIX: cambiado el boton de guía por el de select (o back)
- Añadido flag para intercambiar los botones de start y select en consola
- Añadido botón para activar o desactivar el borde con el mando (botón X)
2023-02-10 20:31:37 +01:00
3be9d4459c - Ya se puede usar el mando en todas las secciones del juego
- Definido flag para compilar para consola de juegos (GAME_CONSOLE)
2023-02-10 20:08:06 +01:00
76e928e21d Commit para seguir programando en WSL 2023-02-10 19:07:19 +01:00
9c6924d7bb - La clase input ya admite inputs personalizados
- El juego ya utiliza el objeto input para comprobar las teclas de cambio de tamaño de ventana, pausa, etc.
2023-02-10 18:28:53 +01:00
5007bea835 Se había quedado una linea comentada 2023-01-09 09:21:22 +01:00
5e7be1c2fb Ya se guardan los logros en un fichero 2023-01-02 09:46:09 +01:00
faf2e69b63 Creando iconos para las notificaciones 2022-12-30 13:18:43 +01:00
4c3c844ccf Fix: En la secuencia del final, al pulsar ESC se cerraba el juego. Ahora vuelve al logo 2022-12-29 15:26:02 +01:00
48b8ae049a Testeados todos los logros. Los logros no funcionan con los trucos activados 2022-12-29 14:59:48 +01:00
c0d4eddde7 Colocados los disparadores de los logros en su sitio 2022-12-29 14:08:42 +01:00
f590101047 Definidos los logros 2022-12-29 13:03:10 +01:00
c7fcbd0258 Añadidos nuevos iconos para las notificaciones. Rediseñada la notificación de login. Arreglado bug: No se podia elegir un icono para las notificaciones que no fuera de la primera fila 2022-12-29 11:58:32 +01:00
b2061c86d2 Cambiado el tamaño de las notificaciones. Posibilidad de añadir un icono 2022-12-29 11:36:44 +01:00
510a6ca718 Añadido bisel a las notificaciones 2022-12-29 11:00:26 +01:00
ec8209265a Añadidos iconos a las notificaciones 2022-12-29 10:19:11 +01:00
e963251fd9 Modificadas las notificaciones a dos lineas de texto 2022-12-29 09:42:57 +01:00
a2f1efd2a6 Empezando a trabajar con los logros 2022-12-29 09:09:36 +01:00
8959b7bcce Arreglado el cambio de paleta durante la pantalla de carga optimizada 2022-12-16 11:15:13 +01:00
4d8bb46a52 Cambiada la variable section por un puntero 2022-12-16 09:32:33 +01:00
2abde36a5e Actualizadas las etiquetas a la versión 1.07 2022-12-02 19:16:00 +01:00
0a083af712 El nombre de la habitación se pinta a partir de una textura 2022-12-02 09:35:49 +01:00
f322b1b81b Eliminada una variable static que no se utilizaba 2022-12-01 22:36:41 +01:00
13fe98edb3 Arreglado un poco el metodo de apertura de la Jail 2022-12-01 22:27:23 +01:00
c90b49c8be Añadido Batman a FEEL THE HEAT 2022-12-01 22:14:51 +01:00
d3a5c0e54f Cambiado el tamaño de la textura usado para pintar el mapa 2022-12-01 22:07:03 +01:00
254ff50ef3 Merge branch 'master' of https://gitea.sustancia.synology.me/JailDesigner/jaildoctors_dilemma 2022-12-01 22:05:05 +01:00
e551206351 Actualizado el cielo de la Jail 2022-12-01 22:04:47 +01:00
b22e830dac Merge branch 'master' of https://gitea.sustancia.synology.me/JailDesigner/jaildoctors_dilemma 2022-12-01 21:05:37 +01:00
a81d42cb25 Corregido bug: en la jail se rellenaban las vidas mientras estaba activa la pausa 2022-12-01 21:05:34 +01:00
3ea0025fb4 Retocada la pantalla de titulo 2022-12-01 21:03:12 +01:00
d7c49a0578 Modificado el sprite de PACO 2022-12-01 20:15:34 +01:00
4cbe55c2d4 Actualizado jail_audio a la última versión 2022-12-01 19:51:53 +01:00
564f316586 Cambiado el nombre del enemigo diskette a floppy 2022-12-01 19:32:59 +01:00
522ab8e726 Cambios cosméticos en algunas habitaciones. Cambiado el nombre de STATIC a BE CAREFUL WITH THE FUSE 2022-12-01 19:31:35 +01:00
4911282777 El color de fondo de la habitación se pinta en la textura del mapa 2022-12-01 11:40:35 +01:00
06ecabc676 Corregido un "memory leak" en texture.cpp 2022-12-01 10:43:58 +01:00
5d89a3057e Optimizado un poco el title.cpp 2022-11-30 13:43:47 +01:00
75228cc451 Eliminado el resto de accesos a vector mediante at() 2022-11-30 12:09:45 +01:00
357eec20b1 Eliminados la mayor parte de accesos a vector mediante at() 2022-11-30 12:03:37 +01:00
62c1e2715e Preparando el juego para ser compatble con consolas 2022-11-30 11:06:27 +01:00
34fc2b6b06 Optimizada la intro 2022-11-30 10:10:10 +01:00
6557dea2bb Merge branch 'master' of https://gitea.sustancia.synology.me/JailDesigner/jaildoctors_dilemma 2022-11-30 08:27:11 +01:00
2caea7ba6e Optimizando la intro 2022-11-30 08:26:16 +01:00
d33d2e4a09 Cambiado el nombre de algunos enemigos 2022-11-29 21:26:28 +01:00
d9174dcdb9 Cambiado el nombre de algunos enemigos 2022-11-29 21:08:33 +01:00
22f7204e08 Añadidas mas dll para el release de windows 2022-11-29 19:41:14 +01:00
06fab0d457 Actualizado Makefile 2022-11-29 19:16:14 +01:00
f180f88068 Corregido error en el texto de las teclas nuevas para moverse 2022-11-29 19:12:04 +01:00
4109d6c938 Actualizado Readme.md. Cambiado LICENSE a LICENSE.txt 2022-11-29 19:11:02 +01:00
9c2264ca75 Actualizado Makefile 2022-11-29 19:07:59 +01:00
c59739c7ba Cambiado el tamaño del borde de porcentaje a valor absoluto en pixeles 2022-11-29 18:45:25 +01:00
4a430c0d5b Actualizadas las instrucciones con el método de control escogido 2022-11-29 18:22:40 +01:00
5a7f637f4b Cambiada la tecla de pausa a la tecla H (HOLD) 2022-11-29 18:07:31 +01:00
c63298b555 Posibilidad de escoger diferentes configuraciónes prefijadas de teclas de control desde el fichero de configuración 2022-11-29 18:05:38 +01:00
82aa91bead Corregida la funcion para verificar si existen los ficheros de recursos 2022-11-29 17:29:18 +01:00
f4129e109a Actualizado Makefile 2022-11-29 17:25:08 +01:00
5e8714697d Añadido un tile para poder bajar en la fase ULA HOP! 2022-11-29 17:23:12 +01:00
dd4355051f Merge branch 'master' of https://gitea.sustancia.synology.me/JailDesigner/jaildoctors_dilemma 2022-11-28 09:01:22 +01:00
160b212a43 Actualizado info.plist 2022-11-28 09:01:21 +01:00
69d3b076d7 Modificadas algunas fases para prevenir glitches 2022-11-28 07:53:07 +01:00
3817a01712 Guardado de las opciones de las notificaciones 2022-11-24 12:55:34 +01:00
156 changed files with 5193 additions and 2633 deletions

5
.gitignore vendored
View File

@@ -10,4 +10,7 @@ thumbs.db
*.tar.gz
*.zip
*.app
*_debug*
*_debug*
sync_jail_engine.sh
jaildoctors_dilemma*
todo

233
LICENSE
View File

@@ -1,232 +1 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for software and other kinds of works.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
“This License” refers to version 3 of the GNU General Public License.
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
A “covered work” means either the unmodified Program or a work based on the Program.
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
GNU General Public License v3.0 only

View File

@@ -1,8 +1,8 @@
executable = jaildoctors_dilemma
source = source/*.cpp source/common/*.cpp
source = source/*.cpp source/jail_engine/*.cpp
appName = JailDoctor's Dilemma
releaseFolder = jdd_release
version = v1.06.1
version = v1.08
# Release names
windowsRelease = $(executable)-$(version)-win32-x64.zip
@@ -35,7 +35,7 @@ windows_release:
# Copy root files
powershell Copy-Item "LICENSE" -Destination "$(releaseFolder)"
powershell Copy-Item "README.md" -Destination "$(releaseFolder)"
powershell Copy-Item "release\SDL2.dll" -Destination "$(releaseFolder)"
powershell Copy-Item "release\*.dll" -Destination "$(releaseFolder)"
# Build
g++ $(source) -std=c++11 -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(releaseFolder)/$(executable).exe"
@@ -83,6 +83,9 @@ macos_release:
cp LICENSE "$(releaseFolder)"
cp README.md "$(releaseFolder)"
# Create links
ln -s /Applications "$(releaseFolder)"/Applications
# Build INTEL
clang++ $(source) -D MACOS_BUNDLE -std=c++11 -Wall -Os -framework SDL2 -F ./Frameworks -ffunction-sections -fdata-sections -o "$(releaseFolder)/$(appName).app/Contents/MacOS/$(executable)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12

View File

@@ -1,4 +1,4 @@
# JailDoctor's Dilemma (v1.06.1)
# JailDoctor's Dilemma
JailDoc es un Jailer. A los Jailers les gusta empezar proyectos. A nadie le gusta terminarlos. Los Jailers viven en la Jail. A la Jail va uno a empezar proyectos. A la Jail va uno a enseñar sus proyectos. A la Jail va uno a aprender como empezar nuevos proyectos. A la Jail va uno a ayudar a sus compañeros a que empiecen nuevos proyectos.
@@ -40,7 +40,7 @@ El juego permite tanto el uso del teclado como de un mando de control. Las tecla
- **Cursores**: Para mover a izquierda o derecha a JailDoc y para saltar
- **Cursores**: Para mover a izquierda o derecha a JailDoc y para saltar. En el fichero de configuración se pueden cambiar las teclas por otras opciones prefijadas: O, P para moverse y Q para saltar o A, D para moverse y W para saltar.
- **Tecla M**: Activa o desactiva la música
@@ -48,9 +48,13 @@ El juego permite tanto el uso del teclado como de un mando de control. Las tecla
- **Tecla ESC**: Sale del juego si estas jugando. Sale del programa en cualquier otra circunstancia
- **Tecla F**: Cambia a modo de pantalla completa o de ventana
- **Tecla F1**: Disminuye el tamaño de la ventana
- **Teclas F1 a F4**: Cambian el tamaño de la ventana
- **Tecla F2**: Aumenta el tamaño de la ventana
- **Tecla F3**: Cambia entre el modo de pantalla completa y el de ventana
- **Tecla F5**: Cambia la paleta de colores del juego
- **Tecla B**: Activa o desactiva el borde de colores de la pantalla cuando el programa se ejecuta en modo de ventana
@@ -62,15 +66,13 @@ El juego permite tanto el uso del teclado como de un mando de control. Las tecla
El programa guarda automáticamente la configuración del modo de video y las estadísticas de juego en tu carpeta personal del sistema. Esta carpeta tiene una ubicación distinta en función del sistema operativo que utilices.
En **Windows** se encuentra en:
`C:\Users\<nombre_de_usuario>\AppData\Roaming\jaildoctors_dilemma`
`C:\Users\<nombre_de_usuario>\AppData\Roaming\jailgames\jaildoctors_dilemma`
En **MacOS** se encuentra en:
`~/Library/Application Support/jaildoctors_dilemma`
`~/Library/Application Support/jailgames/jaildoctors_dilemma`
En **Linux** se encuentra en:
`~/.jaildoctors_dilemma`
La primera vez, el juego te pregunta por tu identificador online. Esta información se guarda para futuras partidas.
`~/./jailgames/jaildoctors_dilemma`
En la carpeta está el fichero de configuración `config.txt` donde se puede modificar la configuración para conectarse al servicio online y los ficheros `stats.csv` y `stats_buffer.csv` con información de las estadisticas de juego.
@@ -78,10 +80,10 @@ En la carpeta está el fichero de configuración `config.txt` donde se puede mod
Agradecimientos como siempre a todos los Jailers por motivarme a hacer el juego y ayudarme en los momentos de duda a la hora de escribir el código. Y, como siempre, en especial a JailDoc por su unidad de Jail_Audio y cualquier otro código/ayuda/enseñanzas que haya necesitado para terminar el programa.
Si no me he descontado, este es el cuarto juego que consigo crear.
*13 de noviembre de 2022, JailDesigner*

View File

Before

Width:  |  Height:  |  Size: 310 B

After

Width:  |  Height:  |  Size: 310 B

View File

Before

Width:  |  Height:  |  Size: 271 B

After

Width:  |  Height:  |  Size: 271 B

View File

Before

Width:  |  Height:  |  Size: 122 B

After

Width:  |  Height:  |  Size: 122 B

View File

Before

Width:  |  Height:  |  Size: 205 B

After

Width:  |  Height:  |  Size: 205 B

View File

Before

Width:  |  Height:  |  Size: 189 B

After

Width:  |  Height:  |  Size: 189 B

View File

Before

Width:  |  Height:  |  Size: 351 B

After

Width:  |  Height:  |  Size: 351 B

View File

Before

Width:  |  Height:  |  Size: 323 B

After

Width:  |  Height:  |  Size: 323 B

View File

Before

Width:  |  Height:  |  Size: 378 B

After

Width:  |  Height:  |  Size: 378 B

View File

@@ -3,7 +3,7 @@ frameHeight=16
[animation]
name=default
speed=8
speed=4
loop=0
frames=0,1,2,3
frames=0,1,2,3,4,5,6,7
[/animation]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

After

Width:  |  Height:  |  Size: 357 B

View File

Before

Width:  |  Height:  |  Size: 139 B

After

Width:  |  Height:  |  Size: 139 B

View File

Before

Width:  |  Height:  |  Size: 129 B

After

Width:  |  Height:  |  Size: 129 B

BIN
data/font/gauntlet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

194
data/font/gauntlet.txt Normal file
View File

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

BIN
data/font/subatomic.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

194
data/font/subatomic.txt Normal file
View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -9,8 +9,8 @@ roomLeft=0
roomRight=02.room
[enemy]
tileSetFile=jailer.png
animation=jailer.ani
tileSetFile=jailer_#1.png
animation=jailer_#1.ani
width=16
height=16
x=1
@@ -25,8 +25,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=jailer3.png
animation=jailer3.ani
tileSetFile=jailer_#3.png
animation=jailer_#3.ani
width=16
height=16
x=4
@@ -41,8 +41,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=jailer.png
animation=jailer.ani
tileSetFile=jailer_#1.png
animation=jailer_#1.ani
width=16
height=16
x=7
@@ -57,8 +57,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=jailer2.png
animation=jailer2.ani
tileSetFile=jailer_#2.png
animation=jailer_#2.ani
width=16
height=16
x=10
@@ -73,8 +73,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=jailer.png
animation=jailer.ani
tileSetFile=jailer_#1.png
animation=jailer_#1.ani
width=16
height=16
x=13
@@ -89,8 +89,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=printer.png
animation=printer.ani
tileSetFile=elsa.png
animation=elsa.ani
width=16
height=16
x=3
@@ -105,8 +105,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=printer.png
animation=printer.ani
tileSetFile=elsa.png
animation=elsa.ani
width=16
height=16
x=6

View File

@@ -3,9 +3,9 @@
<tileset firstgid="1" source="standard.tsx"/>
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
168,166,185,167,166,185,166,166,168,166,166,167,166,166,185,166,166,43,43,43,43,43,43,43,43,43,43,43,43,43,43,166,
211,181,211,213,211,181,211,212,213,211,181,211,211,212,211,213,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,

View File

@@ -1,6 +1,6 @@
name=ROAD TO THE JAIL
bgColor=black
border=cyan
border=blue
tileMapFile=02.tmx
tileSetFile=standard.png
roomUp=0

View File

@@ -3,22 +3,22 @@
<tileset firstgid="1" source="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,43,43,43,43,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,25,25,25,25,
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,135,0,0,0,
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,43,43,43,43,43,
43,166,166,167,168,166,185,167,166,185,166,166,168,166,166,167,166,166,185,166,166,166,185,167,166,166,166,185,25,25,25,25,
43,43,211,212,212,211,181,211,213,211,181,211,212,213,211,181,211,211,211,211,212,213,211,181,211,213,181,211,135,0,0,0,
43,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,135,0,0,0,
43,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,25,25,25,25,
34,34,304,0,0,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,
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,303,25,25,
34,34,0,0,0,0,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,
34,34,0,413,413,413,413,0,0,0,0,413,413,413,413,413,0,0,0,0,413,413,413,413,413,413,413,0,0,0,25,25,
34,34,0,413,413,413,413,0,0,0,0,413,304,413,413,413,0,0,0,0,413,304,413,413,413,413,304,0,0,0,25,25,
34,34,0,0,0,0,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,
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,387,25,25,
34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,411,25,25,
34,34,0,0,0,0,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,
34,34,389,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,387,25,25,
34,34,413,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,411,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,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,513,189,190,537,0,0,0,0,
34,34,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,191,0,0,189,190,189,190,189,190,189,190,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,524,189,191,548,0,0,0,0,
34,34,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,190,189,191,0,0,189,190,189,190,189,190,189,191,25,25
</data>
</layer>
</map>

View File

@@ -11,8 +11,8 @@ itemColor1=bright_green
itemColor2=green
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=15

View File

@@ -10,7 +10,7 @@
134,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
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,117,
25,0,0,0,0,0,0,0,0,0,0,417,417,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,
25,0,0,556,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,387,25,
25,0,0,556,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,25,
25,25,25,25,25,25,0,0,0,417,417,0,0,0,0,0,0,0,305,31,0,0,0,0,0,0,0,0,0,0,0,305,
0,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,417,417,0,0,0,0,0,0,
0,0,0,0,0,0,0,417,417,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,0,0,0,

View File

@@ -18,7 +18,7 @@
0,0,0,0,0,0,0,0,531,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,
0,0,0,0,0,0,0,0,0,531,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,
0,0,0,0,0,0,0,0,0,0,349,349,349,349,349,349,349,349,349,349,349,538,0,0,0,0,0,0,0,0,0,17,
0,0,0,0,0,0,0,0,0,0,0,0,0,41,41,41,41,349,349,349,349,349,349,349,349,349,349,0,0,349,349,349
563,563,563,563,563,563,563,563,563,563,0,0,0,41,41,41,41,349,349,349,349,349,349,349,349,349,349,0,0,349,349,349
</data>
</layer>
</map>

View File

@@ -11,8 +11,8 @@ itemColor1=red
itemColor2=magenta
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=9
@@ -27,8 +27,8 @@ color=green
[/enemy]
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=1

View File

@@ -9,13 +9,13 @@
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,0,
25,0,0,0,527,25,25,25,25,25,25,25,25,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,0,251,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,527,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,527,25,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,551,0,0,0,0,0,0,0,0,0,527,25,25,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,25,0,0,0,0,0,25,25,25,25,25,
25,25,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,251,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,395,395,395,395,395,371,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,0,0,0,0,0,0,0,
25,25,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,25,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,251,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,0,25,
0,0,0,0,395,395,395,395,395,371,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,0,0,0,0,0,0,25,
0,0,0,0,0,0,0,0,0,323,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
25,25,551,0,0,0,0,0,0,347,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,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

View File

@@ -30,7 +30,7 @@ flip=true
[enemy]
tileSetFile=bat.png
animation=bat.ani
width=9
width=8
height=7
x=14
y=2
@@ -46,7 +46,7 @@ color=bright_blue
[enemy]
tileSetFile=bat.png
animation=bat.ani
width=9
width=8
height=7
x=10
y=10
@@ -62,7 +62,7 @@ color=cyan
[enemy]
tileSetFile=bat.png
animation=bat.ani
width=9
width=8
height=7
x=15
y=1

View File

@@ -11,8 +11,8 @@ itemColor1=yellow
itemColor2=red
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=5
@@ -27,8 +27,8 @@ color=green
[/enemy]
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=12

View File

@@ -3,16 +3,16 @@
<tileset firstgid="1" source="standard.tsx"/>
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
5,5,5,5,5,5,5,5,5,5,5,0,0,0,506,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,
5,5,5,5,5,5,5,5,0,0,0,0,0,0,506,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,0,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,
5,5,5,5,5,5,5,0,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
5,5,5,5,5,5,5,0,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
5,5,5,5,5,5,5,0,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
0,0,0,0,0,0,134,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
0,0,0,0,0,0,134,0,415,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
5,5,5,5,173,0,134,0,0,506,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
557,557,557,557,557,557,134,0,415,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
5,5,5,5,5,5,5,415,415,415,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
5,5,5,5,5,5,5,0,0,0,0,530,0,0,0,0,0,0,449,449,449,449,449,449,449,449,449,449,449,449,449,5,
5,5,5,5,5,5,5,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
5,5,5,5,5,5,0,0,0,0,0,530,0,0,0,0,0,0,449,449,449,449,449,449,449,449,449,449,449,449,449,5,
5,5,5,5,5,0,0,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
0,0,0,0,0,0,0,0,0,0,0,0,0,530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,517,367,5,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,367,367,367,367,429,429,0,429,429,367,367,367,367,367,367,367,367,5,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,343,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,

View File

@@ -4,15 +4,15 @@
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,349,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,38,38,38,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,38,38,241,241,0,0,0,0,0,0,0,0,0,0,0,0,241,241,38,38,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,38,38,38,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188,
0,0,0,0,0,0,38,38,241,241,0,0,0,0,0,0,0,0,0,0,0,0,241,241,38,38,0,0,0,0,0,188,
0,0,0,0,0,38,38,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,38,38,0,0,0,0,0,
0,0,0,0,38,38,0,0,0,0,0,0,0,0,241,241,241,241,0,0,0,0,0,0,0,0,38,38,0,0,0,0,
0,0,0,0,38,0,0,0,0,0,0,241,241,0,0,0,0,0,0,241,241,0,0,0,0,0,0,38,0,0,0,0,

View File

@@ -9,8 +9,8 @@ roomLeft=26.room
roomRight=0
#[enemy]
#tileSetFile=diskette.png
#animation=diskette.ani
#tileSetFile=floppy.png
#animation=floppy.ani
#width=16
#height=16
#x=2

View File

@@ -3,17 +3,17 @@
<tileset firstgid="1" source="standard.tsx"/>
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,90,41,235,235,0,0,235,235,41,89,90,89,
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,90,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,235,0,0,0,0,0,0,
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,94,41,235,235,0,0,235,235,41,89,90,89,
89,94,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,214,215,0,0,0,0,0,0,0,0,214,89,90,
214,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,214,89,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,235,0,0,0,0,0,214,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,235,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,
94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
94,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,415,415,415,415,
94,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,415,415,415,415,
89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,0,
90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
89,90,89,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

View File

@@ -11,8 +11,8 @@ itemColor1=green
itemColor2=red
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=20

View File

@@ -15,7 +15,7 @@
116,0,0,0,377,377,377,0,0,0,0,0,0,115,114,115,114,0,0,0,0,0,377,377,377,377,0,0,0,0,140,116,
140,0,0,0,0,0,0,0,0,0,0,377,0,114,115,114,115,0,0,377,0,0,0,0,0,0,0,0,0,0,116,140,
116,0,0,0,0,0,0,0,0,0,0,0,0,115,114,115,114,0,0,0,0,0,0,0,0,0,431,432,114,115,140,116,
140,0,0,0,0,0,0,0,377,0,0,0,0,114,115,114,115,0,0,0,0,0,0,431,432,431,432,431,432,0,116,140,
140,0,0,0,0,0,0,377,377,0,0,0,0,114,115,114,115,0,0,0,0,0,0,431,432,431,432,431,432,0,116,140,
0,0,0,0,0,0,0,0,0,0,0,0,377,115,114,115,114,0,0,377,0,0,0,0,0,0,0,0,0,0,140,116,
0,0,0,0,0,0,0,0,0,0,0,0,0,114,115,114,115,0,0,0,0,0,0,0,0,0,0,0,0,0,116,140,
114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,114,115,0,0,114,115,114,115,114,115

View File

@@ -1,4 +1,4 @@
name=STATIC
name=BE CAREFUL WITH THE FUSE
bgColor=black
border=bright_cyan
tileMapFile=36.tmx

View File

@@ -9,8 +9,8 @@ roomLeft=39.room
roomRight=37.room
[enemy]
tileSetFile=arounder_stop.png
animation=arounder_stop.ani
tileSetFile=stopped_arounder.png
animation=stopped_arounder.ani
width=7
height=8
x=9
@@ -25,8 +25,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=arounder_stop.png
animation=arounder_stop.ani
tileSetFile=stopped_arounder.png
animation=stopped_arounder.ani
width=7
height=8
x=18
@@ -41,8 +41,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=12
@@ -75,8 +75,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_fly.png
animation=arounder_fly.ani
tileSetFile=flying_arounder.png
animation=flying_arounder.ani
width=7
height=7
x=3

View File

@@ -27,8 +27,8 @@ color=white
[/enemy]
[enemy]
tileSetFile=arounder_fly.png
animation=arounder_fly.ani
tileSetFile=flying_arounder.png
animation=flying_arounder.ani
width=7
height=7
x=9
@@ -44,8 +44,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_fly.png
animation=arounder_fly.ani
tileSetFile=flying_arounder.png
animation=flying_arounder.ani
width=7
height=7
x=15
@@ -61,8 +61,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_fly.png
animation=arounder_fly.ani
tileSetFile=flying_arounder.png
animation=flying_arounder.ani
width=7
height=7
x=22
@@ -78,8 +78,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_fly.png
animation=arounder_fly.ani
tileSetFile=flying_arounder.png
animation=flying_arounder.ani
width=7
height=7
x=16

View File

@@ -25,8 +25,8 @@ color=red
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=10
@@ -42,8 +42,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=15
@@ -59,8 +59,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=20
@@ -76,8 +76,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=14

View File

@@ -25,8 +25,8 @@ color=bright_cyan
[/enemy]
[enemy]
tileSetFile=arounder_stop.png
animation=arounder_stop.ani
tileSetFile=stopped_arounder.png
animation=stopped_arounder.ani
width=7
height=8
x=8
@@ -41,8 +41,8 @@ color=bright_cyan
[/enemy]
[enemy]
tileSetFile=arounder_stop.png
animation=arounder_stop.ani
tileSetFile=stopped_arounder.png
animation=stopped_arounder.ani
width=7
height=8
x=11
@@ -57,8 +57,8 @@ color=bright_cyan
[/enemy]
[enemy]
tileSetFile=arounder_stop.png
animation=arounder_stop.ani
tileSetFile=stopped_arounder.png
animation=stopped_arounder.ani
width=7
height=8
x=24
@@ -73,8 +73,8 @@ color=bright_cyan
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=12
@@ -90,8 +90,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=14
@@ -107,8 +107,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=arounder_walk.png
animation=arounder_walk.ani
tileSetFile=walking_arounder.png
animation=walking_arounder.ani
width=5
height=8
x=14

View File

@@ -1,6 +1,6 @@
name=P.A.C.O. ON THE GO
bgColor=black
border=black
border=blue
tileMapFile=42.tmx
tileSetFile=standard.png
roomUp=0
@@ -23,7 +23,7 @@ x1=10
y1=2
x2=10
y2=11
color=green
color=magenta
[/enemy]
[enemy]

View File

@@ -11,8 +11,8 @@
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,421,62,
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,421,415,0,0,0,0,0,0,0,0,0,0,0,
36,0,0,0,0,0,0,0,305,0,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
36,0,0,0,305,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
36,0,0,0,0,0,0,0,306,0,0,0,0,306,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
36,0,0,0,306,0,0,0,0,0,0,0,0,0,0,0,0,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
36,0,415,421,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,415,415,0,0,421,415,0,0,0,0,0,0,
36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

View File

@@ -11,6 +11,22 @@ itemColor1=red
itemColor2=magenta
autoSurface=left
[enemy]
tileSetFile=batman_fire.png
animation=batman_fire.ani
width=16
height=16
x=10
y=13
vx=1.3
vy=0
x1=0
y1=13
x2=29
y2=13
color=cyan
flip=true
[/enemy]
[enemy]
tileSetFile=heavy.png

View File

@@ -11,8 +11,8 @@ itemColor1=red
itemColor2=yellow
[enemy]
tileSetFile=jb_alien.png
animation=jb_alien.ani
tileSetFile=jailbattle_alien.png
animation=jailbattle_alien.ani
width=13
height=15
x=10
@@ -28,8 +28,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=jb_alien.png
animation=jb_alien.ani
tileSetFile=jailbattle_alien.png
animation=jailbattle_alien.ani
width=13
height=15
x=25
@@ -45,8 +45,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=jb_human.png
animation=jb_human.ani
tileSetFile=jailbattle_human.png
animation=jailbattle_human.ani
width=11
height=13
x=7
@@ -62,8 +62,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=jb_human.png
animation=jb_human.ani
tileSetFile=jailbattle_human.png
animation=jailbattle_human.ani
width=11
height=13
x=18

View File

@@ -11,8 +11,8 @@ itemColor1=white
itemColor2=green
[enemy]
tileSetFile=jb_human.png
animation=jb_human.ani
tileSetFile=jailbattle_human.png
animation=jailbattle_human.ani
width=11
height=13
x=17
@@ -28,8 +28,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=jb_human.png
animation=jb_human.ani
tileSetFile=jailbattle_human.png
animation=jailbattle_human.ani
width=11
height=13
x=2
@@ -45,8 +45,8 @@ flip=true
[/enemy]
[enemy]
tileSetFile=jb_alien.png
animation=jb_alien.ani
tileSetFile=jailbattle_alien.png
animation=jailbattle_alien.ani
width=11
height=13
x=24

View File

@@ -9,8 +9,8 @@ roomLeft=0
roomRight=49.room
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=7
@@ -25,8 +25,8 @@ color=magenta
[/enemy]
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=floppy.png
animation=floppy.ani
width=16
height=16
x=20

View File

@@ -4,7 +4,7 @@
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
42,42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,42,
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

View File

@@ -1,4 +1,4 @@
name=P.A.C.O WORKSHOP
name=P.A.C.O. WORKSHOP
bgColor=black
border=yellow
tileMapFile=53.tmx

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

BIN
data/title/title_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -11,9 +11,9 @@
<key>CFBundleExecutable</key>
<string>jaildoctors_dilemma</string>
<key>CFBundleIconFile</key>
<string>jaildoctors_dilemma</string>
<string>icon</string>
<key>CFBundleIconName</key>
<string>jaildoctors_dilemma</string>
<string>icon</string>
<key>CFBundleIdentifier</key>
<string>org.jailgames.jaildoctors_dilemma</string>
<key>CFBundleInfoDictionaryVersion</key>
@@ -23,11 +23,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.3</string>
<string>1.08</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.6</string>
<string>1.08</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSMinimumSystemVersion</key>

BIN
release/libgcc_s_seh-1.dll Normal file

Binary file not shown.

BIN
release/libstdc++-6.dll Normal file

Binary file not shown.

BIN
release/libwinpthread-1.dll Normal file

Binary file not shown.

View File

@@ -1,13 +1,339 @@
#include "cheevos.h"
#include <iostream>
// Constructor
Cheevos::Cheevos(options_t *options)
Cheevos::Cheevos(Screen *screen, options_t *options, std::string file, Online *online)
{
// Copia la dirección de los objetos
this->options = options;
this->screen = screen;
this->file = file;
this->online = online;
// Inicializa los logros
init();
// Inicializa variables
enabled = true;
// Carga el estado de los logros
load();
}
// Destructor
Cheevos::~Cheevos()
{
// Guarda el estado de los logros
save();
cheevos.clear();
}
// Inicializa los logros
void Cheevos::init()
{
cheevos.clear();
cheevos_t c;
c.completed = false;
c.valid = true;
c.icon = 2;
c.id = 1;
c.caption = "SHINY THINGS";
c.description = "Get 25\% of the items";
cheevos.push_back(c);
c.id = 2;
c.caption = "HALF THE WORK";
c.description = "Get 50\% of the items";
cheevos.push_back(c);
c.id = 3;
c.caption = "GETTING THERE";
c.description = "Get 75\% of the items";
cheevos.push_back(c);
c.id = 4;
c.caption = "THE COLLECTOR";
c.description = "Get 100\% of the items";
cheevos.push_back(c);
c.id = 5;
c.caption = "WANDERING AROUND";
c.description = "Visit 20 rooms";
cheevos.push_back(c);
c.id = 6;
c.caption = "I GOT LOST";
c.description = "Visit 40 rooms";
cheevos.push_back(c);
c.id = 7;
c.caption = "I LIKE TO EXPLORE";
c.description = "Visit all rooms";
cheevos.push_back(c);
c.id = 8;
c.caption = "FINISH THE GAME";
c.description = "Complete the game";
cheevos.push_back(c);
c.id = 9;
c.caption = "I WAS SUCKED BY A HOLE";
c.description = "Complete the game without entering the jail";
cheevos.push_back(c);
c.id = 10;
c.caption = "MY LITTLE PROJECTS";
c.description = "Complete the game with all items";
cheevos.push_back(c);
c.id = 11;
c.caption = "I LIKE MY MULTICOLOURED FRIENDS";
c.description = "Complete the game without dying";
cheevos.push_back(c);
c.id = 12;
c.caption = "SHIT PROJECTS DONE FAST";
c.description = "Complete the game in under 30 minutes";
cheevos.push_back(c);
}
// Busca un logro por id y devuelve el indice
int Cheevos::find(int id)
{
for (int i = 0; i < (int)cheevos.size(); ++i)
{
if (cheevos[i].id == id)
{
return i;
}
}
return -1;
}
// Desbloquea un logro
void Cheevos::unlock(int id)
{
const int index = find(id);
if (index == -1)
{
return;
}
if (!cheevos[index].valid)
{
return;
}
if (cheevos[index].completed)
{
return;
}
if (!enabled)
{
return;
}
cheevos[index].completed = true;
screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption, cheevos[index].icon);
save();
}
// Invalida un logro
void Cheevos::invalidate(int id)
{
const int index = find(id);
if (index == -1)
{
return;
}
cheevos[index].valid = false;
}
// Habilita o deshabilita los logros
void Cheevos::enable(bool value)
{
enabled = value;
}
// Carga el estado de los logros
void Cheevos::load()
{
if (options->online.enabled)
{ // Carga el estado de los logros desde el servidor online
loadFromServer();
}
else
{ // Carga el estado de los logros desde un fichero
loadFromFile();
}
}
// Guarda el estado de los logros
void Cheevos::save()
{
if (options->online.enabled)
{ // Guarda el estado de los logros en el servidor online
saveToServer();
}
else
{ // Guarda el estado de los logros en un fichero
saveToFile();
}
}
// Carga el estado de los logros desde un fichero
void Cheevos::loadFromFile()
{
// Abre el fichero en modo lectura (binario)
SDL_RWops *file = SDL_RWFromFile(this->file.c_str(), "r+b");
// El fichero no existe
if (file == NULL)
{
if (options->console)
{
std::cout << "Warning: Unable to open file! SDL Error: " << SDL_GetError() << std::endl;
}
// Crea el fichero en modo escritura (binario)
file = SDL_RWFromFile(this->file.c_str(), "w+b");
if (file != NULL)
{
if (options->console)
{
std::cout << "New file created!" << std::endl;
}
// Guarda la información
for (int i = 0; i < (int)cheevos.size(); ++i)
{
SDL_RWwrite(file, &cheevos[i].completed, sizeof(bool), 1);
}
// Cierra el fichero
SDL_RWclose(file);
}
else
{
if (options->console)
{
std::cout << "Error: Unable to create file! SDL Error: " << SDL_GetError() << std::endl;
}
}
}
// El fichero existe
else
{
// Carga los datos
if (options->console)
{
std::cout << "Reading file...!" << std::endl;
}
for (int i = 0; i < (int)cheevos.size(); ++i)
{
SDL_RWread(file, &cheevos[i].completed, sizeof(bool), 1);
}
// Cierra el fichero
SDL_RWclose(file);
}
}
// Guarda el estado de los logros en un fichero
void Cheevos::saveToFile()
{
// Abre el fichero en modo escritura (binario)
SDL_RWops *file = SDL_RWFromFile(this->file.c_str(), "w+b");
if (file != NULL)
{
// Guarda la información
for (int i = 0; i < (int)cheevos.size(); ++i)
{
SDL_RWwrite(file, &cheevos[i].completed, sizeof(bool), 1);
}
// Cierra el fichero
SDL_RWclose(file);
}
else
{
if (options->console)
{
std::cout << "Error: Unable to save file! " << SDL_GetError() << std::endl;
}
}
}
// Lista los logros
std::vector<cheevos_t> Cheevos::list()
{
return cheevos;
}
// Devuelve el número total de logros desbloqueados
int Cheevos::unlocked()
{
int count = 0;
for (auto cheevo : cheevos)
{
if (cheevo.completed)
count++;
}
return count;
}
// Devuelve el número total de logros
int Cheevos::count()
{
return cheevos.size();
}
// Carga el estado de los logros desde el servidor online
void Cheevos::loadFromServer()
{
std::string cheevosData = online->getCheevos();
// Gestiona los posibles errores
const bool noData = cheevosData == "" ? true : false;
const bool incompleteData = cheevosData.length() != cheevos.size() ? true : false;
if (noData || incompleteData)
{
// Pone todos los logros en incompleto
init();
return;
}
// Asigna los valores leídos desde el servidor
for (int i = 0; i < (int)cheevosData.length(); ++i)
{
bool value = cheevosData.at(i) == '1' ? true : false;
cheevos.at(i).completed = value;
}
}
// Guarda el estado de los logros en el servidor online
void Cheevos::saveToServer()
{
std::string cheevosData = "";
// cheevos[2].completed = true;
for (auto cheevo : cheevos)
{
std::string data = cheevo.completed ? "1" : "0";
cheevosData.append(data);
}
online->setCheevos(cheevosData);
}
// Vuelve a cargar los logros desde el origen
void Cheevos::reload()
{
load();
}

View File

@@ -1,27 +1,88 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/utils.h"
#include "jail_engine/screen.h"
#include "jail_engine/utils.h"
#include "online.h"
#include <string>
#include <vector>
#ifndef CHEEVOS_H
#define CHEEVOS_H
struct cheevos_t
{
int id; // Identificador del logro
std::string caption; // Texto con el nombre del logro
std::string description; // Texto que describe el logro
int icon; // Indice del icono a utilizar en la notificación
bool completed; // Indica si se ha obtenido el logro
bool valid; // Indica si se puede obtener el logro
};
class Cheevos
{
private:
// Punteros y objetos
options_t *options;
Screen *screen; // Objeto encargado de dibujar en pantalla
options_t *options; // Puntero a las opciones del juego
Online *online; // Objeto para gestionar la lectura y escritura de datos en el servidor remoto
// Variables
std::vector<cheevos_t> cheevos; // Listado de logros
bool enabled; // Indica si los logros se pueden obtener
std::string file; // Fichero done leer/almacenar el estado de los logros
// Inicializa los logros
void init();
// Busca un logro por id y devuelve el indice
int find(int id);
// Carga el estado de los logros
void load();
// Guarda el estado de los logros
void save();
// Carga el estado de los logros desde un fichero
void loadFromFile();
// Guarda el estado de los logros en un fichero
void saveToFile();
// Carga el estado de los logros desde el servidor online
void loadFromServer();
// Guarda el estado de los logros en el servidor online
void saveToServer();
public:
// Constructor
Cheevos(options_t *options);
Cheevos(Screen *screen, options_t *options, std::string file, Online *online);
// Destructor
~Cheevos();
// Desbloquea un logro
void unlock(int id);
// Invalida un logro
void invalidate(int id);
// Habilita o deshabilita los logros
void enable(bool value);
// Lista los logros
std::vector<cheevos_t> list();
// Devuelve el número total de logros desbloqueados
int unlocked();
// Devuelve el número total de logros
int count();
// Vuelve a cargar los logros desde el origen
void reload();
};
#endif

View File

@@ -1,162 +0,0 @@
#include "notify.h"
#include <string>
#include <stdio.h>
#include <iostream>
// Constructor
Notify::Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textFile, std::string soundFile)
{
// Inicializa variables
this->renderer = renderer;
bgColor = {64, 64, 64};
waitTime = 300;
// Crea objetos
texture = new Texture(renderer, bitmapFile);
text = new Text(textFile, texture, renderer);
sound = JA_LoadSound(soundFile.c_str());
}
// Destructor
Notify::~Notify()
{
// Libera la memoria de los objetos
delete texture;
delete text;
JA_DeleteSound(sound);
for (auto notification : notifications)
{
delete notification.sprite;
delete notification.texture;
}
}
// Dibuja las notificaciones por pantalla
void Notify::render()
{
for (int i = (int)notifications.size() - 1; i >= 0; --i)
{
notifications.at(i).sprite->render();
}
}
// Actualiza el estado de las notificaiones
void Notify::update()
{
for (int i = 0; i < (int)notifications.size(); ++i)
{
notifications.at(i).counter++;
// Comprueba los estados
if (notifications.at(i).state == ns_rising)
{
const float step = ((float)notifications.at(i).counter / notifications.at(i).travelDist);
const int alpha = 255 * step;
notifications.at(i).rect.y++;
notifications.at(i).texture->setAlpha(alpha);
if (notifications.at(i).rect.y == notifications.at(i).y)
{
notifications.at(i).state = ns_stay;
notifications.at(i).texture->setAlpha(255);
notifications.at(i).counter = 0;
}
}
else if (notifications.at(i).state == ns_stay)
{
if (notifications.at(i).counter == waitTime)
{
notifications.at(i).state = ns_vanishing;
notifications.at(i).counter = 0;
}
}
else if (notifications.at(i).state == ns_vanishing)
{
const float step = (notifications.at(i).counter / (float)notifications.at(i).travelDist);
const int alpha = 255 * (1 - step);
notifications.at(i).rect.y--;
notifications.at(i).texture->setAlpha(alpha);
if (notifications.at(i).rect.y == notifications.at(i).y - notifications.at(i).travelDist)
{
notifications.at(i).state = ns_finished;
}
}
notifications.at(i).sprite->setRect(notifications.at(i).rect);
}
clearFinishedNotifications();
}
// Elimina las notificaciones finalizadas
void Notify::clearFinishedNotifications()
{
for (int i = (int)notifications.size() - 1; i >= 0; --i)
{
if (notifications.at(i).state == ns_finished)
{
delete notifications.at(i).sprite;
delete notifications.at(i).texture;
notifications.erase(notifications.begin() + i);
}
}
}
// Muestra una notificación de texto por pantalla;
void Notify::showText(std::string text)
{
// Crea constantes
const int width = this->text->lenght(text) + (this->text->getCharacterSize() * 2);
const int height = this->text->getCharacterSize() * 2;
const int despH = this->text->getCharacterSize() / 2;
const int despV = despH;
const int travelDist = height + despV;
const int offset = (int)notifications.size() > 0 ? notifications.back().y + travelDist : despV;
// Crea la notificacion
notification_t n;
// inicializa variables
n.y = offset;
n.travelDist = travelDist;
n.counter = 0;
n.state = ns_rising;
n.text = text;
n.rect = {despH, offset - travelDist, width, height};
// Crea la textura
n.texture = new Texture(renderer);
n.texture->createBlank(renderer, width, height, SDL_TEXTUREACCESS_TARGET);
n.texture->setAsRenderTarget(renderer);
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
SDL_RenderClear(renderer);
n.texture->setBlendMode(SDL_BLENDMODE_BLEND);
this->text->writeDX(TXT_CENTER | TXT_STROKE, width / 2, despV, text, 1, {255, 255, 255}, 1, {0, 0, 0});
SDL_SetRenderTarget(renderer, nullptr);
// Crea el sprite
n.sprite = new Sprite(n.rect, n.texture, renderer);
// Añade la notificación a la lista
notifications.push_back(n);
// Reproduce el sonido de la notificación
JA_PlaySound(sound);
}
// Indica si hay notificaciones activas
bool Notify::active()
{
if ((int)notifications.size() > 0)
{
return true;
}
return false;
}

View File

@@ -2,7 +2,7 @@
#include <SDL2/SDL.h>
#include <string>
#include "common/utils.h"
#include "jail_engine/utils.h"
#ifndef CONST_H
#define CONST_H
@@ -48,21 +48,22 @@ const int GAMECANVAS_FIRST_QUARTER_Y = GAMECANVAS_HEIGHT / 4;
const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3;
// Secciones del programa
#define SECTION_PROG_LOGO 0
#define SECTION_PROG_INTRO 1
#define SECTION_PROG_TITLE 2
#define SECTION_PROG_CREDITS 3
#define SECTION_PROG_GAME 4
#define SECTION_PROG_DEMO 5
#define SECTION_PROG_GAME_OVER 6
#define SECTION_PROG_ENDING 7
#define SECTION_PROG_ENDING2 8
#define SECTION_PROG_ENTER_ID 9
#define SECTION_PROG_QUIT 10
#define SECTION_LOGO 0
#define SECTION_LOADING_SCREEN 1
#define SECTION_TITLE 2
#define SECTION_CREDITS 3
#define SECTION_GAME 4
#define SECTION_DEMO 5
#define SECTION_GAME_OVER 6
#define SECTION_ENDING 7
#define SECTION_ENDING2 8
#define SECTION_QUIT 9
// Subsecciones
#define SUBSECTION_LOGO_TO_INTRO 0
#define SUBSECTION_LOGO_TO_TITLE 1
#define SUBSECTION_TITLE_WITH_LOADING_SCREEN 2
#define SUBSECTION_TITLE_WITHOUT_LOADING_SCREEN 3
// Colores
const color_t borderColor = {0x27, 0x27, 0x36};

View File

@@ -1,5 +1,5 @@
#include "common/jscore.h"
#include "common/utils.h"
#include "jail_engine/jscore.h"
#include "jail_engine/utils.h"
#include "director.h"
#include <errno.h>
#include <iostream>
@@ -14,11 +14,12 @@
// Constructor
Director::Director(int argc, char *argv[])
{
section.name = SECTION_PROG_LOGO;
section.subsection = SUBSECTION_LOGO_TO_INTRO;
section = new section_t();
section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO;
#ifdef DEBUG
section.name = SECTION_PROG_LOGO;
section->name = SECTION_TITLE;
#endif
// Crea e inicializa las opciones del programa
@@ -28,7 +29,12 @@ Director::Director(int argc, char *argv[])
checkProgramArguments(argc, argv);
// Crea la carpeta del sistema donde guardar datos
createSystemFolder();
createSystemFolder("jailgames");
#ifndef DEBUG
createSystemFolder("jailgames/jaildoctors_dilemma");
#else
createSystemFolder("jailgames/jaildoctors_dilemma_debug");
#endif
// Crea el objeto que controla los ficheros de recursos
asset = new Asset(executablePath);
@@ -57,9 +63,10 @@ Director::Director(int argc, char *argv[])
screen->setBorderColor(borderColor);
debug = new Debug(renderer, screen, asset);
music = JA_LoadMusic(asset->get("title.ogg").c_str());
online = new Online(options);
// Inicializa los servicios online
//initOnline();
initOnline();
}
Director::~Director()
@@ -68,12 +75,14 @@ Director::~Director()
saveConfig();
// Libera la memoria
delete section;
delete options;
delete asset;
delete input;
delete screen;
delete debug;
delete resource;
delete online;
JA_DeleteMusic(music);
SDL_DestroyRenderer(renderer);
@@ -86,16 +95,14 @@ void Director::initOnline()
{
if (options->online.jailerID == "")
{ // Jailer ID no definido
options->online.enabled = false;
}
else
{ // Jailer ID iniciado
if (options->online.enabled)
{ // Establece el servidor y el puerto
jscore::init(options->online.server, options->online.port);
options->online.sessionEnabled = true;
const std::string caption = options->online.jailerID + " IS LOGGED IN";
screen->showNotification(caption);
if (options->console)
@@ -112,10 +119,13 @@ void Director::initOptions()
// Crea el puntero a la estructura de opciones
options = new options_t;
// Version
// Version del archivo de configuración
options->configVersion = "v1.06.1";
// Opciones dee video
// Opciones de control
options->keys = ctrl_cursor;
// Opciones de video
options->gameWidth = GAMECANVAS_WIDTH;
options->gameHeight = GAMECANVAS_HEIGHT;
options->videoMode = 0;
@@ -125,11 +135,19 @@ void Director::initOptions()
options->integerScale = true;
options->keepAspect = true;
options->borderEnabled = true;
options->borderSize = 0.2f;
options->borderWidth = 32;
options->borderHeight = 24;
options->palette = p_zxspectrum;
#ifdef GAME_CONSOLE
options->windowSize = 2;
#endif
// Estos valores no se guardan en el fichero de configuraci´ón
options->console = false;
#ifdef DEBUG
options->console = true;
#endif
options->cheat.infiniteLives = false;
options->cheat.invincible = false;
options->cheat.jailEnabled = false;
@@ -138,15 +156,22 @@ void Director::initOptions()
options->stats.items = 0;
// Opciones online
options->online.enabled = true;
options->online.enabled = false;
options->online.sessionEnabled = false;
options->online.server = "jaildoctor.duckdns.org";
options->online.port = 9911;
#ifdef DEBUG
options->online.gameID = "jaildoctors_dilemma_test";
options->online.gameID = "jaildoctors_dilemma_debug";
#else
options->online.gameID = "jaildoctors_dilemma";
#endif
options->online.jailerID = "";
// Opciones de las notificaciones
options->notifications.posV = pos_top;
options->notifications.posH = pos_left;
options->notifications.sound = true;
options->notifications.color = {48, 48, 48};
}
// Comprueba los parametros del programa
@@ -306,6 +331,21 @@ bool Director::saveConfig()
file << "## VERSION\n";
file << "configVersion=" + options->configVersion + "\n";
file << "\n## CONTROL OPTIONS\n";
file << "## keys = CURSOR | OPQA | WASD\n";
if (options->keys == ctrl_cursor)
{
file << "keys=CURSOR\n";
}
else if (options->keys == ctrl_opqa)
{
file << "keys=OPQA\n";
}
else if (options->keys == ctrl_wasd)
{
file << "keys=WASD\n";
}
file << "\n## VISUAL OPTIONS\n";
if (options->videoMode == 0)
{
@@ -337,7 +377,8 @@ bool Director::saveConfig()
file << "integerScale=" + boolToString(options->integerScale) + "\n";
file << "keepAspect=" + boolToString(options->keepAspect) + "\n";
file << "borderEnabled=" + boolToString(options->borderEnabled) + "\n";
file << "borderSize=" + std::to_string(options->borderSize) + "\n";
file << "borderWidth=" + std::to_string(options->borderWidth) + "\n";
file << "borderHeight=" + std::to_string(options->borderHeight) + "\n";
file << "palette=" + std::to_string(options->palette) + "\n";
file << "\n## ONLINE OPTIONS\n";
@@ -346,6 +387,33 @@ bool Director::saveConfig()
file << "port=" + std::to_string(options->online.port) + "\n";
file << "jailerID=" + options->online.jailerID + "\n";
file << "\n## NOTIFICATION OPTIONS\n";
file << "## notifications.posV = pos_top | pos_bottom\n";
if (options->notifications.posV == pos_top)
{
file << "notifications.posV=pos_top\n";
}
else
{
file << "notifications.posV=pos_bottom\n";
}
file << "## notifications.posH = pos_left | pos_middle | pos_right\n";
if (options->notifications.posH == pos_left)
{
file << "notifications.posH=pos_left\n";
}
else if (options->notifications.posH == pos_middle)
{
file << "notifications.posH=pos_middle\n";
}
else
{
file << "notifications.posH=pos_right\n";
}
file << "notifications.sound=" + boolToString(options->notifications.sound) + "\n";
// Cierra el fichero
file.close();
@@ -353,24 +421,18 @@ bool Director::saveConfig()
}
// Crea la carpeta del sistema donde guardar datos
void Director::createSystemFolder()
void Director::createSystemFolder(std::string folder)
{
#ifdef DEBUG
const std::string folderName = "jaildoctors_dilemma_debug";
#else
const std::string folderName = "jaildoctors_dilemma";
#endif
#ifdef _WIN32
systemFolder = std::string(getenv("APPDATA")) + "/" + folderName;
systemFolder = std::string(getenv("APPDATA")) + "/" + folder;
#elif __APPLE__
struct passwd *pw = getpwuid(getuid());
const char *homedir = pw->pw_dir;
systemFolder = std::string(homedir) + "/Library/Application Support/" + folderName;
systemFolder = std::string(homedir) + "/Library/Application Support" + "/" + folder;
#elif __linux__
struct passwd *pw = getpwuid(getuid());
const char *homedir = pw->pw_dir;
systemFolder = std::string(homedir) + "/." + folderName;
systemFolder = std::string(homedir) + "/." + folder;
#endif
struct stat st = {0};
@@ -408,14 +470,14 @@ void Director::createSystemFolder()
}
// Carga los recursos
void Director::loadResources(section_t section)
void Director::loadResources(section_t *section)
{
if (options->console)
{
std::cout << "** LOAD RESOURCES" << std::endl;
}
if (section.name == SECTION_PROG_LOGO)
if (section->name == SECTION_LOGO)
{
std::vector<std::string> textureList;
textureList.push_back("jailgames.png");
@@ -424,7 +486,7 @@ void Director::loadResources(section_t section)
resource->loadTextures(textureList);
}
else if (section.name == SECTION_PROG_INTRO)
else if (section->name == SECTION_LOADING_SCREEN)
{
std::vector<std::string> textureList;
textureList.push_back("loading_screen_bn.png");
@@ -435,23 +497,27 @@ void Director::loadResources(section_t section)
resource->loadTextures(textureList);
}
else if (section.name == SECTION_PROG_TITLE)
else if (section->name == SECTION_TITLE)
{
std::vector<std::string> textureList;
textureList.push_back("loading_screen_color.png");
textureList.push_back("loading_screen_color_zxarne.png");
textureList.push_back("smb2.png");
textureList.push_back("subatomic.png");
textureList.push_back("notify.png");
textureList.push_back("title_logo.png");
resource->loadTextures(textureList);
// Offsets
std::vector<std::string> offsetsList;
offsetsList.push_back("smb2.txt");
offsetsList.push_back("subatomic.txt");
resource->loadOffsets(offsetsList);
}
else if (section.name == SECTION_PROG_CREDITS)
else if (section->name == SECTION_CREDITS)
{
// Texturas
std::vector<std::string> textureList;
@@ -473,7 +539,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList);
}
else if (section.name == SECTION_PROG_ENDING)
else if (section->name == SECTION_ENDING)
{
// Texturas
std::vector<std::string> textureList;
@@ -498,7 +564,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList);
}
else if (section.name == SECTION_PROG_ENDING2)
else if (section->name == SECTION_ENDING2)
{
// Texturas
std::vector<std::string> textureList;
@@ -510,9 +576,9 @@ void Director::loadResources(section_t section)
textureList.push_back("abad.png");
textureList.push_back("abad_bell.png");
textureList.push_back("amstrad_cs.png");
textureList.push_back("arounder_fly.png");
textureList.push_back("arounder_stop.png");
textureList.push_back("arounder_walk.png");
textureList.push_back("flying_arounder.png");
textureList.push_back("stopped_arounder.png");
textureList.push_back("walking_arounder.png");
textureList.push_back("arounders_door.png");
textureList.push_back("arounders_machine.png");
textureList.push_back("bat.png");
@@ -531,14 +597,14 @@ void Director::loadResources(section_t section)
textureList.push_back("demon.png");
textureList.push_back("heavy.png");
textureList.push_back("dimallas.png");
textureList.push_back("diskette.png");
textureList.push_back("floppy.png");
textureList.push_back("dong.png");
textureList.push_back("guitar.png");
textureList.push_back("jb_alien.png");
textureList.push_back("jb_human.png");
textureList.push_back("jailer.png");
textureList.push_back("jailer2.png");
textureList.push_back("jailer3.png");
textureList.push_back("jailbattle_alien.png");
textureList.push_back("jailbattle_human.png");
textureList.push_back("jailer_#1.png");
textureList.push_back("jailer_#2.png");
textureList.push_back("jailer_#3.png");
textureList.push_back("jeannine.png");
textureList.push_back("lamp.png");
textureList.push_back("lord_abad.png");
@@ -546,7 +612,7 @@ void Director::loadResources(section_t section)
textureList.push_back("matatunos.png");
textureList.push_back("mummy.png");
textureList.push_back("paco.png");
textureList.push_back("printer.png");
textureList.push_back("elsa.png");
textureList.push_back("qvoid.png");
textureList.push_back("sam.png");
textureList.push_back("sigmasua.png");
@@ -573,9 +639,9 @@ void Director::loadResources(section_t section)
animationList.push_back("abad.ani");
animationList.push_back("abad_bell.ani");
animationList.push_back("amstrad_cs.ani");
animationList.push_back("arounder_fly.ani");
animationList.push_back("arounder_stop.ani");
animationList.push_back("arounder_walk.ani");
animationList.push_back("flying_arounder.ani");
animationList.push_back("stopped_arounder.ani");
animationList.push_back("walking_arounder.ani");
animationList.push_back("arounders_door.ani");
animationList.push_back("arounders_machine.ani");
animationList.push_back("bat.ani");
@@ -594,14 +660,14 @@ void Director::loadResources(section_t section)
animationList.push_back("demon.ani");
animationList.push_back("heavy.ani");
animationList.push_back("dimallas.ani");
animationList.push_back("diskette.ani");
animationList.push_back("floppy.ani");
animationList.push_back("dong.ani");
animationList.push_back("guitar.ani");
animationList.push_back("jb_alien.ani");
animationList.push_back("jb_human.ani");
animationList.push_back("jailer.ani");
animationList.push_back("jailer2.ani");
animationList.push_back("jailer3.ani");
animationList.push_back("jailbattle_alien.ani");
animationList.push_back("jailbattle_human.ani");
animationList.push_back("jailer_#1.ani");
animationList.push_back("jailer_#2.ani");
animationList.push_back("jailer_#3.ani");
animationList.push_back("jeannine.ani");
animationList.push_back("lamp.ani");
animationList.push_back("lord_abad.ani");
@@ -609,7 +675,7 @@ void Director::loadResources(section_t section)
animationList.push_back("matatunos.ani");
animationList.push_back("mummy.ani");
animationList.push_back("paco.ani");
animationList.push_back("printer.ani");
animationList.push_back("elsa.ani");
animationList.push_back("qvoid.ani");
animationList.push_back("sam.ani");
animationList.push_back("sigmasua.ani");
@@ -636,7 +702,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList);
}
else if (section.name == SECTION_PROG_GAME_OVER)
else if (section->name == SECTION_GAME_OVER)
{
// Texturas
std::vector<std::string> textureList;
@@ -660,7 +726,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList);
}
else if (section.name == SECTION_PROG_GAME || section.name == SECTION_PROG_DEMO)
else if (section->name == SECTION_GAME || section->name == SECTION_DEMO)
{
// Texturas
std::vector<std::string> textureList;
@@ -684,9 +750,9 @@ void Director::loadResources(section_t section)
textureList.push_back("abad.png");
textureList.push_back("aerojailer.png");
textureList.push_back("amstrad_cs.png");
textureList.push_back("arounder_fly.png");
textureList.push_back("arounder_stop.png");
textureList.push_back("arounder_walk.png");
textureList.push_back("flying_arounder.png");
textureList.push_back("stopped_arounder.png");
textureList.push_back("walking_arounder.png");
textureList.push_back("arounder.png");
textureList.push_back("arounders_door.png");
textureList.push_back("arounders_machine.png");
@@ -705,15 +771,15 @@ void Director::loadResources(section_t section)
textureList.push_back("crosshair.png");
textureList.push_back("demon.png");
textureList.push_back("dimallas.png");
textureList.push_back("diskette.png");
textureList.push_back("floppy.png");
textureList.push_back("dong.png");
textureList.push_back("guitar.png");
textureList.push_back("heavy.png");
textureList.push_back("jailer.png");
textureList.push_back("jailer2.png");
textureList.push_back("jailer3.png");
textureList.push_back("jb_alien.png");
textureList.push_back("jb_human.png");
textureList.push_back("jailer_#1.png");
textureList.push_back("jailer_#2.png");
textureList.push_back("jailer_#3.png");
textureList.push_back("jailbattle_alien.png");
textureList.push_back("jailbattle_human.png");
textureList.push_back("jeannine.png");
textureList.push_back("lamp.png");
textureList.push_back("lord_abad.png");
@@ -721,7 +787,7 @@ void Director::loadResources(section_t section)
textureList.push_back("mummy.png");
textureList.push_back("paco.png");
textureList.push_back("pepe_rosita_job.png");
textureList.push_back("printer.png");
textureList.push_back("elsa.png");
textureList.push_back("qvoid.png");
textureList.push_back("robot.png");
textureList.push_back("sam.png");
@@ -765,9 +831,9 @@ void Director::loadResources(section_t section)
animationList.push_back("abad.ani");
animationList.push_back("aerojailer.ani");
animationList.push_back("amstrad_cs.ani");
animationList.push_back("arounder_fly.ani");
animationList.push_back("arounder_stop.ani");
animationList.push_back("arounder_walk.ani");
animationList.push_back("flying_arounder.ani");
animationList.push_back("stopped_arounder.ani");
animationList.push_back("walking_arounder.ani");
animationList.push_back("arounder.ani");
animationList.push_back("arounders_door.ani");
animationList.push_back("arounders_machine.ani");
@@ -786,15 +852,15 @@ void Director::loadResources(section_t section)
animationList.push_back("crosshair.ani");
animationList.push_back("demon.ani");
animationList.push_back("dimallas.ani");
animationList.push_back("diskette.ani");
animationList.push_back("floppy.ani");
animationList.push_back("dong.ani");
animationList.push_back("guitar.ani");
animationList.push_back("heavy.ani");
animationList.push_back("jailer.ani");
animationList.push_back("jailer2.ani");
animationList.push_back("jailer3.ani");
animationList.push_back("jb_alien.ani");
animationList.push_back("jb_human.ani");
animationList.push_back("jailer_#1.ani");
animationList.push_back("jailer_#2.ani");
animationList.push_back("jailer_#3.ani");
animationList.push_back("jailbattle_alien.ani");
animationList.push_back("jailbattle_human.ani");
animationList.push_back("jeannine.ani");
animationList.push_back("lamp.ani");
animationList.push_back("lord_abad.ani");
@@ -802,7 +868,7 @@ void Director::loadResources(section_t section)
animationList.push_back("mummy.ani");
animationList.push_back("paco.ani");
animationList.push_back("pepe_rosita_job.ani");
animationList.push_back("printer.ani");
animationList.push_back("elsa.ani");
animationList.push_back("qvoid.ani");
animationList.push_back("robot.ani");
animationList.push_back("sam.ani");
@@ -976,6 +1042,22 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
options->configVersion = value;
}
else if (var == "keys")
{
if (value == "OPQA")
{
options->keys = ctrl_opqa;
}
else if (value == "WASD")
{
options->keys = ctrl_wasd;
}
else
{
options->keys = ctrl_cursor;
}
}
else if (var == "videoMode")
{
if (value == "SDL_WINDOW_FULLSCREEN_DESKTOP")
@@ -1033,13 +1115,14 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
options->borderEnabled = stringToBool(value);
}
else if (var == "borderSize")
else if (var == "borderWidth")
{
options->borderSize = std::stof(value);
if (options->borderSize < 0.0f || options->borderSize > 0.5f)
{
options->borderSize = 0.1f;
}
options->borderWidth = std::stoi(value);
}
else if (var == "borderHeight")
{
options->borderHeight = std::stoi(value);
}
else if (var == "palette")
@@ -1081,6 +1164,39 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
options->online.jailerID = value;
}
else if (var == "notifications.posH")
{
if (value == "pos_left")
{
options->notifications.posH = pos_left;
}
else if (value == "pos_middle")
{
options->notifications.posH = pos_middle;
}
else
{
options->notifications.posH = pos_right;
}
}
else if (var == "notifications.posV")
{
if (value == "pos_top")
{
options->notifications.posV = pos_top;
}
else
{
options->notifications.posV = pos_bottom;
}
}
else if (var == "notifications.sound")
{
options->notifications.sound = stringToBool(value);
}
else if (var == "" || var.substr(0, 1) == "#")
{
}
@@ -1102,27 +1218,62 @@ void Director::initInput()
// Busca si hay un mando conectado
input->discoverGameController();
// Asigna inputs a teclas
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);
// Teclado - Movimiento
if (options->keys == ctrl_cursor)
{
input->bindKey(input_jump, SDL_SCANCODE_UP);
input->bindKey(input_left, SDL_SCANCODE_LEFT);
input->bindKey(input_right, SDL_SCANCODE_RIGHT);
input->bindKey(input_up, SDL_SCANCODE_UP);
input->bindKey(input_down, SDL_SCANCODE_DOWN);
}
else if (options->keys == ctrl_opqa)
{
input->bindKey(input_jump, SDL_SCANCODE_Q);
input->bindKey(input_left, SDL_SCANCODE_O);
input->bindKey(input_right, SDL_SCANCODE_P);
input->bindKey(input_up, SDL_SCANCODE_Q);
input->bindKey(input_down, SDL_SCANCODE_A);
}
else if (options->keys == ctrl_wasd)
{
input->bindKey(input_jump, SDL_SCANCODE_W);
input->bindKey(input_left, SDL_SCANCODE_A);
input->bindKey(input_right, SDL_SCANCODE_D);
input->bindKey(input_up, SDL_SCANCODE_W);
input->bindKey(input_down, SDL_SCANCODE_S);
}
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);
// Teclado - Otros
input->bindKey(input_accept, SDL_SCANCODE_RETURN);
input->bindKey(input_cancel, SDL_SCANCODE_ESCAPE);
input->bindKey(input_pause, SDL_SCANCODE_H);
input->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
input->bindKey(input_window_dec_size, SDL_SCANCODE_F1);
input->bindKey(input_window_inc_size, SDL_SCANCODE_F2);
input->bindKey(input_window_fullscreen, SDL_SCANCODE_F3);
input->bindKey(input_swap_palette, SDL_SCANCODE_F5);
input->bindKey(input_switch_music, SDL_SCANCODE_M);
input->bindKey(input_toggle_border, SDL_SCANCODE_B);
// Mando - Movimiento
input->bindGameControllerButton(input_jump, SDL_CONTROLLER_BUTTON_B);
input->bindGameControllerButton(input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
input->bindGameControllerButton(input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
// Mando - Otros
input->bindGameControllerButton(input_accept, SDL_CONTROLLER_BUTTON_B);
input->bindGameControllerButton(input_cancel, SDL_CONTROLLER_BUTTON_A);
#ifdef GAME_CONSOLE
input->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_BACK);
input->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_START);
#else
input->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_START);
input->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_BACK);
#endif
input->bindGameControllerButton(input_swap_palette, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
input->bindGameControllerButton(input_switch_music, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
input->bindGameControllerButton(input_toggle_border, SDL_CONTROLLER_BUTTON_X);
}
// Inicializa JailAudio
@@ -1165,8 +1316,8 @@ bool Director::initSDL()
int incH = 0;
if (options->borderEnabled)
{
incW = options->gameWidth * options->borderSize;
incH = options->gameHeight * options->borderSize;
incW = options->borderWidth * 2;
incH = options->borderHeight * 2;
}
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (options->gameWidth + incW) * options->windowSize, (options->gameHeight + incH) * options->windowSize, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
@@ -1181,14 +1332,14 @@ bool Director::initSDL()
else
{
// Crea un renderizador para la ventana. El vsync se activa en funcion de las opciones
// Uint32 flags = SDL_RENDERER_SOFTWARE;
// Uint32 flags = SDL_RENDERER_ACCELERATED;
Uint32 flags = 0;
if (options->vSync)
{
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
}
else
{
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
flags = flags | SDL_RENDERER_PRESENTVSYNC;
}
renderer = SDL_CreateRenderer(window, -1, flags);
if (renderer == nullptr)
{
@@ -1233,6 +1384,10 @@ bool Director::setFileList()
asset->add(prefix + "/data/font/smb2.txt", t_font);
asset->add(prefix + "/data/font/debug.png", t_font);
asset->add(prefix + "/data/font/debug.txt", t_font);
asset->add(prefix + "/data/font/gauntlet.png", t_font);
asset->add(prefix + "/data/font/gauntlet.txt", t_font);
asset->add(prefix + "/data/font/subatomic.png", t_font);
asset->add(prefix + "/data/font/subatomic.txt", t_font);
// Datos
asset->add(prefix + "/data/input/gamecontrollerdb.txt", t_data);
@@ -1241,6 +1396,10 @@ bool Director::setFileList()
asset->add(systemFolder + "/config.txt", t_data, false, true);
asset->add(systemFolder + "/stats_buffer.csv", t_data, false, true);
asset->add(systemFolder + "/stats.csv", t_data, false, true);
asset->add(systemFolder + "/cheevos.bin", t_data, false, true);
// Notificaciones
asset->add(prefix + "/data/notifications/notify.png", t_bitmap);
// Habitaciones
asset->add(prefix + "/data/room/01.room", t_room);
@@ -1377,12 +1536,12 @@ bool Director::setFileList()
asset->add(prefix + "/data/enemies/abad.png", t_bitmap);
asset->add(prefix + "/data/enemies/amstrad_cs.ani", t_data);
asset->add(prefix + "/data/enemies/amstrad_cs.png", t_bitmap);
asset->add(prefix + "/data/enemies/arounder_fly.ani", t_data);
asset->add(prefix + "/data/enemies/arounder_fly.png", t_bitmap);
asset->add(prefix + "/data/enemies/arounder_stop.ani", t_data);
asset->add(prefix + "/data/enemies/arounder_stop.png", t_bitmap);
asset->add(prefix + "/data/enemies/arounder_walk.ani", t_data);
asset->add(prefix + "/data/enemies/arounder_walk.png", t_bitmap);
asset->add(prefix + "/data/enemies/flying_arounder.ani", t_data);
asset->add(prefix + "/data/enemies/flying_arounder.png", t_bitmap);
asset->add(prefix + "/data/enemies/stopped_arounder.ani", t_data);
asset->add(prefix + "/data/enemies/stopped_arounder.png", t_bitmap);
asset->add(prefix + "/data/enemies/walking_arounder.ani", t_data);
asset->add(prefix + "/data/enemies/walking_arounder.png", t_bitmap);
asset->add(prefix + "/data/enemies/arounders_door.ani", t_data);
asset->add(prefix + "/data/enemies/arounders_door.png", t_bitmap);
asset->add(prefix + "/data/enemies/arounders_machine.ani", t_data);
@@ -1417,24 +1576,24 @@ bool Director::setFileList()
asset->add(prefix + "/data/enemies/demon.png", t_bitmap);
asset->add(prefix + "/data/enemies/dimallas.ani", t_data);
asset->add(prefix + "/data/enemies/dimallas.png", t_bitmap);
asset->add(prefix + "/data/enemies/diskette.ani", t_data);
asset->add(prefix + "/data/enemies/diskette.png", t_bitmap);
asset->add(prefix + "/data/enemies/floppy.ani", t_data);
asset->add(prefix + "/data/enemies/floppy.png", t_bitmap);
asset->add(prefix + "/data/enemies/dong.ani", t_data);
asset->add(prefix + "/data/enemies/dong.png", t_bitmap);
asset->add(prefix + "/data/enemies/guitar.ani", t_data);
asset->add(prefix + "/data/enemies/guitar.png", t_bitmap);
asset->add(prefix + "/data/enemies/heavy.ani", t_data);
asset->add(prefix + "/data/enemies/heavy.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailer.ani", t_data);
asset->add(prefix + "/data/enemies/jailer.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailer2.ani", t_data);
asset->add(prefix + "/data/enemies/jailer2.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailer3.ani", t_data);
asset->add(prefix + "/data/enemies/jailer3.png", t_bitmap);
asset->add(prefix + "/data/enemies/jb_alien.ani", t_data);
asset->add(prefix + "/data/enemies/jb_alien.png", t_bitmap);
asset->add(prefix + "/data/enemies/jb_human.ani", t_data);
asset->add(prefix + "/data/enemies/jb_human.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailer_#1.ani", t_data);
asset->add(prefix + "/data/enemies/jailer_#1.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailer_#2.ani", t_data);
asset->add(prefix + "/data/enemies/jailer_#2.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailer_#3.ani", t_data);
asset->add(prefix + "/data/enemies/jailer_#3.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailbattle_alien.ani", t_data);
asset->add(prefix + "/data/enemies/jailbattle_alien.png", t_bitmap);
asset->add(prefix + "/data/enemies/jailbattle_human.ani", t_data);
asset->add(prefix + "/data/enemies/jailbattle_human.png", t_bitmap);
asset->add(prefix + "/data/enemies/jeannine.ani", t_data);
asset->add(prefix + "/data/enemies/jeannine.png", t_bitmap);
asset->add(prefix + "/data/enemies/lamp.ani", t_data);
@@ -1447,8 +1606,8 @@ bool Director::setFileList()
asset->add(prefix + "/data/enemies/mummy.png", t_bitmap);
asset->add(prefix + "/data/enemies/paco.ani", t_data);
asset->add(prefix + "/data/enemies/paco.png", t_bitmap);
asset->add(prefix + "/data/enemies/printer.ani", t_data);
asset->add(prefix + "/data/enemies/printer.png", t_bitmap);
asset->add(prefix + "/data/enemies/elsa.ani", t_data);
asset->add(prefix + "/data/enemies/elsa.png", t_bitmap);
asset->add(prefix + "/data/enemies/qvoid.ani", t_data);
asset->add(prefix + "/data/enemies/qvoid.png", t_bitmap);
asset->add(prefix + "/data/enemies/robot.ani", t_data);
@@ -1545,6 +1704,8 @@ bool Director::setFileList()
asset->add(prefix + "/data/title/loading_screen_color.png", t_bitmap);
asset->add(prefix + "/data/title/loading_screen_bn_zxarne.png", t_bitmap);
asset->add(prefix + "/data/title/loading_screen_color_zxarne.png", t_bitmap);
asset->add(prefix + "/data/title/loading_screen_color.gif", t_bitmap);
asset->add(prefix + "/data/title/title_logo.png", t_bitmap);
// Ending
asset->add(prefix + "/data/ending/ending1.png", t_bitmap);
@@ -1565,24 +1726,6 @@ bool Director::setFileList()
return asset->check();
}
// Obtiene el valor de la variable
Uint8 Director::getSubsection()
{
return section.subsection;
}
// Obtiene el valor de la variable
Uint8 Director::getSection()
{
return section.name;
}
// Establece el valor de la variable
void Director::setSection(section_t section)
{
this->section = section;
}
// Ejecuta la seccion de juego con el logo
void Director::runLogo()
{
@@ -1591,23 +1734,23 @@ void Director::runLogo()
std::cout << "\n* SECTION: LOGO" << std::endl;
}
loadResources(section);
logo = new Logo(renderer, screen, resource, asset, options, section.subsection);
setSection(logo->run());
logo = new Logo(renderer, screen, resource, asset, input, options, section);
logo->run();
delete logo;
resource->free();
}
// Ejecuta la seccion de juego de la introducción
void Director::runIntro()
// Ejecuta la seccion de juego de la pantalla de carga
void Director::runLoadingScreen()
{
if (options->console)
{
std::cout << "\n* SECTION: INTRO" << std::endl;
}
loadResources(section);
intro = new Intro(renderer, screen, resource, asset, options);
setSection(intro->run());
delete intro;
loadingScreen = new LoadingScreen(renderer, screen, resource, asset, input, options, section);
loadingScreen->run();
delete loadingScreen;
resource->free();
}
@@ -1623,8 +1766,8 @@ void Director::runTitle()
JA_PlayMusic(music);
}
loadResources(section);
title = new Title(renderer, screen, resource, asset, options);
setSection(title->run());
title = new Title(renderer, screen, resource, asset, input, online, options, section);
title->run();
delete title;
resource->free();
}
@@ -1637,8 +1780,8 @@ void Director::runCredits()
std::cout << "\n* SECTION: CREDITS" << std::endl;
}
loadResources(section);
credits = new Credits(renderer, screen, resource, asset, options);
setSection(credits->run());
credits = new Credits(renderer, screen, resource, asset, input, options, section);
credits->run();
delete credits;
resource->free();
}
@@ -1651,26 +1794,12 @@ void Director::runDemo()
std::cout << "\n* SECTION: DEMO" << std::endl;
}
loadResources(section);
demo = new Demo(renderer, screen, resource, asset, options, debug);
setSection(demo->run());
demo = new Demo(renderer, screen, resource, asset, input, options, section, debug);
demo->run();
delete demo;
resource->free();
}
// Ejecuta la seccion en la que se solicita al usuario su ID online
void Director::runEnterID()
{
if (options->console)
{
std::cout << "\n* SECTION: ENTER_ID" << std::endl;
}
// loadResources(section);
enterID = new EnterID(renderer, screen, asset, options, section);
setSection(enterID->run());
delete enterID;
resource->free();
}
// Ejecuta la seccion del final del juego
void Director::runEnding()
{
@@ -1679,8 +1808,8 @@ void Director::runEnding()
std::cout << "\n* SECTION: ENDING" << std::endl;
}
loadResources(section);
ending = new Ending(renderer, screen, resource, asset, options);
setSection(ending->run());
ending = new Ending(renderer, screen, resource, asset, input, options, section);
ending->run();
delete ending;
resource->free();
}
@@ -1693,8 +1822,8 @@ void Director::runEnding2()
std::cout << "\n* SECTION: ENDING2" << std::endl;
}
loadResources(section);
ending2 = new Ending2(renderer, screen, resource, asset, options);
setSection(ending2->run());
ending2 = new Ending2(renderer, screen, resource, asset, input, options, section);
ending2->run();
delete ending2;
resource->free();
}
@@ -1707,8 +1836,8 @@ void Director::runGameOver()
std::cout << "\n* SECTION: GAME OVER" << std::endl;
}
loadResources(section);
gameOver = new GameOver(renderer, screen, resource, asset, options);
setSection(gameOver->run());
gameOver = new GameOver(renderer, screen, resource, asset, input, options, section);
gameOver->run();
delete gameOver;
resource->free();
}
@@ -1722,8 +1851,8 @@ void Director::runGame()
}
JA_StopMusic();
loadResources(section);
game = new Game(renderer, screen, resource, asset, options, input, debug);
setSection(game->run());
game = new Game(renderer, screen, resource, asset, online, options, input, section, debug);
game->run();
delete game;
resource->free();
}
@@ -1731,47 +1860,43 @@ void Director::runGame()
void Director::run()
{
// Bucle principal
while (getSection() != SECTION_PROG_QUIT)
while (section->name != SECTION_QUIT)
{
switch (getSection())
switch (section->name)
{
case SECTION_PROG_LOGO:
case SECTION_LOGO:
runLogo();
break;
case SECTION_PROG_INTRO:
runIntro();
case SECTION_LOADING_SCREEN:
runLoadingScreen();
break;
case SECTION_PROG_TITLE:
case SECTION_TITLE:
runTitle();
break;
case SECTION_PROG_CREDITS:
case SECTION_CREDITS:
runCredits();
break;
case SECTION_PROG_DEMO:
case SECTION_DEMO:
runDemo();
break;
case SECTION_PROG_ENTER_ID:
runEnterID();
break;
case SECTION_PROG_GAME:
case SECTION_GAME:
runGame();
break;
case SECTION_PROG_GAME_OVER:
case SECTION_GAME_OVER:
runGameOver();
break;
case SECTION_PROG_ENDING:
case SECTION_ENDING:
runEnding();
break;
case SECTION_PROG_ENDING2:
case SECTION_ENDING2:
runEnding2();
break;
}

View File

@@ -1,25 +1,26 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "common/debug.h"
#include "common/input.h"
#include "common/jail_audio.h"
#include "common/movingsprite.h"
#include "common/resource.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/utils.h"
#include "jail_engine/asset.h"
#include "jail_engine/debug.h"
#include "jail_engine/input.h"
#include "jail_engine/jail_audio.h"
#include "jail_engine/movingsprite.h"
#include "jail_engine/resource.h"
#include "jail_engine/sprite.h"
#include "jail_engine/text.h"
#include "jail_engine/utils.h"
#include "const.h"
#include "credits.h"
#include "demo.h"
#include "ending.h"
#include "ending2.h"
#include "gamestate_credits.h"
#include "gamestate_demo.h"
#include "gamestate_ending.h"
#include "gamestate_ending2.h"
#include "enter_id.h"
#include "game_over.h"
#include "game.h"
#include "intro.h"
#include "logo.h"
#include "title.h"
#include "gamestate_game_over.h"
#include "gamestate_game.h"
#include "gamestate_loading_screen.h"
#include "gamestate_logo.h"
#include "online.h"
#include "gamestate_title.h"
#ifndef DIRECTOR_H
#define DIRECTOR_H
@@ -28,28 +29,28 @@ class Director
{
private:
// Objetos y punteros
SDL_Window *window; // La ventana donde dibujamos
SDL_Renderer *renderer; // El renderizador de la ventana
Screen *screen; // Objeto encargado de dibujar en pantalla
Resource *resource; // Objeto con los recursos
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
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; // Objeto para gestionar la introducción del juego
Credits *credits; // Objeto para gestionar los creditos del juego
Demo *demo; // Objeto para gestionar el modo demo, en el que se ven pantallas del juego
EnterID *enterID; // Objeto para gestionar la sección donde se solicita el ID online al usuario
Ending *ending; // Objeto para gestionar el final del juego
Ending2 *ending2; // Objeto para gestionar el final del juego
GameOver *gameOver; // Objeto para gestionar el final de la partida
Debug *debug; // Objeto para getsionar la información de debug
struct options_t *options; // Variable con todas las opciones del programa
SDL_Window *window; // La ventana donde dibujamos
SDL_Renderer *renderer; // El renderizador de la ventana
Screen *screen; // Objeto encargado de dibujar en pantalla
Resource *resource; // Objeto con los recursos
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
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
LoadingScreen *loadingScreen; // Objeto para gestionar la introducción del juego
Credits *credits; // Objeto para gestionar los creditos del juego
Demo *demo; // Objeto para gestionar el modo demo, en el que se ven pantallas del juego
Ending *ending; // Objeto para gestionar el final del juego
Ending2 *ending2; // Objeto para gestionar el final del juego
GameOver *gameOver; // Objeto para gestionar el final de la partida
Debug *debug; // Objeto para getsionar la información de debug
Online *online; // Objeto para gestionar la lectura y escritura de datos en el servidor remoto
struct options_t *options; // Variable con todas las opciones del programa
section_t *section; // Sección y subsección actual del programa;
// Variables
section_t section; // Sección y subsección actual del programa;
JA_Music music; // Musica del titulo
JA_Music_t *music; // Musica del titulo
std::string executablePath; // Path del ejecutable
std::string systemFolder; // Carpeta del sistema donde guardar datos
@@ -69,10 +70,10 @@ private:
bool saveConfig();
// Crea la carpeta del sistema donde guardar datos
void createSystemFolder();
void createSystemFolder(std::string folder);
// Carga los recursos
void loadResources(section_t section);
void loadResources(section_t *section);
// Asigna variables a partir de dos cadenas
bool setOptions(options_t *options, std::string var, std::string value);
@@ -89,20 +90,11 @@ private:
// Crea el indice de ficheros
bool setFileList();
// Obtiene el valor de la variable
Uint8 getSubsection();
// Obtiene el valor de la variable
Uint8 getSection();
// Establece el valor de la variable
void setSection(section_t section);
// Ejecuta la seccion de juego con el logo
void runLogo();
// Ejecuta la seccion de juego de la introducción
void runIntro();
// Ejecuta la seccion de juego de la pantalla de carga
void runLoadingScreen();
// Ejecuta la seccion de juego con el titulo y los menus
void runTitle();
@@ -113,9 +105,6 @@ private:
// Ejecuta la seccion de la demo, donde se ven pantallas del juego
void runDemo();
// Ejecuta la seccion en la que se solicita al usuario su ID online
void runEnterID();
// Ejecuta la seccion del final del juego
void runEnding();

View File

@@ -1,9 +1,9 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/animatedsprite.h"
#include "common/asset.h"
#include "common/utils.h"
#include "jail_engine/animatedsprite.h"
#include "jail_engine/asset.h"
#include "jail_engine/utils.h"
#include <string>
#ifndef ENEMY_H

View File

@@ -1,17 +1,18 @@
#include "common/jail_audio.h"
#include "common/jscore.h"
#include "jail_engine/jail_audio.h"
#include "jail_engine/jscore.h"
#include "const.h"
#include "enter_id.h"
#include <iostream>
// Constructor
EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t section)
EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section)
{
// Copia la dirección de los objetos
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->options = options;
this->section = section;
// Reserva memoria para los punteros
eventHandler = new SDL_Event();
@@ -30,22 +31,13 @@ EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t
SDL_SetTextureBlendMode(textTexture, SDL_BLENDMODE_BLEND);
// Inicializa variables
oldJailerID = options->online.jailerID;
loopRunning = true;
counter = 0;
ticks = 0;
ticksSpeed = 15;
pos = 0;
name[pos] = 0;
maxLenght = 15;
this->section.subsection = section.subsection;
if (options->online.enabled && options->online.jailerID == "")
{
this->section.name = SECTION_PROG_ENTER_ID;
}
else
{
endSection();
}
jailerIDPos = 0;
initName();
// Escribe el texto en la textura
fillTexture();
@@ -57,25 +49,22 @@ EnterID::~EnterID()
delete eventHandler;
delete text;
delete texture;
SDL_DestroyTexture(textTexture);
}
// Bucle para el logo del juego
section_t EnterID::run()
void EnterID::run()
{
// Detiene la música
JA_StopMusic();
while (section.name == SECTION_PROG_ENTER_ID)
while (loopRunning)
{
update();
checkEvents();
render();
}
return section;
}
// Comprueba el manejador de eventos
void EnterID::checkEventHandler()
void EnterID::checkEvents()
{
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0)
@@ -83,24 +72,21 @@ void EnterID::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
loopRunning = false;
break;
}
// El ENTER solo se comprueba cuando se suelta, para no saltarse la siguiente sección
if ((eventHandler->type == SDL_KEYUP && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONUP))
{
if (eventHandler->key.keysym.scancode == SDL_SCANCODE_RETURN)
{
options->online.jailerID = (std::string)name;
endSection();
break;
}
}
// Comprueba las teclas que se han pulsado
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
{
if (eventHandler->key.keysym.scancode == SDL_SCANCODE_RETURN)
{
options->online.jailerID = toLower((std::string)name);
endSection();
break;
}
if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_A && eventHandler->key.keysym.scancode <= SDL_SCANCODE_Z)
{ // Si pulsa una letra
if (pos < maxLenght)
@@ -138,7 +124,8 @@ void EnterID::checkEventHandler()
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_ESCAPE)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
loopRunning = false;
break;
}
@@ -184,14 +171,14 @@ void EnterID::update()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Comprueba el manejador de eventos
checkEventHandler();
// Actualiza el contador
counter++;
// Actualiza el cursor
cursor = (counter % 20 >= 10) ? " " : "_";
// Actualiza las notificaciones
screen->updateNotifier();
}
}
@@ -201,16 +188,13 @@ void EnterID::render()
// Prepara para empezar a dibujar en la textura de juego
screen->start();
// Limpia la pantalla
screen->clean();
// Dibuja la textura con el texto en pantalla
SDL_RenderCopy(renderer, textTexture, nullptr, nullptr);
// Escribe el jailerID
const std::string jailerID = (std::string)name + cursor;
const color_t color = stringToColor(options->palette, "white");
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, (16 * 8 + 1), jailerID, 1, color);
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, jailerIDPos, jailerID, 1, color);
// Vuelca el contenido del renderizador en pantalla
screen->blit();
@@ -224,26 +208,18 @@ void EnterID::iniTexts()
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"ONLINE CONFIGURATION:", stringToColor(options->palette, "red")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"YOU HAVE NOT SPECIFIED ANY ID", stringToColor(options->palette, "white")});
texts.push_back({"FOR THE ONLINE SERVICE", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"ONLINE CONFIGURATION:", stringToColor(options->palette, "green")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"PLEASE ENTER AN ID OR", stringToColor(options->palette, "white")});
texts.push_back({"LEAVE BLANK FOR OFFLINE MODE", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"JAILER_ID:", stringToColor(options->palette, "red")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"JAILER_ID:", stringToColor(options->palette, "green")});
jailerIDPos = ((int)texts.size() + 1) * text->getCharacterSize();
}
// Escribe el texto en la textura
@@ -271,29 +247,34 @@ void EnterID::fillTexture()
SDL_SetRenderTarget(renderer, nullptr);
}
// Cambia la paleta
void EnterID::switchPalette()
{
options->palette = options->palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
fillTexture();
}
// Inicializa los servicios online
void EnterID::initOnline()
{
// Si ya ha iniciado la sesión y no ha cambiado el jailerID, que no continue
if (options->online.sessionEnabled)
{
if (oldJailerID == options->online.jailerID)
{
return;
}
}
if (options->online.jailerID == "")
{ // Jailer ID no definido
options->online.enabled = false;
options->online.sessionEnabled = false;
}
else
{ // Jailer ID iniciado
options->online.enabled = true;
options->online.enabled = options->online.sessionEnabled = true;
// Establece el servidor y el puerto
jscore::init(options->online.server, options->online.port);
const std::string caption = options->online.jailerID + " IS LOGGED IN";
screen->showNotification(caption);
#ifdef DEBUG
const std::string caption = "IS LOGGED IN (DEBUG)";
#else
const std::string caption = "IS LOGGED IN";
#endif
screen->showNotification(options->online.jailerID, caption, 12);
if (options->console)
{
std::cout << caption << std::endl;
@@ -304,7 +285,42 @@ void EnterID::initOnline()
// Termina la sección
void EnterID::endSection()
{
loopRunning = false;
initOnline();
section.name = (section.subsection == SUBSECTION_LOGO_TO_INTRO) ? SECTION_PROG_INTRO : SECTION_PROG_TITLE;
section.subsection = 0;
}
}
// Inicializa el vector utilizado para almacenar el texto que se escribe en pantalla
void EnterID::initName()
{
// Calcula el tamaño del vector
name[0] = 0;
maxLenght = sizeof(name) / sizeof(name[pos]);
// Inicializa el vector con ceros
for (int i = 0; i < maxLenght; ++i)
{
name[i] = 0;
}
// Si no hay definido ningun JailerID, coloca el cursor en primera posición
if (options->online.jailerID == "")
{
pos = 0;
}
else
{ // En caso contrario, copia el texto al vector y coloca el cursor en posición
const int len = std::min((int)options->online.jailerID.size(), maxLenght);
for (int i = 0; i < len; ++i)
{
name[i] = (char)options->online.jailerID[i];
}
pos = len;
}
}
// Cambia la paleta
void EnterID::switchPalette()
{
options->palette = options->palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
fillTexture();
}

View File

@@ -1,15 +1,15 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "common/screen.h"
#include "common/utils.h"
#include "common/text.h"
#include "common/texture.h"
#include "jail_engine/asset.h"
#include "jail_engine/screen.h"
#include "jail_engine/utils.h"
#include "jail_engine/text.h"
#include "jail_engine/texture.h"
#include <string>
#include <vector>
#ifndef ENTER_ID_H
#define ASK_ME_H
#define ENTER_ID_H
class EnterID
{
@@ -29,18 +29,21 @@ private:
SDL_Texture *textTexture; // Textura para dibujar el texto
Text *text; // Objeto para escribir texto en pantalla
Texture *texture; // Textura para la fuente para el texto
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables
bool loopRunning; // Indica si ha de terminar el bucle principal
int counter; // Contador
section_t section; // Estado del bucle principal para saber si continua o se sale
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
std::vector<captions_t> texts; // Vector con los textos
std::string cursor; // Contiene el caracter que se muestra como cursor
char name[15];
int pos;
int maxLenght; // Tamaño máximo del jailerID
char name[15]; // Aqui se guardan los caracteres de las teclas que se van pulsando
int pos; // Posición actual en el vector name
int maxLenght; // Tamaño máximo del jailerID
std::string oldJailerID; // Almacena el valor de jailerID al inicio para ver si se ha modificado
int jailerIDPos; // Posición en el eje Y donde ser va a escribir el texto
// Actualiza las variables
void update();
@@ -49,7 +52,7 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Inicializa los textos
void iniTexts();
@@ -57,24 +60,27 @@ private:
// Escribe el texto en la textura
void fillTexture();
// Cambia la paleta
void switchPalette();
// Inicializa los servicios online
void initOnline();
// Termina la sección
void endSection();
// Inicializa el vector utilizado para almacenar el texto que se escribe en pantalla
void initName();
// Cambia la paleta
void switchPalette();
public:
// Constructor
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t section);
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section);
// Destructor
~EnterID();
// Bucle principal
section_t run();
void run();
};
#endif
#endif

View File

@@ -1,15 +1,17 @@
#include "credits.h"
#include "gamestate_credits.h"
#include <iostream>
// Constructor
Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
{
// Copia la dirección de los objetos
this->resource = resource;
this->renderer = renderer;
this->screen = screen;
this->resource = resource;
this->asset = asset;
this->input = input;
this->options = options;
this->section = section;
// Reserva memoria para los punteros
eventHandler = new SDL_Event();
@@ -20,8 +22,8 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
counter = 0;
counterEnabled = true;
subCounter = 0;
section.name = SECTION_PROG_CREDITS;
section.subsection = 0;
section->name = SECTION_CREDITS;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
sprite->setRect({194, 174, 8, 8});
@@ -66,7 +68,7 @@ Credits::~Credits()
}
// Comprueba el manejador de eventos
void Credits::checkEventHandler()
void Credits::checkEvents()
{
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0)
@@ -74,65 +76,71 @@ void Credits::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
break;
}
}
}
// Comprueba las teclas que se han pulsado
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
{
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_QUIT;
break;
// Comprueba las entradas
void Credits::checkInput()
{
case SDL_SCANCODE_B:
screen->switchBorder();
resource->reLoadTextures();
break;
if (input->checkInput(input_exit, REPEAT_FALSE))
{
section->name = SECTION_QUIT;
}
case SDL_SCANCODE_F:
screen->switchVideoMode();
resource->reLoadTextures();
break;
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
{
screen->switchBorder();
}
case SDL_SCANCODE_F1:
screen->setWindowSize(1);
resource->reLoadTextures();
break;
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
}
case SDL_SCANCODE_F2:
screen->setWindowSize(2);
resource->reLoadTextures();
break;
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
}
case SDL_SCANCODE_F3:
screen->setWindowSize(3);
resource->reLoadTextures();
break;
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
}
case SDL_SCANCODE_F4:
screen->setWindowSize(4);
resource->reLoadTextures();
break;
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
{
switchPalette();
}
case SDL_SCANCODE_F5:
switchPalette();
break;
default:
section.name = SECTION_PROG_TITLE;
section.subsection = 0;
break;
}
}
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
{
section->name = SECTION_TITLE;
section->subsection = 0;
}
}
// Inicializa los textos
void Credits::iniTexts()
{
std::string keys = "";
if (options->keys == ctrl_cursor)
{
keys = "CURSORS";
}
else if (options->keys == ctrl_opqa)
{
keys = "O,P AND Q";
}
else
{
keys = "A,D AND W";
}
#ifndef GAME_CONSOLE
texts.clear();
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
@@ -145,12 +153,12 @@ void Credits::iniTexts()
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"CURSORS TO MOVE AND JUMP", stringToColor(options->palette, "white")});
texts.push_back({"M TO TURN ON/OFF THE MUSIC", stringToColor(options->palette, "white")});
texts.push_back({"P TO PAUSE THE GAME", stringToColor(options->palette, "white")});
texts.push_back({"F1-F4 TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")});
texts.push_back({"F TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")});
texts.push_back({"B TO SWITCH THE BORDER SCREEN", stringToColor(options->palette, "white")});
texts.push_back({keys + " TO MOVE AND JUMP", stringToColor(options->palette, "white")});
texts.push_back({"M TO SWITCH THE MUSIC", stringToColor(options->palette, "white")});
texts.push_back({"H TO PAUSE THE GAME", stringToColor(options->palette, "white")});
texts.push_back({"F1-F2 TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")});
texts.push_back({"F3 TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")});
texts.push_back({"B TO TOOGLE THE BORDER SCREEN", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
@@ -161,6 +169,36 @@ void Credits::iniTexts()
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
#else
texts.clear();
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"HELP JAILDOC TO GET BACK ALL", stringToColor(options->palette, "white")});
texts.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options->palette, "white")});
texts.push_back({"JAIL TO FINISH THEM", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"B TO JUMP", stringToColor(options->palette, "white")});
texts.push_back({"R TO SWITCH THE MUSIC", stringToColor(options->palette, "white")});
texts.push_back({"L TO SWAP THE COLOR PALETTE", stringToColor(options->palette, "white")});
texts.push_back({"START TO PAUSE", stringToColor(options->palette, "white")});
texts.push_back({"SELECT TO EXIT", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor(options->palette, "yellow")});
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options->palette, "yellow")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
#endif
}
// Escribe el texto en la textura
@@ -186,7 +224,7 @@ void Credits::fillTexture()
}
// Escribe el corazón
const int textLenght = text->lenght(texts.at(22).label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
const int textLenght = text->lenght(texts[22].label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
const int posX = ((PLAY_AREA_WIDTH - textLenght) / 2) + textLenght;
text->writeColored(posX, 176, "}", stringToColor(options->palette, "bright_red"));
@@ -245,7 +283,7 @@ void Credits::updateCounter()
// Comprueba si ha terminado la sección
if (counter > 1200)
{
section.name = SECTION_PROG_DEMO;
section->name = SECTION_DEMO;
}
}
@@ -258,8 +296,8 @@ void Credits::update()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Comprueba el manejador de eventos
checkEventHandler();
// Comprueba las entradas
checkInput();
// Actualiza el contador
updateCounter();
@@ -304,20 +342,19 @@ void Credits::render()
}
// Bucle para el logo del juego
section_t Credits::run()
void Credits::run()
{
while (section.name == SECTION_PROG_CREDITS)
while (section->name == SECTION_CREDITS)
{
update();
checkEvents();
render();
}
return section;
}
// Cambia la paleta
void Credits::switchPalette()
{
options->palette = options->palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
fillTexture();
options->palette = options->palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
fillTexture();
}

View File

@@ -1,15 +1,16 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/animatedsprite.h"
#include "common/asset.h"
#include "common/jail_audio.h"
#include "common/resource.h"
#include "common/screen.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/texture.h"
#include "common/utils.h"
#include "jail_engine/animatedsprite.h"
#include "jail_engine/asset.h"
#include "jail_engine/input.h"
#include "jail_engine/jail_audio.h"
#include "jail_engine/resource.h"
#include "jail_engine/screen.h"
#include "jail_engine/sprite.h"
#include "jail_engine/text.h"
#include "jail_engine/texture.h"
#include "jail_engine/utils.h"
#include "const.h"
#include <vector>
@@ -30,18 +31,19 @@ private:
Screen *screen; // Objeto encargado de dibujar en pantalla
Resource *resource; // Objeto con los recursos
Asset *asset; // Objeto con los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada
SDL_Event *eventHandler; // Manejador de eventos
Text *text; // Objeto para escribir texto en pantalla
SDL_Texture *textTexture; // Textura para dibujar el texto
SDL_Texture *coverTexture; // Textura para cubrir el texto
AnimatedSprite *sprite; // Sprite para el brillo del corazón
options_t *options; // Puntero a las opciones del juego
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables
int counter; // Contador
bool counterEnabled; // Indica si esta activo el contador
int subCounter; // Contador secundario
section_t section; // Estado del bucle principal para saber si continua o se sale
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
std::vector<captions_t> texts; // Vector con los textos
@@ -53,7 +55,10 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();
// Actualiza el contador
void updateCounter();
@@ -69,13 +74,13 @@ private:
public:
// Constructor
Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
// Destructor
~Credits();
// Bucle principal
section_t run();
void run();
};
#endif

View File

@@ -1,7 +1,7 @@
#include "demo.h"
#include "gamestate_demo.h"
// Constructor
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Debug *debug)
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section, Debug *debug)
{
// Inicia algunas variables
board.iniClock = SDL_GetTicks();
@@ -15,15 +15,17 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
rooms.push_back("44.room");
roomIndex = 0;
currentRoom = rooms.at(roomIndex);
currentRoom = rooms[roomIndex];
// Copia los punteros
this->resource = resource;
this->renderer = renderer;
this->asset = asset;
this->screen = screen;
this->debug = debug;
this->resource = resource;
this->asset = asset;
this->input = input;
this->options = options;
this->section = section;
this->debug = debug;
// Crea los objetos
itemTracker = new ItemTracker();
@@ -40,12 +42,12 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
board.lives = 9;
board.items = 0;
board.rooms = 1;
board.jailEnabled = options->cheat.jailEnabled;
board.jailEnabled = false;
board.music = true;
setScoreBoardColor();
section.name = SECTION_PROG_DEMO;
section.subsection = 0;
section->name = SECTION_DEMO;
section->subsection = 0;
}
Demo::~Demo()
@@ -59,7 +61,7 @@ Demo::~Demo()
}
// Comprueba los eventos de la cola
void Demo::checkEventHandler()
void Demo::checkEvents()
{
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0)
@@ -67,73 +69,67 @@ void Demo::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
screen->setBorderColor(stringToColor(options->palette, "black"));
break;
}
// Comprueba las teclas que se han pulsado
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
{
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_QUIT;
break;
case SDL_SCANCODE_B:
screen->switchBorder();
reLoadTextures();
break;
case SDL_SCANCODE_F:
screen->switchVideoMode();
reLoadTextures();
break;
case SDL_SCANCODE_F1:
screen->setWindowSize(1);
reLoadTextures();
break;
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;
case SDL_SCANCODE_F5:
switchPalette();
break;
default:
section.name = SECTION_PROG_TITLE;
section.subsection = 0;
break;
}
}
}
}
// Bucle para el juego
section_t Demo::run()
// Comprueba las entradas
void Demo::checkInput()
{
while (section.name == SECTION_PROG_DEMO)
if (input->checkInput(input_exit, REPEAT_FALSE))
{
update();
render();
section->name = SECTION_QUIT;
}
return section;
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
{
screen->switchBorder();
reLoadTextures();
}
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
reLoadTextures();
}
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
reLoadTextures();
}
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
reLoadTextures();
}
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
{
switchPalette();
}
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
{
section->name = SECTION_TITLE;
section->subsection = 0;
}
}
// Bucle para el juego
void Demo::run()
{
while (section->name == SECTION_DEMO)
{
update();
checkEvents();
render();
}
}
// Actualiza el juego, las variables, comprueba la entrada, etc.
@@ -145,8 +141,8 @@ void Demo::update()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Comprueba los eventos de la cola
checkEventHandler();
// Comprueba las entradas
checkInput();
// Actualiza los objetos
room->update();
@@ -164,8 +160,8 @@ void Demo::render()
{
// Prepara para dibujar el frame
screen->start();
screen->clean(room->getBGColor());
// Dibuja los elementos del juego en orden
room->renderMap();
room->renderEnemies();
room->renderItems();
@@ -255,12 +251,12 @@ void Demo::checkRoomChange()
roomIndex++;
if (roomIndex == (int)rooms.size())
{
section.name = SECTION_PROG_LOGO;
section.subsection = SUBSECTION_LOGO_TO_TITLE;
section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_TITLE;
}
else
{
changeRoom(rooms.at(roomIndex));
changeRoom(rooms[roomIndex]);
}
}
}

View File

@@ -1,15 +1,16 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/animatedsprite.h"
#include "common/asset.h"
#include "common/debug.h"
#include "common/input.h"
#include "common/resource.h"
#include "common/screen.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/utils.h"
#include "jail_engine/animatedsprite.h"
#include "jail_engine/asset.h"
#include "jail_engine/input.h"
#include "jail_engine/debug.h"
#include "jail_engine/input.h"
#include "jail_engine/resource.h"
#include "jail_engine/screen.h"
#include "jail_engine/sprite.h"
#include "jail_engine/text.h"
#include "jail_engine/utils.h"
#include "const.h"
#include "item_tracker.h"
#include "room_tracker.h"
@@ -29,16 +30,17 @@ private:
Room *room; // Objeto encargado de gestionar cada habitación del juego
Resource *resource; // Objeto con los recursos
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
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
Debug *debug; // Objeto para gestionar la información de debug
options_t *options; // Puntero a las opciones del juego
section_t *section; // Seccion actual dentro del juego
// Variables
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 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
board_t board; // Estructura con los datos del marcador
int counter; // Contador para el modo demo
@@ -53,7 +55,10 @@ private:
void render();
// Comprueba los eventos de la cola
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();
// Escribe el nombre de la pantalla
void renderRoomName();
@@ -75,13 +80,13 @@ private:
public:
// Constructor
Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Debug *debug);
Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section, Debug *debug);
// Destructor
~Demo();
// Bucle para el juego
section_t run();
void run();
};
#endif

View File

@@ -1,14 +1,16 @@
#include "ending.h"
#include "gamestate_ending.h"
// Constructor
Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
{
// Copia los punteros
this->renderer = renderer;
this->screen = screen;
this->resource = resource;
this->asset = asset;
this->input = input;
this->options = options;
this->section = section;
// Reserva memoria para los punteros a objetos
eventHandler = new SDL_Event();
@@ -19,8 +21,8 @@ Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset
counter = -1;
preCounter = 0;
coverCounter = 0;
section.name = SECTION_PROG_ENDING;
section.subsection = 0;
section->name = SECTION_ENDING;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
scene = 0;
@@ -89,8 +91,8 @@ void Ending::update()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Comprueba el manejador de eventos
checkEventHandler();
// Comprueba las entradas
checkInput();
// Actualiza el contador
updateCounters();
@@ -119,16 +121,16 @@ void Ending::render()
screen->clean(stringToColor(options->palette, "black"));
// Dibuja las imagenes de la escena
spritePics.at(scene).sprite->render();
spritePics.at(scene).coverSprite->render();
spritePics[scene].sprite->render();
spritePics[scene].coverSprite->render();
// Dibuja los textos de la escena
for (auto ti : scenes.at(scene).textIndex)
for (auto ti : scenes[scene].textIndex)
{
if (counter > ti.trigger)
{
spriteTexts.at(ti.index).sprite->render();
spriteTexts.at(ti.index).coverSprite->render();
spriteTexts[ti.index].sprite->render();
spriteTexts[ti.index].coverSprite->render();
}
}
@@ -142,7 +144,7 @@ void Ending::render()
}
// Comprueba el manejador de eventos
void Ending::checkEventHandler()
void Ending::checkEvents()
{
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0)
@@ -150,57 +152,45 @@ void Ending::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
break;
}
}
}
// Comprueba las teclas que se han pulsado
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
{
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_QUIT;
break;
// Comprueba las entradas
void Ending::checkInput()
{
case SDL_SCANCODE_B:
screen->switchBorder();
resource->reLoadTextures();
break;
if (input->checkInput(input_exit, REPEAT_FALSE))
{
section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO;
}
case SDL_SCANCODE_F:
screen->switchVideoMode();
resource->reLoadTextures();
break;
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
{
screen->switchBorder();
}
case SDL_SCANCODE_F1:
screen->setWindowSize(1);
resource->reLoadTextures();
break;
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
}
case SDL_SCANCODE_F2:
screen->setWindowSize(2);
resource->reLoadTextures();
break;
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
}
case SDL_SCANCODE_F3:
screen->setWindowSize(3);
resource->reLoadTextures();
break;
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
}
case SDL_SCANCODE_F4:
screen->setWindowSize(4);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F5:
switchPalette();
break;
default:
break;
}
}
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
{
switchPalette();
}
}
@@ -482,20 +472,19 @@ void Ending::iniScenes()
}
// Bucle principal
section_t Ending::run()
void Ending::run()
{
JA_PlayMusic(music);
while (section.name == SECTION_PROG_ENDING)
while (section->name == SECTION_ENDING)
{
update();
checkEvents();
render();
}
JA_StopMusic();
JA_SetVolume(128);
return section;
}
// Actualiza los contadores
@@ -511,7 +500,7 @@ void Ending::updateCounters()
counter++;
}
if (counter > scenes.at(scene).counterEnd - 100)
if (counter > scenes[scene].counterEnd - 100)
{
coverCounter++;
}
@@ -522,20 +511,20 @@ void Ending::updateSpriteCovers()
{ // Actualiza la cortinilla de los textos
if (counter % 4 == 0)
{
for (auto ti : scenes.at(scene).textIndex)
for (auto ti : scenes[scene].textIndex)
{
if (counter > ti.trigger)
{
if (spriteTexts.at(ti.index).clipDesp > 0)
if (spriteTexts[ti.index].clipDesp > 0)
{
spriteTexts.at(ti.index).clipDesp -= 2;
spriteTexts[ti.index].clipDesp -= 2;
}
else if (spriteTexts.at(ti.index).clipHeight > 0)
else if (spriteTexts[ti.index].clipHeight > 0)
{
spriteTexts.at(ti.index).clipHeight -= 2;
spriteTexts.at(ti.index).coverSprite->setPosY(spriteTexts.at(ti.index).coverSprite->getPosY() + 2);
spriteTexts[ti.index].clipHeight -= 2;
spriteTexts[ti.index].coverSprite->setPosY(spriteTexts[ti.index].coverSprite->getPosY() + 2);
}
spriteTexts.at(ti.index).coverSprite->setSpriteClip(0, spriteTexts.at(ti.index).clipDesp, spriteTexts.at(ti.index).coverSprite->getWidth(), spriteTexts.at(ti.index).clipHeight);
spriteTexts[ti.index].coverSprite->setSpriteClip(0, spriteTexts[ti.index].clipDesp, spriteTexts[ti.index].coverSprite->getWidth(), spriteTexts[ti.index].clipHeight);
}
}
}
@@ -543,27 +532,27 @@ void Ending::updateSpriteCovers()
// Actualiza la cortinilla de las imagenes
if (counter % 2 == 0)
{
if (spritePics.at(scene).clipDesp > 0)
if (spritePics[scene].clipDesp > 0)
{
spritePics.at(scene).clipDesp -= 2;
spritePics[scene].clipDesp -= 2;
}
else if (spritePics.at(scene).clipHeight > 0)
else if (spritePics[scene].clipHeight > 0)
{
spritePics.at(scene).clipHeight -= 2;
if (spritePics.at(scene).clipHeight < 0)
spritePics[scene].clipHeight -= 2;
if (spritePics[scene].clipHeight < 0)
{
spritePics.at(scene).clipHeight = 0;
spritePics[scene].clipHeight = 0;
}
spritePics.at(scene).coverSprite->setPosY(spritePics.at(scene).coverSprite->getPosY() + 2);
spritePics[scene].coverSprite->setPosY(spritePics[scene].coverSprite->getPosY() + 2);
}
spritePics.at(scene).coverSprite->setSpriteClip(0, spritePics.at(scene).clipDesp, spritePics.at(scene).coverSprite->getWidth(), spritePics.at(scene).clipHeight);
spritePics[scene].coverSprite->setSpriteClip(0, spritePics[scene].clipDesp, spritePics[scene].coverSprite->getWidth(), spritePics[scene].clipHeight);
}
}
// Comprueba si se ha de cambiar de escena
void Ending::checkChangeScene()
{
if (counter > scenes.at(scene).counterEnd)
if (counter > scenes[scene].counterEnd)
{
scene++;
counter = 0;
@@ -571,7 +560,7 @@ void Ending::checkChangeScene()
if (scene == 5)
{
// Termina el bucle
section.name = SECTION_PROG_ENDING2;
section->name = SECTION_ENDING2;
// Mantiene los valores anteriores
scene = 4;
@@ -639,20 +628,20 @@ void Ending::switchPalette()
{
options->palette = p_zxarne;
spritePics.at(0).sprite->setTexture(resource->getTexture("ending1_zxarne.png"));
spritePics.at(1).sprite->setTexture(resource->getTexture("ending2_zxarne.png"));
spritePics.at(2).sprite->setTexture(resource->getTexture("ending3_zxarne.png"));
spritePics.at(3).sprite->setTexture(resource->getTexture("ending4_zxarne.png"));
spritePics.at(4).sprite->setTexture(resource->getTexture("ending5_zxarne.png"));
spritePics[0].sprite->setTexture(resource->getTexture("ending1_zxarne.png"));
spritePics[1].sprite->setTexture(resource->getTexture("ending2_zxarne.png"));
spritePics[2].sprite->setTexture(resource->getTexture("ending3_zxarne.png"));
spritePics[3].sprite->setTexture(resource->getTexture("ending4_zxarne.png"));
spritePics[4].sprite->setTexture(resource->getTexture("ending5_zxarne.png"));
}
else
{
options->palette = p_zxspectrum;
spritePics.at(0).sprite->setTexture(resource->getTexture("ending1.png"));
spritePics.at(1).sprite->setTexture(resource->getTexture("ending2.png"));
spritePics.at(2).sprite->setTexture(resource->getTexture("ending3.png"));
spritePics.at(3).sprite->setTexture(resource->getTexture("ending4.png"));
spritePics.at(4).sprite->setTexture(resource->getTexture("ending5.png"));
spritePics[0].sprite->setTexture(resource->getTexture("ending1.png"));
spritePics[1].sprite->setTexture(resource->getTexture("ending2.png"));
spritePics[2].sprite->setTexture(resource->getTexture("ending3.png"));
spritePics[3].sprite->setTexture(resource->getTexture("ending4.png"));
spritePics[4].sprite->setTexture(resource->getTexture("ending5.png"));
}
}

View File

@@ -1,14 +1,15 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "common/jail_audio.h"
#include "common/resource.h"
#include "common/screen.h"
#include "common/sprite.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/texture.h"
#include "common/utils.h"
#include "jail_engine/asset.h"
#include "jail_engine/input.h"
#include "jail_engine/jail_audio.h"
#include "jail_engine/resource.h"
#include "jail_engine/screen.h"
#include "jail_engine/sprite.h"
#include "jail_engine/sprite.h"
#include "jail_engine/text.h"
#include "jail_engine/texture.h"
#include "jail_engine/utils.h"
#include "const.h"
#include <string>
#include <vector>
@@ -54,23 +55,24 @@ private:
Screen *screen; // Objeto encargado de dibujar en pantalla
Resource *resource; // Objeto con los recursos
Asset *asset; // Objeto con los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada
options_t *options; // Puntero a las opciones del juego
SDL_Event *eventHandler; // Manejador de eventos
Text *text; // Objeto para escribir texto en pantalla
SDL_Texture *coverTexture; // Textura para cubrir el texto
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables
int counter; // Contador
int preCounter; // Contador previo
int coverCounter; // Contador para la cortinilla
section_t section; // Estado del bucle principal para saber si continua o se sale
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
std::vector<endingTexture_t> spriteTexts; // Vector con los sprites de texto con su cortinilla
std::vector<endingTexture_t> spritePics; // Vector con los sprites de texto con su cortinilla
int scene; // Escena actual
std::vector<scene_t> scenes; // Vector con los textos e imagenes de cada escena
JA_Music music; // Musica que suena durante el final
JA_Music_t *music; // Musica que suena durante el final
// Actualiza el objeto
void update();
@@ -79,7 +81,10 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();
// Inicializa los textos
void iniTexts();
@@ -113,13 +118,13 @@ private:
public:
// Constructor
Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
// Destructor
~Ending();
// Bucle principal
section_t run();
void run();
};
#endif

View File

@@ -1,15 +1,17 @@
#include "ending2.h"
#include "gamestate_ending2.h"
#include <algorithm>
// Constructor
Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
{
// Copia los punteros
this->renderer = renderer;
this->screen = screen;
this->resource = resource;
this->asset = asset;
this->input = input;
this->options = options;
this->section = section;
// Reserva memoria para los punteros a objetos
eventHandler = new SDL_Event();
@@ -21,8 +23,8 @@ Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
preCounter = 0;
postCounter = 0;
postCounterEnabled = false;
section.name = SECTION_PROG_ENDING2;
section.subsection = 0;
section->name = SECTION_ENDING2;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
distSpriteText = 8;
@@ -79,8 +81,8 @@ void Ending2::update()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Comprueba el manejador de eventos
checkEventHandler();
// Comprueba las entradas
checkInput();
// Actualiza los contadores
updateCounters();
@@ -176,7 +178,7 @@ void Ending2::render()
}
// Comprueba el manejador de eventos
void Ending2::checkEventHandler()
void Ending2::checkEvents()
{
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0)
@@ -184,75 +186,62 @@ void Ending2::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
break;
}
// Comprueba las teclas que se han pulsado
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
{
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_QUIT;
break;
case SDL_SCANCODE_B:
screen->switchBorder();
resource->reLoadTextures();
break;
case SDL_SCANCODE_F:
screen->switchVideoMode();
resource->reLoadTextures();
break;
case SDL_SCANCODE_F1:
screen->setWindowSize(1);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F2:
screen->setWindowSize(2);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F3:
screen->setWindowSize(3);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F4:
screen->setWindowSize(4);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F5:
switchPalette();
break;
default:
break;
}
}
}
}
// Comprueba las entradas
void Ending2::checkInput()
{
if (input->checkInput(input_exit, REPEAT_FALSE))
{
section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO;
}
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
{
screen->switchBorder();
}
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
}
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
}
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
}
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
{
switchPalette();
}
}
// Bucle principal
section_t Ending2::run()
void Ending2::run()
{
JA_PlayMusic(music);
while (section.name == SECTION_PROG_ENDING2)
while (section->name == SECTION_ENDING2)
{
update();
checkEvents();
render();
}
JA_StopMusic();
JA_SetVolume(128);
return section;
}
// Actualiza los contadores
@@ -275,8 +264,8 @@ void Ending2::updateCounters()
if (postCounter > 600)
{
section.name = SECTION_PROG_LOGO;
section.subsection = SUBSECTION_LOGO_TO_INTRO;
section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO;
}
}
@@ -288,14 +277,14 @@ void Ending2::iniSpriteList()
// Añade los valores
spriteList.push_back("bin");
spriteList.push_back("diskette");
spriteList.push_back("floppy");
spriteList.push_back("bird");
spriteList.push_back("chip");
spriteList.push_back("jeannine");
spriteList.push_back("spark");
spriteList.push_back("code");
spriteList.push_back("paco");
spriteList.push_back("printer");
spriteList.push_back("elsa");
spriteList.push_back("z80");
spriteList.push_back("bell");
@@ -304,9 +293,9 @@ void Ending2::iniSpriteList()
spriteList.push_back("amstrad_cs");
spriteList.push_back("breakout");
spriteList.push_back("arounder_fly");
spriteList.push_back("arounder_stop");
spriteList.push_back("arounder_walk");
spriteList.push_back("flying_arounder");
spriteList.push_back("stopped_arounder");
spriteList.push_back("walking_arounder");
spriteList.push_back("arounders_door");
spriteList.push_back("arounders_machine");
@@ -324,12 +313,12 @@ void Ending2::iniSpriteList()
spriteList.push_back("dimallas");
spriteList.push_back("guitar");
spriteList.push_back("jb_alien");
spriteList.push_back("jb_human");
spriteList.push_back("jailbattle_alien");
spriteList.push_back("jailbattle_human");
spriteList.push_back("jailer");
spriteList.push_back("jailer2");
spriteList.push_back("jailer3");
spriteList.push_back("jailer_#1");
spriteList.push_back("jailer_#2");
spriteList.push_back("jailer_#3");
spriteList.push_back("bry");
spriteList.push_back("upv_student");
@@ -469,13 +458,13 @@ void Ending2::placeSprites()
{
const int x = i % 2 == 0 ? firstCol : secondCol;
const int y = (i / 1) * (maxSpriteHeight + distSpriteText + text->getCharacterSize() + distSpriteSprite) + GAMECANVAS_HEIGHT + 40;
const int w = sprites.at(i)->getAnimationClip(0, 0).w;
const int h = sprites.at(i)->getAnimationClip(0, 0).h;
const int w = sprites[i]->getAnimationClip(0, 0).w;
const int h = sprites[i]->getAnimationClip(0, 0).h;
const int dx = -(w / 2);
const int dy = i % 1 == 0 ? maxSpriteHeight - h : (int)(maxSpriteHeight * 1.5f) - h;
sprites.at(i)->setRect({x + dx, y + dy, w, h});
sprites.at(i)->setVelY(despSpeed);
sprites[i]->setRect({x + dx, y + dy, w, h});
sprites[i]->setVelY(despSpeed);
}
// Recoloca el último sprite, que es el del jugador
@@ -497,14 +486,14 @@ void Ending2::createSpriteTexts()
for (int i = 0; i < (int)spriteList.size(); ++i)
{
// Calcula constantes
std::string txt = spriteList.at(i);
std::string txt = spriteList[i];
std::replace(txt.begin(), txt.end(), '_', ' ');
txt = txt == "player" ? "JAILDOCTOR" : txt; // Reemplaza el texto
const int w = text->lenght(txt, 1);
const int h = text->getCharacterSize();
const int x = i % 2 == 0 ? firstCol : secondCol;
const int dx = -(w / 2);
const int y = sprites.at(i)->getPosY() + sprites.at(i)->getHeight() + distSpriteText;
const int y = sprites[i]->getPosY() + sprites[i]->getHeight() + distSpriteText;
// Cambia la posición del último sprite
const int X = (i == (int)spriteList.size() - 1) ? GAMECANVAS_CENTER_X - (w / 2) : x + dx;
@@ -536,7 +525,7 @@ void Ending2::createTexts()
for (int i = 0; i < (int)list.size(); ++i)
{
// Calcula constantes
const int w = text->lenght(list.at(i), 1);
const int w = text->lenght(list[i], 1);
const int h = text->getCharacterSize();
const int x = GAMECANVAS_CENTER_X;
const int dx = -(w / 2);
@@ -547,7 +536,7 @@ void Ending2::createTexts()
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
texture->setAsRenderTarget(renderer);
texture->setBlendMode(SDL_BLENDMODE_BLEND);
text->write(0, 0, list.at(i));
text->write(0, 0, list[i]);
// Crea el sprite
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer);
@@ -565,7 +554,7 @@ void Ending2::createTexts()
for (int i = 0; i < (int)list.size(); ++i)
{
// Calcula constantes
const int w = text->lenght(list.at(i), 1);
const int w = text->lenght(list[i], 1);
const int h = text->getCharacterSize();
const int x = GAMECANVAS_CENTER_X;
const int dx = -(w / 2);
@@ -576,7 +565,7 @@ void Ending2::createTexts()
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
texture->setAsRenderTarget(renderer);
texture->setBlendMode(SDL_BLENDMODE_BLEND);
text->write(0, 0, list.at(i));
text->write(0, 0, list[i]);
// Crea el sprite
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer);
@@ -624,7 +613,7 @@ void Ending2::updateFinalFade()
for (auto t : texts)
{
t->getTexture()->setColor(colors.at(index).r, colors.at(index).g, colors.at(index).b);
t->getTexture()->setColor(colors[index].r, colors[index].g, colors[index].b);
}
}

View File

@@ -1,14 +1,15 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/animatedsprite.h"
#include "common/asset.h"
#include "common/jail_audio.h"
#include "common/resource.h"
#include "common/screen.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/texture.h"
#include "common/utils.h"
#include "jail_engine/animatedsprite.h"
#include "jail_engine/asset.h"
#include "jail_engine/input.h"
#include "jail_engine/jail_audio.h"
#include "jail_engine/resource.h"
#include "jail_engine/screen.h"
#include "jail_engine/sprite.h"
#include "jail_engine/text.h"
#include "jail_engine/texture.h"
#include "jail_engine/utils.h"
#include "const.h"
#include <vector>
#include <string>
@@ -25,21 +26,22 @@ private:
Screen *screen; // Objeto encargado de dibujar en pantalla
SDL_Event *eventHandler; // Manejador de eventos
SDL_Renderer *renderer; // El renderizador de la ventana
Input *input; // Objeto pata gestionar la entrada
Text *text; // Objeto para escribir texto en pantalla
options_t *options; // Puntero a las opciones del juego
std::vector<AnimatedSprite *> sprites; // Vector con todos los sprites a dibujar
std::vector<MovingSprite *> spriteTexts; // Vector con los sprites de texto de los sprites
std::vector<MovingSprite *> texts; // Vector con los sprites de texto
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables
bool counterEnabled; // Indica si está el contador habilitado
int preCounter; // Contador previo
int postCounter; // Contador posterior
bool postCounterEnabled; // Indica si está habilitado el contador
section_t section; // Estado del bucle principal para saber si continua o se sale
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
JA_Music music; // Musica que suena durante el final
JA_Music_t *music; // Musica que suena durante el final
std::vector<std::string> spriteList; // Lista con todos los sprites a dibujar
std::vector<color_t> colors; // Vector con los colores para el fade
int maxSpriteWidth; // El valor de ancho del sprite mas ancho
@@ -57,7 +59,10 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();
// Actualiza los contadores
void updateCounters();
@@ -115,13 +120,13 @@ private:
public:
// Constructor
Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
// Destructor
~Ending2();
// Bucle principal
section_t run();
void run();
};
#endif

View File

@@ -1,33 +1,37 @@
#include "game.h"
#include "gamestate_game.h"
#include <iostream>
// Constructor
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug)
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Online *online, options_t *options, Input *input, section_t *section, Debug *debug)
{
// Inicia algunas variables
board.iniClock = SDL_GetTicks();
currentRoom = "03.room";
const int x = 25;
const int y = 13;
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
// Copia los punteros
this->resource = resource;
this->renderer = renderer;
this->asset = asset;
this->online = online;
this->screen = screen;
this->input = input;
this->debug = debug;
this->options = options;
this->section = section;
// Inicia algunas variables
board.iniClock = SDL_GetTicks();
#ifdef DEBUG
currentRoom = "01.room";
const int x1 = 25;
const int y1 = 13;
spawnPoint = {x1 * 8, y1 * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
currentRoom = "03.room";
const int x = 25;
const int y = 13;
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
debug->setEnabled(false);
#else
currentRoom = "03.room";
const int x = 25;
const int y = 13;
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
#endif
// Crea los objetos
cheevos = new Cheevos(screen, options, asset->get("cheevos.bin"), online);
scoreboard = new ScoreBoard(renderer, resource, asset, options, &board);
itemTracker = new ItemTracker();
roomTracker = new RoomTracker();
@@ -40,14 +44,33 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
music = JA_LoadMusic(asset->get("game.ogg").c_str());
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
stats = new Stats(asset->get("stats.csv"), asset->get("stats_buffer.csv"), options);
stats = new Stats(asset->get("stats.csv"), asset->get("stats_buffer.csv"), options, online);
// Crea la textura para poner el nombre de la habitación
roomNameTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, text->getCharacterSize() * 2);
if (roomNameTexture == nullptr)
{
if (options->console)
{
std::cout << "Error: roomNameTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
}
}
// Establece el blend mode de la textura
SDL_SetTextureBlendMode(roomNameTexture, SDL_BLENDMODE_BLEND);
// Establece el destino de la textura
roomNameRect = {0, PLAY_AREA_HEIGHT, GAMECANVAS_WIDTH, text->getCharacterSize() * 2};
// Pone el nombre de la habitación en la textura
fillRoomNameTexture();
// Inicializa el resto de variables
ticks = 0;
ticksSpeed = 15;
board.lives = 9;
#ifdef DEBUG
board.lives = 0;
board.lives = 9;
#endif
board.items = 0;
board.rooms = 1;
@@ -61,14 +84,17 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
totalItems = getTotalItems();
initStats();
stats->addVisit(room->getName());
const bool cheats = options->cheat.infiniteLives || options->cheat.invincible || options->cheat.jailEnabled;
cheevos->enable(!cheats); // Deshabilita los logros si hay trucos activados
section.name = SECTION_PROG_GAME;
section.subsection = 0;
section->name = SECTION_GAME;
section->subsection = 0;
}
Game::~Game()
{
// Libera la memoria de los objetos
delete cheevos;
delete scoreboard;
delete itemTracker;
delete roomTracker;
@@ -78,12 +104,14 @@ Game::~Game()
delete text;
delete stats;
SDL_DestroyTexture(roomNameTexture);
JA_DeleteMusic(music);
JA_DeleteSound(deathSound);
}
// Comprueba los eventos de la cola
void Game::checkEventHandler()
void Game::checkEvents()
{
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0)
@@ -91,7 +119,7 @@ void Game::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
screen->setBorderColor(stringToColor(options->palette, "black"));
break;
}
@@ -101,13 +129,10 @@ void Game::checkEventHandler()
reLoadTextures();
}
if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0))
if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
{
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_TITLE;
break;
#ifdef DEBUG
case SDL_SCANCODE_G:
debug->switchEnabled();
@@ -137,53 +162,21 @@ void Game::checkEventHandler()
break;
case SDL_SCANCODE_F6:
screen->showNotification("MAMA MIRA! SIN MANOS!");
screen->showNotification("ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS", 2);
break;
case SDL_SCANCODE_F7:
screen->showNotification("ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS", 3);
break;
case SDL_SCANCODE_F8:
screen->showNotification("JAILDESIGNER IS LOGGED IN", "", 4);
break;
case SDL_SCANCODE_F9:
screen->showNotification("JAILDESIGNER IS LOGGED IN", "", 5);
break;
#endif
case SDL_SCANCODE_M:
board.music = !board.music;
board.music ? JA_ResumeMusic() : JA_PauseMusic();
break;
case SDL_SCANCODE_P:
switchPause();
break;
case SDL_SCANCODE_B:
screen->switchBorder();
reLoadTextures();
break;
case SDL_SCANCODE_F:
screen->switchVideoMode();
reLoadTextures();
break;
case SDL_SCANCODE_F1:
screen->setWindowSize(1);
reLoadTextures();
break;
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;
case SDL_SCANCODE_F5:
switchPalette();
break;
default:
break;
}
@@ -191,8 +184,57 @@ void Game::checkEventHandler()
}
}
// Comprueba el teclado
void Game::checkInput()
{
if (input->checkInput(input_exit, REPEAT_FALSE))
{
section->name = SECTION_TITLE;
}
else if (input->checkInput(input_switch_music, REPEAT_FALSE))
{
board.music = !board.music;
board.music ? JA_ResumeMusic() : JA_PauseMusic();
}
else if (input->checkInput(input_pause, REPEAT_FALSE))
{
switchPause();
}
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
{
screen->switchBorder();
reLoadTextures();
}
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
reLoadTextures();
}
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
reLoadTextures();
}
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
reLoadTextures();
}
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
{
switchPalette();
}
}
// Bucle para el juego
section_t Game::run()
void Game::run()
{
JA_PlayMusic(music);
if (!board.music)
@@ -200,15 +242,14 @@ section_t Game::run()
JA_PauseMusic();
}
while (section.name == SECTION_PROG_GAME)
while (section->name == SECTION_GAME)
{
update();
checkEvents();
render();
}
JA_StopMusic();
return section;
}
// Actualiza el juego, las variables, comprueba la entrada, etc.
@@ -220,8 +261,8 @@ void Game::update()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Comprueba los eventos de la cola
checkEventHandler();
// Comprueba el teclado
checkInput();
#ifdef DEBUG
debug->clear();
@@ -237,6 +278,7 @@ void Game::update()
checkGameOver();
checkEndGame();
checkRestoringJail();
checkSomeCheevos();
scoreboard->update();
input->update();
@@ -256,8 +298,8 @@ void Game::render()
{
// Prepara para dibujar el frame
screen->start();
screen->clean(room->getBGColor());
// Dibuja los elementos del juego en orden
room->renderMap();
room->renderEnemies();
room->renderItems();
@@ -317,13 +359,8 @@ void Game::renderDebugInfo()
// 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(options->palette, "white");
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
SDL_RenderFillRect(renderer, &rect);
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, 16 * 8 + 4, room->getName(), 1, room->getBGColor());
// Dibuja la textura con el nombre de la habitación
SDL_RenderCopy(renderer, roomNameTexture, nullptr, &roomNameRect);
}
// Cambia de habitación
@@ -345,6 +382,9 @@ bool Game::changeRoom(std::string file)
// Crea un objeto habitación nuevo a partir del fichero
room = new Room(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
// Pone el nombre de la habitación en la textura
fillRoomNameTexture();
// Pone el color del marcador en función del color del borde de la habitación
setScoreBoardColor();
@@ -413,7 +453,7 @@ void Game::checkGameOver()
{
if (board.lives < 0 && blackScreenCounter > 17)
{
section.name = SECTION_PROG_GAME_OVER;
section->name = SECTION_GAME_OVER;
}
}
@@ -434,6 +474,9 @@ void Game::killPlayer()
// Actualiza las estadisticas
stats->addDeath(room->getName());
// Invalida el logro de pasarse el juego sin morir
cheevos->invalidate(11);
// Destruye la habitacion y el jugador
delete room;
delete this->player;
@@ -539,24 +582,21 @@ void Game::setScoreBoardColor()
// Comprueba si ha finalizado el juego
bool Game::checkEndGame()
{
const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca
const bool haveTheItems = board.items >= int(totalItems * 0.9f); // Con mas del 90% de los items recogidos
const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca
const bool haveTheItems = board.items >= int(totalItems * 0.9f) || options->cheat.jailEnabled; // Con mas del 90% de los items recogidos
const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
if (haveTheItems)
{
board.jailEnabled = true;
}
if (isOnTheRoom && haveTheItems && isOnTheDoor)
if (haveTheItems && isOnTheRoom && isOnTheDoor)
{
section.name = SECTION_PROG_ENDING;
return true;
}
// Comprueba los logros de completar el juego
checkEndGameCheevos();
if (options->cheat.jailEnabled && isOnTheRoom && isOnTheDoor)
{
section.name = SECTION_PROG_ENDING;
section->name = SECTION_ENDING;
return true;
}
@@ -616,12 +656,25 @@ void Game::checkRestoringJail()
}
static int counter = 0;
counter++;
if (!paused)
{
counter++;
}
// Incrementa el numero de vidas
if (counter == 100)
{
counter = 0;
board.lives++;
JA_PlaySound(deathSound);
// Invalida el logro de completar el juego sin entrar a la jail
const bool haveTheItems = board.items >= int(totalItems * 0.9f);
if (!haveTheItems)
{
cheevos->invalidate(9);
}
}
}
@@ -637,4 +690,92 @@ void Game::initStats()
}
stats->init();
}
// Crea la textura con el nombre de la habitación
void Game::fillRoomNameTexture()
{
// Pone la textura como destino de renderizado
SDL_SetRenderTarget(renderer, roomNameTexture);
// Rellena la textura de color
const color_t color = stringToColor(options->palette, "white");
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
SDL_RenderClear(renderer);
// Escribe el texto en la textura
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, text->getCharacterSize() / 2, room->getName(), 1, room->getBGColor());
// Deja el renderizador por defecto
SDL_SetRenderTarget(renderer, nullptr);
}
// Comprueba algunos logros
void Game::checkSomeCheevos()
{
// Logros sobre la cantidad de items
if (board.items == totalItems)
{
cheevos->unlock(4);
cheevos->unlock(3);
cheevos->unlock(2);
cheevos->unlock(1);
}
else if (board.items >= totalItems * 0.75f)
{
cheevos->unlock(3);
cheevos->unlock(2);
cheevos->unlock(1);
}
else if (board.items >= totalItems * 0.5f)
{
cheevos->unlock(2);
cheevos->unlock(1);
}
else if (board.items >= totalItems * 0.25f)
{
cheevos->unlock(1);
}
// Logros sobre las habitaciones visitadas
if (board.rooms >= 60)
{
cheevos->unlock(7);
cheevos->unlock(6);
cheevos->unlock(5);
}
else if (board.rooms >= 40)
{
cheevos->unlock(6);
cheevos->unlock(5);
}
else if (board.rooms >= 20)
{
cheevos->unlock(5);
}
}
// Comprueba los logros de completar el juego
void Game::checkEndGameCheevos()
{
// "Complete the game"
cheevos->unlock(8);
// "Complete the game without entering the jail"
cheevos->unlock(9);
// "Complete the game with all items"
if (board.items == totalItems)
{
cheevos->unlock(10);
}
// "Complete the game without dying"
cheevos->unlock(11);
// "Complete the game in under 30 minutes"
if (scoreboard->getMinutes() < 30)
{
cheevos->unlock(12);
}
}

View File

@@ -1,16 +1,17 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/animatedsprite.h"
#include "common/asset.h"
#include "common/debug.h"
#include "common/input.h"
#include "common/jail_audio.h"
#include "common/resource.h"
#include "common/screen.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/utils.h"
#include "cheevos.h"
#include "jail_engine/animatedsprite.h"
#include "jail_engine/asset.h"
#include "jail_engine/debug.h"
#include "jail_engine/input.h"
#include "jail_engine/jail_audio.h"
#include "jail_engine/resource.h"
#include "jail_engine/screen.h"
#include "jail_engine/sprite.h"
#include "jail_engine/text.h"
#include "jail_engine/utils.h"
#include "const.h"
#include "item_tracker.h"
#include "player.h"
@@ -18,6 +19,7 @@
#include "room.h"
#include "scoreboard.h"
#include "stats.h"
#include "online.h"
#ifndef GAME_H
#define GAME_H
@@ -26,35 +28,39 @@ class Game
{
private:
// Objetos y punteros
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
Resource *resource; // Objeto con los recursos
Debug *debug; // Objeto para gestionar la información de debug
options_t *options; // Puntero a las opciones del juego
Stats *stats; // Objeto encargado de gestionar las estadísticas
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
Online *online; // Objeto para gestionar la lectura y escritura de datos en el servidor remoto
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
Cheevos *cheevos; // Objeto encargado de gestionar los logros del juego
Resource *resource; // Objeto con los recursos
Debug *debug; // Objeto para gestionar la información de debug
options_t *options; // Puntero a las opciones del juego
Stats *stats; // Objeto encargado de gestionar las estadísticas
SDL_Texture *roomNameTexture; // Textura para escribir el nombre de la habitación
section_t *section; // Seccion actual dentro del juego
// Variables
JA_Music music; // Musica que suena durante el juego
JA_Music_t *music; // Musica que suena durante el juego
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 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
playerSpawn_t spawnPoint; // Lugar de la habitación donde aparece el jugador
JA_Sound deathSound; // Sonido a reproducir cuando muere el jugador
JA_Sound_t *deathSound; // Sonido a reproducir cuando muere el jugador
board_t board; // Estructura con los datos del marcador
bool paused; // Indica si el juego se encuentra en pausa
bool blackScreen; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador
int blackScreenCounter; // Contador para temporizar la pantalla en negro
int totalItems; // Cantidad total de items que hay en el mapeado del juego
SDL_Rect roomNameRect; // Rectangulo donde pintar la textura con el nombre de la habitación
// Actualiza el juego, las variables, comprueba la entrada, etc.
void update();
@@ -63,7 +69,7 @@ private:
void render();
// Comprueba los eventos de la cola
void checkEventHandler();
void checkEvents();
#ifdef DEBUG
// Pone la información de debug en pantalla
@@ -79,6 +85,9 @@ private:
// Cambia de habitación
bool changeRoom(std::string file);
// Comprueba el teclado
void checkInput();
// Comprueba si el jugador esta en el borde de la pantalla y actua
void checkPlayerOnBorder();
@@ -133,15 +142,24 @@ private:
// Inicializa el diccionario de las estadísticas
void initStats();
// Pone el nombre de la habitación en la textura
void fillRoomNameTexture();
// Comprueba algunos logros
void checkSomeCheevos();
// Comprueba los logros de completar el juego
void checkEndGameCheevos();
public:
// Constructor
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug);
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Online *online, options_t *options, Input *input, section_t *section, Debug *debug);
// Destructor
~Game();
// Bucle para el juego
section_t run();
void run();
};
#endif

View File

@@ -1,14 +1,16 @@
#include "game_over.h"
#include "gamestate_game_over.h"
// Constructor
GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
{
// Copia los punteros
this->renderer = renderer;
this->screen = screen;
this->resource = resource;
this->asset = asset;
this->input = input;
this->options = options;
this->section = section;
// Reserva memoria para los punteros a objetos
eventHandler = new SDL_Event();
@@ -20,8 +22,8 @@ GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, A
// Inicializa variables
preCounter = 0;
counter = 0;
section.name = SECTION_PROG_GAME_OVER;
section.subsection = 0;
section->name = SECTION_GAME_OVER;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
endSection = 400;
@@ -61,8 +63,8 @@ void GameOver::update()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Comprueba el manejador de eventos
checkEventHandler();
// Comprueba las entradas
checkInput();
// Actualiza el color usado para renderizar los textos e imagenes
updateColor();
@@ -83,7 +85,7 @@ void GameOver::update()
void GameOver::render()
{
const int y = 32;
// Prepara para empezar a dibujar en la textura de juego
screen->start();
@@ -113,7 +115,7 @@ void GameOver::render()
}
// Comprueba el manejador de eventos
void GameOver::checkEventHandler()
void GameOver::checkEvents()
{
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0)
@@ -121,71 +123,57 @@ void GameOver::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section.subsection = 0;
section->name = SECTION_QUIT;
section->subsection = 0;
break;
}
// Comprueba las teclas que se han pulsado
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
{
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_QUIT;
break;
case SDL_SCANCODE_B:
screen->switchBorder();
resource->reLoadTextures();
break;
case SDL_SCANCODE_F:
screen->switchVideoMode();
resource->reLoadTextures();
break;
case SDL_SCANCODE_F1:
screen->setWindowSize(1);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F2:
screen->setWindowSize(2);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F3:
screen->setWindowSize(3);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F4:
screen->setWindowSize(4);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F5:
switchPalette();
break;
default:
break;
}
}
}
}
// Bucle principal
section_t GameOver::run()
// Comprueba las entradas
void GameOver::checkInput()
{
while (section.name == SECTION_PROG_GAME_OVER)
if (input->checkInput(input_exit, REPEAT_FALSE))
{
update();
render();
section->name = SECTION_QUIT;
}
return section;
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
{
screen->switchBorder();
}
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
}
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
}
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
}
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
{
switchPalette();
}
}
// Bucle principal
void GameOver::run()
{
while (section->name == SECTION_GAME_OVER)
{
update();
checkEvents();
render();
}
}
// Actualiza el color usado para renderizar los textos e imagenes
@@ -195,16 +183,15 @@ void GameOver::updateColor()
if (counter < half)
{
// const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
const float step = std::min(counter, fadeLenght) / (float)fadeLenght;
const int index = (colors.size() - 1) - int((colors.size() - 1) * step);
color = colors.at(index);
color = colors[index];
}
else
{
const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
const int index = (colors.size() - 1) * step;
color = colors.at(index);
color = colors[index];
}
}
@@ -240,8 +227,8 @@ void GameOver::updateCounters()
// Comprueba si ha terminado la sección
else if (counter == endSection)
{
section.name = SECTION_PROG_LOGO;
section.subsection = SUBSECTION_LOGO_TO_TITLE;
section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_TITLE;
}
}

View File

@@ -1,14 +1,15 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/animatedsprite.h"
#include "common/asset.h"
#include "common/jail_audio.h"
#include "common/resource.h"
#include "common/screen.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/texture.h"
#include "common/utils.h"
#include "jail_engine/animatedsprite.h"
#include "jail_engine/asset.h"
#include "jail_engine/input.h"
#include "jail_engine/jail_audio.h"
#include "jail_engine/resource.h"
#include "jail_engine/screen.h"
#include "jail_engine/sprite.h"
#include "jail_engine/text.h"
#include "jail_engine/texture.h"
#include "jail_engine/utils.h"
#include "const.h"
#include <vector>
@@ -23,16 +24,17 @@ private:
Screen *screen; // Objeto encargado de dibujar en pantalla
Resource *resource; // Objeto con los recursos
Asset *asset; // Objeto con los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada
options_t *options; // Puntero a las opciones del juego
SDL_Event *eventHandler; // Manejador de eventos
Text *text; // Objeto para escribir texto en pantalla
AnimatedSprite *playerSprite; // Sprite con el jugador
AnimatedSprite *tvSprite; // Sprite con el televisor
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables
int preCounter; // Contador previo
int counter; // Contador
section_t section; // Estado del bucle principal para saber si continua o se sale
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
std::vector<color_t> colors; // Vector con los colores para el fade
@@ -40,7 +42,7 @@ private:
int endSection; // Contador: cuando acaba la sección
int iniFade; // Contador: cuando emiepza el fade
int fadeLenght; // Contador: duración del fade
JA_Music music; // Musica que suena durante el juego
JA_Music_t *music; // Musica que suena durante el juego
// Actualiza el objeto
void update();
@@ -49,7 +51,10 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();
// Actualiza el color usado para renderizar los textos e imagenes
void updateColor();
@@ -65,13 +70,13 @@ private:
public:
// Constructor
GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
// Destructor
~GameOver();
// Bucle principal
section_t run();
void run();
};
#endif

View File

@@ -0,0 +1,358 @@
#include "gamestate_loading_screen.h"
// Constructor
LoadingScreen::LoadingScreen(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
{
// Copia la dirección de los objetos
this->resource = resource;
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->input = input;
this->options = options;
this->section = section;
// Reserva memoria para los punteros
eventHandler = new SDL_Event();
if (options->palette == p_zxspectrum)
{
loadingScreenTexture1 = resource->getTexture("loading_screen_bn.png");
loadingScreenTexture2 = resource->getTexture("loading_screen_color.png");
}
else if (options->palette == p_zxarne)
{
loadingScreenTexture1 = resource->getTexture("loading_screen_bn_zxarne.png");
loadingScreenTexture2 = resource->getTexture("loading_screen_color_zxarne.png");
}
sprite1 = new Sprite(0, 0, loadingScreenTexture1->getWidth(), loadingScreenTexture1->getHeight(), loadingScreenTexture1, renderer);
sprite2 = new Sprite(0, 0, loadingScreenTexture2->getWidth(), loadingScreenTexture2->getHeight(), loadingScreenTexture2, 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_LOADING_SCREEN;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
loadCounter = 0;
loadingFirstPart = true;
loadRect = {0, 0, 51, 1};
// Establece el orden de las lineas para imitar el direccionamiento de memoria del spectrum
for (int i = 0; i < 192; ++i)
{
if (i < 64)
{ // Primer bloque de 2K
lineIndex[i] = ((i % 8) * 8) + (i / 8);
}
else if (i >= 64 && i < 128)
{ // Segundo bloque de 2K
lineIndex[i] = 64 + ((i % 8) * 8) + ((i - 64) / 8);
}
else if (i >= 128 && i < 192)
{ // tercer bloque de 2K
lineIndex[i] = 128 + ((i % 8) * 8) + ((i - 128) / 8);
}
}
// Cambia el color del borde
screen->setBorderColor(stringToColor(options->palette, "black"));
}
// Destructor
LoadingScreen::~LoadingScreen()
{
delete sprite1;
delete sprite2;
delete eventHandler;
JA_DeleteMusic(loadingSound1);
JA_DeleteMusic(loadingSound2);
JA_DeleteMusic(loadingSound3);
}
// Comprueba el manejador de eventos
void LoadingScreen::checkEvents()
{
// 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_QUIT;
break;
}
}
}
// Comprueba las entradas
void LoadingScreen::checkInput()
{
if (input->checkInput(input_exit, REPEAT_FALSE))
{
section->name = SECTION_QUIT;
}
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
{
screen->switchBorder();
}
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
}
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
}
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
}
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
{
switchPalette();
}
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
{
section->name = SECTION_TITLE;
section->subsection = 0;
}
}
// Gestiona el contador de carga
void LoadingScreen::updateLoad()
{
// Primera parte de la carga, la parte en blanco y negro
if (loadingFirstPart)
{
// Cada 5 pasos el loadCounter se incrementa en uno
const int numSteps = 5;
const int step = 51;
loadCounter = counter / numSteps;
if (loadCounter < 192)
{
loadRect.x = step * (counter % numSteps);
loadRect.y = lineIndex[loadCounter];
sprite1->setSpriteClip(loadRect);
sprite1->setRect(loadRect);
}
// Una vez actualizadas las 192 lineas, pasa a la segunda fase de la carga
else if (loadCounter == 192)
{
loadingFirstPart = false;
loadCounter = 0;
loadRect = {0, 0, 16, 8};
sprite2->setRect(loadRect);
sprite2->setSpriteClip(loadRect);
JA_PlayMusic(loadingSound3);
}
}
// Segunda parte de la carga, la parte de los bloques en color
else
{
loadCounter += 2;
loadRect.x = (loadCounter * 8) % 256;
loadRect.y = (loadCounter / 32) * 8;
sprite2->setSpriteClip(loadRect);
sprite2->setRect(loadRect);
// Comprueba si ha terminado la intro
if (loadCounter >= 768)
{
section->name = SECTION_TITLE;
section->subsection = SUBSECTION_TITLE_WITH_LOADING_SCREEN;
JA_StopMusic();
}
}
}
// Gestiona el contador interno
void LoadingScreen::updateCounter()
{
(preCounter >= 50) ? counter++ : preCounter++;
if (counter == 1)
{
JA_PlayMusic(loadingSound2);
}
}
// Dibuja la pantalla de carga
void LoadingScreen::renderLoad()
{
loadingFirstPart ? sprite1->render() : sprite2->render();
}
// Dibuja el efecto de carga en el borde
void LoadingScreen::renderBorder()
{
// Pinta el borde de colro azul
color_t color = stringToColor(options->palette, "blue");
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
SDL_RenderClear(renderer);
// Añade lineas amarillas
color = stringToColor(options->palette, "yellow");
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
const int width = GAMECANVAS_WIDTH + (options->borderWidth * 2);
const int height = GAMECANVAS_HEIGHT + (options->borderHeight * 2);
bool drawEnabled = rand() % 2 == 0 ? true : false;
// for (int i = 0; i < height; ++i)
//{
// if (rand() % 2 == 0)
// {
// SDL_RenderDrawLine(renderer, 0, i, width, i);
// }
// }
int row = 0;
int rowSize = 1;
while (row < height)
{
rowSize = (rand() % 4) + 3;
if (drawEnabled)
for (int i = row; i < row + rowSize; ++i)
{
SDL_RenderDrawLine(renderer, 0, i, width, i);
}
row += rowSize;
drawEnabled = !drawEnabled;
}
}
// Actualiza las variables
void LoadingScreen::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 las entradas
checkInput();
// Gestiona el contador interno
updateCounter();
// Gestiona el contador de carga
updateLoad();
// Actualiza las notificaciones
screen->updateNotifier();
}
}
// Dibuja en pantalla
void LoadingScreen::render()
{
if (options->borderEnabled)
{
// Prepara para empezar a dibujar en la textura del borde
screen->startDrawOnBorder();
// Dibuja el efecto de carga en el borde
renderBorder();
}
// Prepara para empezar a dibujar en la textura de juego
screen->start();
// Dibuja la pantalla de carga
renderLoad();
// Vuelca el contenido del renderizador en pantalla
screen->blit();
}
// Bucle para el logo del juego
void LoadingScreen::run()
{
// Inicia el sonido de carga
JA_SetVolume(64);
JA_PlayMusic(loadingSound1);
// Limpia la pantalla
screen->start();
screen->clean();
screen->blit();
while (section->name == SECTION_LOADING_SCREEN)
{
update();
checkEvents();
render();
}
JA_SetVolume(128);
}
// Cambia la paleta
void LoadingScreen::switchPalette()
{
if (options->palette == p_zxspectrum)
{
options->palette = p_zxarne;
sprite1->setTexture(resource->getTexture("loading_screen_bn_zxarne.png"));
sprite2->setTexture(resource->getTexture("loading_screen_color_zxarne.png"));
}
else
{
options->palette = p_zxspectrum;
sprite1->setTexture(resource->getTexture("loading_screen_bn.png"));
sprite2->setTexture(resource->getTexture("loading_screen_color.png"));
}
recreateLoadingScreen();
}
// Reconstruye la pantalla de carga
void LoadingScreen::recreateLoadingScreen()
{
// Prepara para empezar a dibujar en la textura de juego
screen->start();
// Primera parte de la carga, la parte en blanco y negro
if (loadingFirstPart)
{
const int numSteps = 5;
const int step = 51;
for (int i = 0; i <= counter; i++)
{
loadCounter = i / numSteps;
loadRect.x = step * (i % numSteps);
loadRect.y = lineIndex[loadCounter];
sprite1->setSpriteClip(loadRect);
sprite1->setRect(loadRect);
sprite1->render();
}
}
// Segunda parte de la carga, la parte de los bloques en color
else
{
for (int i = 0; i <= loadCounter; i++)
{
loadRect.x = (i * 8) % 256;
loadRect.y = (i / 32) * 8;
sprite2->setSpriteClip(loadRect);
sprite2->setRect(loadRect);
sprite2->render();
}
}
// Vuelca el contenido del renderizador en pantalla
screen->blit();
}

View File

@@ -0,0 +1,91 @@
#pragma once
#include <SDL2/SDL.h>
#include "jail_engine/asset.h"
#include "jail_engine/input.h"
#include "jail_engine/jail_audio.h"
#include "jail_engine/resource.h"
#include "jail_engine/screen.h"
#include "jail_engine/sprite.h"
#include "jail_engine/utils.h"
#include "const.h"
#include <vector>
#include <string>
#include "jail_engine/text.h"
#ifndef LOADING_SCREEN_H
#define LOADING_SCREEN_H
class LoadingScreen
{
private:
// Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana
Screen *screen; // Objeto encargado de dibujar en pantalla
Resource *resource; // Objeto con los recursos
Asset *asset; // Objeto con los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada
Texture *loadingScreenTexture1; // Textura con la pantalla de carga en blanco y negro
Texture *loadingScreenTexture2; // Textura con la pantalla de carga en color
SDL_Event *eventHandler; // Manejador de eventos
Sprite *sprite1; // Sprite para manejar la textura loadingScreenTexture1
Sprite *sprite2; // Sprite para manejar la textura loadingScreenTexture2
options_t *options; // Puntero a las opciones del juego
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables
int preCounter; // Contador previo para realizar una pausa inicial
int counter; // Contador
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
int loadCounter; // Contador para controlar las cargas
bool loadingFirstPart; // Para saber en que parte de la carga se encuentra
JA_Music_t *loadingSound1; // Sonidos para imitar la carga tipo spectrum
JA_Music_t *loadingSound2; // Sonidos para imitar la carga tipo spectrum
JA_Music_t *loadingSound3; // Sonidos para imitar la carga tipo spectrum
int lineIndex[192]; // El orden en el que se procesan las 192 lineas de la pantalla de carga
SDL_Rect loadRect; // Rectangulo para dibujar la pantalla de carga
// Actualiza las variables
void update();
// Dibuja en pantalla
void render();
// Comprueba el manejador de eventos
void checkEvents();
// Comprueba las entradas
void checkInput();
// Gestiona el contador interno
void updateCounter();
// Gestiona el contador de carga
void updateLoad();
// Dibuja la pantalla de carga
void renderLoad();
// Dibuja el efecto de carga en el borde
void renderBorder();
// Cambia la paleta
void switchPalette();
// Reconstruye la pantalla de carga
void recreateLoadingScreen();
public:
// Constructor
LoadingScreen(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
// Destructor
~LoadingScreen();
// Bucle principal
void run();
};
#endif

View File

@@ -1,15 +1,17 @@
#include "logo.h"
#include "gamestate_logo.h"
#include <iostream>
// Constructor
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, int subsection)
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
{
// Copia la dirección de los objetos
this->resource = resource;
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->input = input;
this->options = options;
this->section = section;
// Reserva memoria para los punteros
eventHandler = new SDL_Event();
@@ -26,19 +28,18 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
sprite.back()->setSpriteClip(0, i, texture->getWidth(), 1);
if (i % 2 == 0)
{
sprite.at(i)->setPosX(256 + (i * 3));
sprite[i]->setPosX(256 + (i * 3));
}
else
{
sprite.at(i)->setPosX(-181 - (i * 3));
sprite[i]->setPosX(-181 - (i * 3));
}
sprite.at(i)->setPosY(83 + i);
sprite[i]->setPosY(83 + i);
}
// Inicializa variables
counter = 0;
section.name = SECTION_PROG_LOGO;
section.subsection = subsection;
section->name = SECTION_LOGO;
ticks = 0;
ticksSpeed = 15;
initFade = 300;
@@ -69,7 +70,7 @@ Logo::~Logo()
}
// Comprueba el manejador de eventos
void Logo::checkEventHandler()
void Logo::checkEvents()
{
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0)
@@ -77,59 +78,49 @@ void Logo::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_QUIT;
break;
}
}
}
// Comprueba las teclas que se han pulsado
if ((eventHandler->type == SDL_KEYUP && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONUP))
{
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_QUIT;
break;
// Comprueba las entradas
void Logo::checkInput()
{
if (input->checkInput(input_exit, REPEAT_FALSE))
{
section->name = SECTION_TITLE;
}
case SDL_SCANCODE_B:
screen->switchBorder();
resource->reLoadTextures();
break;
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
{
screen->switchBorder();
}
case SDL_SCANCODE_F:
screen->switchVideoMode();
resource->reLoadTextures();
break;
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
}
case SDL_SCANCODE_F1:
screen->setWindowSize(1);
resource->reLoadTextures();
break;
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
}
case SDL_SCANCODE_F2:
screen->setWindowSize(2);
resource->reLoadTextures();
break;
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
}
case SDL_SCANCODE_F3:
screen->setWindowSize(3);
resource->reLoadTextures();
break;
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
{
switchPalette();
}
case SDL_SCANCODE_F4:
screen->setWindowSize(4);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F5:
switchPalette();
break;
default:
section.subsection = SUBSECTION_LOGO_TO_TITLE;
endSection();
break;
}
}
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
{
section->subsection = SUBSECTION_LOGO_TO_TITLE;
endSection();
}
}
@@ -142,22 +133,22 @@ void Logo::updateJAILGAMES()
{
const int speed = 8;
const int dest = 37;
if (sprite.at(i)->getPosX() != 37)
if (sprite[i]->getPosX() != 37)
{
if (i % 2 == 0)
{
sprite.at(i)->incPosX(-speed);
if (sprite.at(i)->getPosX() < dest)
sprite[i]->incPosX(-speed);
if (sprite[i]->getPosX() < dest)
{
sprite.at(i)->setPosX(dest);
sprite[i]->setPosX(dest);
}
}
else
{
sprite.at(i)->incPosX(speed);
if (sprite.at(i)->getPosX() > dest)
sprite[i]->incPosX(speed);
if (sprite[i]->getPosX() > dest)
{
sprite.at(i)->setPosX(dest);
sprite[i]->setPosX(dest);
}
}
}
@@ -173,72 +164,84 @@ void Logo::updateTextureColors()
if (counter == ini + inc * 0)
{
texture2->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
texture2->setColor(color[0].r, color[0].g, color[0].b);
}
else if (counter == ini + inc * 1)
{
texture2->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
texture2->setColor(color[1].r, color[1].g, color[1].b);
}
else if (counter == ini + inc * 2)
{
texture2->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
texture2->setColor(color[2].r, color[2].g, color[2].b);
}
else if (counter == ini + inc * 3)
{
texture2->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
texture2->setColor(color[3].r, color[3].g, color[3].b);
}
else if (counter == ini + inc * 4)
{
texture2->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
texture2->setColor(color[4].r, color[4].g, color[4].b);
}
else if (counter == ini + inc * 5)
{
texture2->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
texture2->setColor(color[5].r, color[5].g, color[5].b);
}
else if (counter == ini + inc * 6)
{
texture2->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
texture2->setColor(color[6].r, color[6].g, color[6].b);
}
else if (counter == ini + inc * 7)
{
texture2->setColor(color.at(7).r, color.at(7).g, color.at(7).b);
texture2->setColor(color[7].r, color[7].g, color[7].b);
}
else if (counter == initFade + inc * 0)
{
texture->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
texture2->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
texture->setColor(color[6].r, color[6].g, color[6].b);
texture2->setColor(color[6].r, color[6].g, color[6].b);
}
else if (counter == initFade + inc * 1)
{
texture->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
texture2->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
texture->setColor(color[5].r, color[5].g, color[5].b);
texture2->setColor(color[5].r, color[5].g, color[5].b);
}
else if (counter == initFade + inc * 2)
{
texture->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
texture2->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
texture->setColor(color[4].r, color[4].g, color[4].b);
texture2->setColor(color[4].r, color[4].g, color[4].b);
}
else if (counter == initFade + inc * 3)
{
texture->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
texture2->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
texture->setColor(color[3].r, color[3].g, color[3].b);
texture2->setColor(color[3].r, color[3].g, color[3].b);
}
else if (counter == initFade + inc * 4)
{
texture->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
texture2->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
texture->setColor(color[2].r, color[2].g, color[2].b);
texture2->setColor(color[2].r, color[2].g, color[2].b);
}
else if (counter == initFade + inc * 5)
{
texture->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
texture2->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
texture->setColor(color[1].r, color[1].g, color[1].b);
texture2->setColor(color[1].r, color[1].g, color[1].b);
}
else if (counter == initFade + inc * 6)
{
texture->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
texture2->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
texture->setColor(color[0].r, color[0].g, color[0].b);
texture2->setColor(color[0].r, color[0].g, color[0].b);
}
}
@@ -251,8 +254,8 @@ void Logo::update()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Comprueba el manejador de eventos
checkEventHandler();
// Comprueba las entradas
checkInput();
// Incrementa el contador
counter++;
@@ -295,18 +298,17 @@ void Logo::render()
}
// Bucle para el logo del juego
section_t Logo::run()
void Logo::run()
{
// Detiene la música
JA_StopMusic();
while (section.name == SECTION_PROG_LOGO)
while (section->name == SECTION_LOGO)
{
update();
checkEvents();
render();
}
return section;
}
// Cambia la paleta
@@ -318,5 +320,13 @@ void Logo::switchPalette()
// Termina la sección
void Logo::endSection()
{
section.name = SECTION_PROG_ENTER_ID;
if (section->subsection == SUBSECTION_LOGO_TO_TITLE)
{
section->name = SECTION_TITLE;
}
else if (section->subsection == SUBSECTION_LOGO_TO_INTRO)
{
section->name = SECTION_LOADING_SCREEN;
}
}

View File

@@ -1,12 +1,13 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "common/jail_audio.h"
#include "common/resource.h"
#include "common/screen.h"
#include "common/sprite.h"
#include "common/utils.h"
#include "jail_engine/asset.h"
#include "jail_engine/input.h"
#include "jail_engine/jail_audio.h"
#include "jail_engine/resource.h"
#include "jail_engine/screen.h"
#include "jail_engine/sprite.h"
#include "jail_engine/utils.h"
#include "const.h"
#include <vector>
@@ -21,17 +22,18 @@ private:
Screen *screen; // Objeto encargado de dibujar en pantalla
Resource *resource; // Objeto con los recursos
Asset *asset; // Objeto con los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada
Texture *texture; // Textura con los graficos "JAILGAMES"
Texture *texture2; // Textura con los graficos "Since 1998"
SDL_Event *eventHandler; // Manejador de eventos
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
Sprite *sprite2; // Sprite para manejar la textura2
options_t *options; // Puntero a las opciones del juego
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables
std::vector<color_t> color; // Vector con los colores para el fade
int counter; // Contador
section_t section; // Estado del bucle principal para saber si continua o se sale
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
int initFade; // Tiempo del contador cuando inicia el fade a negro
@@ -45,7 +47,10 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();
// Gestiona el logo de JAILGAME
void updateJAILGAMES();
@@ -61,13 +66,13 @@ private:
public:
// Constructor
Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, int subsection);
Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
// Destructor
~Logo();
// Bucle principal
section_t run();
void run();
};
#endif

531
source/gamestate_title.cpp Normal file
View File

@@ -0,0 +1,531 @@
#include "gamestate_title.h"
// Constructor
Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, Online *online, options_t *options, section_t *section)
{
// Copia la dirección de los objetos
this->resource = resource;
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->input = input;
this->online = online;
this->options = options;
this->section = section;
// Reserva memoria para los punteros
eventHandler = new SDL_Event();
cheevos = new Cheevos(screen, options, asset->get("cheevos.bin"), online);
if (options->palette == p_zxspectrum)
{
texture = resource->getTexture("title_logo.png");
}
else if (options->palette == p_zxarne)
{
texture = resource->getTexture("title_logo.png");
}
sprite = new Sprite(0, 0, texture->getWidth(), texture->getHeight(), texture, renderer);
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
infoText = new Text(resource->getOffset("subatomic.txt"), resource->getTexture("subatomic.png"), renderer);
// Crea la textura para los graficos que aparecen en el fondo de la pantalla de titulo
bgTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
if (bgTexture == nullptr)
{
if (options->console)
{
std::cout << "Error: bgTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
}
}
SDL_SetTextureBlendMode(bgTexture, SDL_BLENDMODE_BLEND);
// Carga la surface con los gráficos de la pantalla de carga
pInit(renderer, 256, 128);
loading_screen = pLoadSurface(asset->get("loading_screen_color.gif").c_str());
pLoadPal(asset->get("loading_screen_color.gif").c_str());
pSetSource(loading_screen);
// Inicializa variables
counter = 0;
state = section->subsection == SUBSECTION_TITLE_WITH_LOADING_SCREEN ? show_loading_screen : show_menu;
section->name = SECTION_TITLE;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
marqueeSpeed = 3;
initMarquee();
showCheevos = false;
// Crea y rellena la textura para mostrar los logros
createCheevosTexture();
// Cambia el color del borde
screen->setBorderColor(stringToColor(options->palette, "black"));
// Rellena la textura de fondo con todos los gráficos
fillTexture();
}
// Destructor
Title::~Title()
{
delete cheevos;
delete eventHandler;
delete sprite;
delete cheevosSprite;
delete cheevosTexture;
delete text;
delete infoText;
pDeleteSurface(loading_screen);
SDL_DestroyTexture(bgTexture);
}
// Inicializa la marquesina
void Title::initMarquee()
{
letters.clear();
longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO: P.A.C.O. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
for (int i = 0; i < (int)longText.length(); ++i)
{
letter_t l;
l.letter = longText.substr(i, 1);
l.x = 256;
l.enabled = false;
letters.push_back(l);
}
letters[0].enabled = true;
}
// Comprueba el manejador de eventos
void Title::checkEvents()
{
// 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_QUIT;
break;
}
// Solo se comprueban estas teclas si no está activo el menu de logros
if (eventHandler->type == SDL_KEYDOWN)
{
if (!showCheevos)
{
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_1:
section->name = SECTION_GAME;
section->subsection = 0;
break;
case SDL_SCANCODE_2:
showCheevos = true;
break;
case SDL_SCANCODE_3:
runEnterID();
counter = 0;
cheevos->reload();
fillTexture();
createCheevosTexture();
break;
default:
break;
}
}
}
}
}
// Comprueba las entradas
void Title::checkInput()
{
if (showCheevos)
{
if (input->checkInput(input_down, REPEAT_TRUE))
{
moveCheevosList(1);
}
else if (input->checkInput(input_up, REPEAT_TRUE))
{
moveCheevosList(0);
}
}
if (input->checkInput(input_exit, REPEAT_FALSE))
{
if (showCheevos)
{
hideCheevosList();
counter = 0;
}
else
{
section->name = SECTION_QUIT;
}
}
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
{
screen->switchBorder();
resource->reLoadTextures();
}
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
resource->reLoadTextures();
}
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
resource->reLoadTextures();
}
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
resource->reLoadTextures();
}
else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
{
switchPalette();
}
else if (input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_pause, REPEAT_FALSE))
{
if (state == show_loading_screen)
{
state = fade_loading_screen;
}
}
}
// Actualiza la marquesina
void Title::updateMarquee()
{
for (int i = 0; i < (int)letters.size(); ++i)
{
if (letters[i].enabled)
{
letters[i].x -= marqueeSpeed;
if (letters[i].x < -10)
{
letters[i].enabled = false;
}
}
else
{
if (i > 0 && letters[i - 1].x < 256 && letters[i - 1].enabled)
{
letters[i].enabled = true;
letters[i].x = letters[i - 1].x + text->lenght(letters[i - 1].letter) + 1;
}
}
}
// Comprueba si ha terminado la marquesina y la reinicia
if (letters[letters.size() - 1].x < -10)
{ // Inicializa la marquesina
initMarquee();
}
}
// Dibuja la marquesina
void Title::renderMarquee()
{
for (auto l : letters)
{
if (l.enabled)
{
text->writeColored(l.x, 184, l.letter, stringToColor(options->palette, "white"));
}
}
}
// Dibuja la linea de información inferior
void Title::renderInfo()
{
const std::string loginText = options->online.enabled ? "OnLine: " + options->online.jailerID : "OnLine: OFF";
infoText->write(1, 1, loginText);
const std::string version = "v.1.09";
const int x = GAMECANVAS_WIDTH - infoText->lenght(version) - 1;
infoText->write(x, 1, version);
}
// Actualiza las variables
void Title::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 las entradas
checkInput();
// Actualiza las notificaciones
screen->updateNotifier();
// Incrementa el contador
counter++;
switch (state)
{
case show_loading_screen:
if (counter == 500)
{
counter = 0;
state = fade_loading_screen;
}
break;
case fade_loading_screen:
if (counter % 4 == 0)
if (pFadePal())
{
counter = 0;
state = show_menu;
}
break;
case show_menu:
// Actualiza la marquesina
updateMarquee();
// Si el contador alcanza cierto valor, termina la seccion
if (counter == 2200)
{
if (!showCheevos)
{
section->name = SECTION_CREDITS;
section->subsection = 0;
}
}
break;
default:
break;
}
}
}
// Dibuja en pantalla
void Title::render()
{
// Prepara para empezar a dibujar en la textura de juego
screen->start();
screen->clean(stringToColor(options->palette, "black"));
if (state == show_menu)
{
// Dibuja la textura de fondo
SDL_RenderCopy(renderer, bgTexture, nullptr, nullptr);
// Dibuja la marquesina
renderMarquee();
// Dibuja la información de logros
if (showCheevos)
{
cheevosSprite->render();
}
}
else
{
// Dibuja la pantalla de carga
pCls(4);
pBlit(0, 0, 0, 0, 256, 128);
pFlip(renderer);
// Dibuja el logo del título
sprite->render();
}
// Vuelca el contenido del renderizador en pantalla
screen->blit();
}
// Bucle para el logo del juego
void Title::run()
{
while (section->name == SECTION_TITLE)
{
update();
checkEvents();
render();
}
}
// Recarga las texturas
void Title::reLoadTextures()
{
// Carga la textura adecuada
if (options->palette == p_zxspectrum)
{
// texture->loadFromFile(asset->get("loading_screen_color.png"), renderer);
texture = resource->getTexture("loading_screen_color.png");
}
else if (options->palette == p_zxarne)
{
// texture->loadFromFile(asset->get("loading_screen_color_zxarne.png"), renderer);
texture = resource->getTexture("loading_screen_color_zxarne.png");
}
texture->reLoad();
}
// Cambia la paleta
void Title::switchPalette()
{
if (options->palette == p_zxspectrum)
{
options->palette = p_zxarne;
sprite->setTexture(resource->getTexture("loading_screen_color_zxarne.png"));
}
else
{
options->palette = p_zxspectrum;
sprite->setTexture(resource->getTexture("loading_screen_color.png"));
}
// Cambia el color del borde
screen->setBorderColor(stringToColor(options->palette, "bright_blue"));
}
// Desplaza la lista de logros
void Title::moveCheevosList(int direction)
{
const int speed = 2;
cheevosTextureView.y = direction == 0 ? cheevosTextureView.y - speed : cheevosTextureView.y + speed;
const int bottom = cheevosTexture->getHeight() - cheevosTextureView.h;
if (cheevosTextureView.y < 0)
cheevosTextureView.y = 0;
else if (cheevosTextureView.y > bottom)
cheevosTextureView.y = bottom;
cheevosSprite->setSpriteClip(cheevosTextureView);
}
// Ejecuta la seccion en la que se solicita al usuario su ID online
void Title::runEnterID()
{
enterID = new EnterID(renderer, screen, asset, options, section);
enterID->run();
delete enterID;
}
// Rellena la textura de fondo con todos los gráficos
void Title::fillTexture()
{
// Coloca el puntero del renderizador sobre la textura
SDL_SetRenderTarget(renderer, bgTexture);
// Rellena la textura de color
const color_t c = stringToColor(options->palette, "black");
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
SDL_RenderClear(renderer);
// Pinta el gráfico del titulo a partir del sprite
sprite->render();
// Borra la firma
//const color_t coverColor = stringToColor(options->palette, "black");
//SDL_SetRenderDrawColor(renderer, coverColor.r, coverColor.g, coverColor.b, 0xFF);
//SDL_Rect coverRect = {28, 11, 21, 5};
//SDL_RenderFillRect(renderer, &coverRect);
// Escribe el texto en la textura
const color_t textColor = stringToColor(options->palette, "green");
const int textSize = text->getCharacterSize();
const std::string onlineText = options->online.jailerID == "" ? "(OFF)" : "(" + options->online.jailerID + ")";
text->writeDX(TXT_CENTER | TXT_COLOR, PLAY_AREA_CENTER_X, 11 * textSize, "1.PLAY", 1, textColor);
text->writeDX(TXT_CENTER | TXT_COLOR, PLAY_AREA_CENTER_X, 13 * textSize, "2.ACHIEVEMENTS", 1, textColor);
text->writeDX(TXT_CENTER | TXT_COLOR, PLAY_AREA_CENTER_X, 15 * textSize, "3.ONLINE MODE", 1, textColor);
text->writeDX(TXT_CENTER | TXT_COLOR, PLAY_AREA_CENTER_X, 16 * textSize + 1, onlineText, 1, textColor);
text->writeDX(TXT_CENTER | TXT_COLOR, PLAY_AREA_CENTER_X, 20 * textSize, "ESC.EXIT GAME", 1, textColor);
// Devuelve el puntero del renderizador a su sitio
SDL_SetRenderTarget(renderer, nullptr);
}
// Crea y rellena la textura para mostrar los logros
void Title::createCheevosTexture()
{
// Crea la textura con el listado de logros
const std::vector<cheevos_t> cheevosList = cheevos->list();
// const int iconSize = 16; // Altura del icono que representa a cada logro
const int cheevosTextureWidth = 200;
const int cheevosTextureViewHeight = 110;
const int cheevosTexturePosY = 73;
const int cheevosPadding = 10;
const int cheevoHeight = cheevosPadding + (infoText->getCharacterSize() * 2) + 1;
const int cheevosTextureHeight = (cheevoHeight * cheevosList.size()) + 2 + infoText->getCharacterSize() + 8;
cheevosTexture = new Texture(renderer);
cheevosTexture->createBlank(renderer, cheevosTextureWidth, cheevosTextureHeight, SDL_TEXTUREACCESS_TARGET);
cheevosTexture->setAsRenderTarget(renderer);
cheevosTexture->setBlendMode(SDL_BLENDMODE_BLEND);
// Rellena la textura con color sólido
const color_t cheevosBGColor = stringToColor(options->palette, "black");
SDL_SetRenderDrawColor(renderer, cheevosBGColor.r, cheevosBGColor.g, cheevosBGColor.b, 0xFF);
SDL_RenderClear(renderer);
// Escribe la lista de logros en la textura
const std::string cheevosOwner = options->online.jailerID == "" ? "LOCAL ACHIEVEMENTS" : "ACHIEVEMENTS FOR " + toUpper(options->online.jailerID);
const std::string cheevosListCaption = cheevosOwner + " (" + std::to_string(cheevos->unlocked()) + " / " + std::to_string(cheevos->count()) + ")";
int pos = 2;
infoText->writeDX(TXT_CENTER | TXT_COLOR, cheevosTexture->getWidth() / 2, pos, cheevosListCaption, 1, stringToColor(options->palette, "bright_green"));
pos += infoText->getCharacterSize();
const color_t cheevoLockedColor = stringToColor(options->palette, "white");
const color_t cheevoUnlockedColor = stringToColor(options->palette, "bright_green");
color_t cheevoColor;
SDL_SetRenderDrawColor(renderer, cheevoLockedColor.r, cheevoLockedColor.g, cheevoLockedColor.b, 0xFF);
const int lineX1 = (cheevosTextureWidth / 7) * 3;
const int lineX2 = lineX1 + ((cheevosTextureWidth / 7) * 1);
// Texture *iconTexture = new Texture(renderer, asset->get("notify.png"));
// Sprite *sp = new Sprite({0, 0, iconSize, iconSize}, iconTexture, renderer);
for (auto cheevo : cheevosList)
{
cheevoColor = cheevo.completed ? cheevoUnlockedColor : cheevoLockedColor;
// sp->setPos({2, pos, iconSize, iconSize});
// sp->setSpriteClip({iconSize * 2, 0, iconSize, iconSize});
// sp->getTexture()->setColor(cheevoColor.r, cheevoColor.g, cheevoColor.b);
// sp->render();
pos += cheevosPadding;
int half = cheevosPadding / 2;
SDL_RenderDrawLine(renderer, lineX1, pos - half - 1, lineX2, pos - half - 1);
// infoText->writeColored(2 + iconSize + 2, pos, cheevo.caption, cheevoColor);
infoText->writeDX(TXT_CENTER | TXT_COLOR, cheevosTextureWidth / 2, pos, cheevo.caption, 1, cheevoColor);
pos += infoText->getCharacterSize() + 1;
// infoText->writeColored(2 + iconSize + 2, pos, cheevo.description, cheevoColor);
infoText->writeDX(TXT_CENTER | TXT_COLOR, cheevosTextureWidth / 2, pos, cheevo.description, 1, cheevoColor);
// pos += cheevosPadding;
pos += infoText->getCharacterSize();
}
// delete sp;
// delete iconTexture;
// Crea el sprite para el listado de logros
// cheevosSprite = new Sprite((GAMECANVAS_WIDTH - cheevosTexture->getWidth()) / 2, (GAMECANVAS_HEIGHT - cheevosTextureViewHeight) / 2, cheevosTexture->getWidth(), cheevosTexture->getHeight(), cheevosTexture, renderer);
cheevosSprite = new Sprite((GAMECANVAS_WIDTH - cheevosTexture->getWidth()) / 2, cheevosTexturePosY, cheevosTexture->getWidth(), cheevosTexture->getHeight(), cheevosTexture, renderer);
cheevosTextureView = {0, 0, cheevosTexture->getWidth(), cheevosTextureViewHeight};
cheevosSprite->setSpriteClip(cheevosTextureView);
}
// Oculta la lista de logros
void Title::hideCheevosList()
{
showCheevos = false;
cheevosTextureView.y = 0;
cheevosSprite->setSpriteClip(cheevosTextureView);
}

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