Compare commits

...

113 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
125 changed files with 4845 additions and 2527 deletions

3
.gitignore vendored
View File

@@ -11,3 +11,6 @@ thumbs.db
*.zip *.zip
*.app *.app
*_debug* *_debug*
sync_jail_engine.sh
jaildoctors_dilemma*
todo

1
LICENSE Normal file
View File

@@ -0,0 +1 @@
GNU General Public License v3.0 only

View File

@@ -1,232 +0,0 @@
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>.

View File

@@ -1,8 +1,8 @@
executable = jaildoctors_dilemma executable = jaildoctors_dilemma
source = source/*.cpp source/common/*.cpp source = source/*.cpp source/jail_engine/*.cpp
appName = JailDoctor's Dilemma appName = JailDoctor's Dilemma
releaseFolder = jdd_release releaseFolder = jdd_release
version = v1.06.2 version = v1.08
# Release names # Release names
windowsRelease = $(executable)-$(version)-win32-x64.zip windowsRelease = $(executable)-$(version)-win32-x64.zip
@@ -33,7 +33,7 @@ windows_release:
powershell if (Test-Path "$(releaseFolder)\data\room\standard.tsx") {Remove-Item "$(releaseFolder)\data\room\standard.tsx" -Recurse -Force} powershell if (Test-Path "$(releaseFolder)\data\room\standard.tsx") {Remove-Item "$(releaseFolder)\data\room\standard.tsx" -Recurse -Force}
# Copy root files # Copy root files
powershell Copy-Item "LICENSE.txt" -Destination "$(releaseFolder)" powershell Copy-Item "LICENSE" -Destination "$(releaseFolder)"
powershell Copy-Item "README.md" -Destination "$(releaseFolder)" powershell Copy-Item "README.md" -Destination "$(releaseFolder)"
powershell Copy-Item "release\*.dll" -Destination "$(releaseFolder)" powershell Copy-Item "release\*.dll" -Destination "$(releaseFolder)"
@@ -80,7 +80,7 @@ macos_release:
# Copy files # Copy files
cp release/*.icns "$(releaseFolder)/$(appName).app/Contents/Resources" cp release/*.icns "$(releaseFolder)/$(appName).app/Contents/Resources"
cp release/Info.plist "$(releaseFolder)/$(appName).app/Contents" cp release/Info.plist "$(releaseFolder)/$(appName).app/Contents"
cp LICENSE.txt "$(releaseFolder)" cp LICENSE "$(releaseFolder)"
cp README.md "$(releaseFolder)" cp README.md "$(releaseFolder)"
# Create links # Create links
@@ -123,7 +123,7 @@ linux_release:
# Copy data # Copy data
cp -R data "$(releaseFolder)" cp -R data "$(releaseFolder)"
cp LICENSE.txt "$(releaseFolder)" cp LICENSE "$(releaseFolder)"
cp README.md "$(releaseFolder)" cp README.md "$(releaseFolder)"
# Delete data # Delete data

View File

@@ -1,4 +1,4 @@
# JailDoctor's Dilemma (v1.06.2) # 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. 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.
@@ -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 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 - **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. 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: 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: En **MacOS** se encuentra en:
`~/Library/Application Support/jaildoctors_dilemma` `~/Library/Application Support/jailgames/jaildoctors_dilemma`
En **Linux** se encuentra en: En **Linux** se encuentra en:
`~/.jaildoctors_dilemma` `~/./jailgames/jaildoctors_dilemma`
La primera vez, el juego te pregunta por tu identificador online. Esta información se guarda para futuras partidas.
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. 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.

View File

Before

Width:  |  Height:  |  Size: 271 B

After

Width:  |  Height:  |  Size: 271 B

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

After

Width:  |  Height:  |  Size: 357 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

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

View File

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

View File

@@ -3,22 +3,22 @@
<tileset firstgid="1" source="standard.tsx"/> <tileset firstgid="1" source="standard.tsx"/>
<layer id="1" name="Capa de patrones 1" width="32" height="16"> <layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv"> <data encoding="csv">
0,0,0,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, 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,0,0,0,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,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,0,0,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,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,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, 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,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,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,0,0,0,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,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,0,0,0,0,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,0,0,0,0,0,0,0,0,
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, 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,190,25,25 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> </data>
</layer> </layer>
</map> </map>

View File

@@ -11,8 +11,8 @@ itemColor1=bright_green
itemColor2=green itemColor2=green
[enemy] [enemy]
tileSetFile=diskette.png tileSetFile=floppy.png
animation=diskette.ani animation=floppy.ani
width=16 width=16
height=16 height=16
x=15 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, 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,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,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, 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,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, 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

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

View File

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

View File

@@ -3,16 +3,16 @@
<tileset firstgid="1" source="standard.tsx"/> <tileset firstgid="1" source="standard.tsx"/>
<layer id="1" name="Capa de patrones 1" width="32" height="16"> <layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv"> <data encoding="csv">
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,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,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,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,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, 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, 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,
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, 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,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,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,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,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,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,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, 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"> <layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv"> <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, 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,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,0, 0,0,0,0,0,0,0,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,0, 0,0,0,0,0,0,0,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,0, 0,0,0,0,0,0,0,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,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,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,0, 0,0,0,0,0,0,0,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,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,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,0, 0,0,0,0,0,0,0,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,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,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,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,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, 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 roomRight=0
#[enemy] #[enemy]
#tileSetFile=diskette.png #tileSetFile=floppy.png
#animation=diskette.ani #animation=floppy.ani
#width=16 #width=16
#height=16 #height=16
#x=2 #x=2

View File

@@ -3,17 +3,17 @@
<tileset firstgid="1" source="standard.tsx"/> <tileset firstgid="1" source="standard.tsx"/>
<layer id="1" name="Capa de patrones 1" width="32" height="16"> <layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv"> <data encoding="csv">
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, 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,0,0,0,0,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,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,
0,0,0,0,0,0,0,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, 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,0, 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,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,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, 0,0,0,0,0,0,0,0,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, 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, 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, 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, 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, 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 itemColor2=red
[enemy] [enemy]
tileSetFile=diskette.png tileSetFile=floppy.png
animation=diskette.ani animation=floppy.ani
width=16 width=16
height=16 height=16
x=20 x=20

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,7 @@
<layer id="1" name="Capa de patrones 1" width="32" height="16"> <layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv"> <data encoding="csv">
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,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,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, 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 bgColor=black
border=yellow border=yellow
tileMapFile=53.tmx 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> <key>CFBundleExecutable</key>
<string>jaildoctors_dilemma</string> <string>jaildoctors_dilemma</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>jaildoctors_dilemma</string> <string>icon</string>
<key>CFBundleIconName</key> <key>CFBundleIconName</key>
<string>jaildoctors_dilemma</string> <string>icon</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>org.jailgames.jaildoctors_dilemma</string> <string>org.jailgames.jaildoctors_dilemma</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
@@ -23,11 +23,11 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.0.6.2</string> <string>1.08</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.0.6.2</string> <string>1.08</string>
<key>CSResourcesFileMapped</key> <key>CSResourcesFileMapped</key>
<true/> <true/>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>

View File

@@ -1,13 +1,339 @@
#include "cheevos.h" #include "cheevos.h"
#include <iostream>
// Constructor // 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->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 // Destructor
Cheevos::~Cheevos() 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 #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "common/utils.h" #include "jail_engine/screen.h"
#include "jail_engine/utils.h"
#include "online.h"
#include <string> #include <string>
#include <vector> #include <vector>
#ifndef CHEEVOS_H #ifndef CHEEVOS_H
#define 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 class Cheevos
{ {
private: private:
// Punteros y objetos // 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 // 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: public:
// Constructor // Constructor
Cheevos(options_t *options); Cheevos(Screen *screen, options_t *options, std::string file, Online *online);
// Destructor // Destructor
~Cheevos(); ~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 #endif

View File

@@ -1,223 +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, options_t *options)
{
// Inicializa variables
this->renderer = renderer;
this->options = options;
bgColor = options->notifications.color;
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;
if (options->notifications.posV == pos_top)
{
notifications.at(i).rect.y++;
}
else
{
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);
if (options->notifications.posV == pos_top)
{
notifications.at(i).rect.y--;
}
else
{
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)
{
// Inicializa variables
const int width = this->text->lenght(text) + (this->text->getCharacterSize() * 2);
const int height = this->text->getCharacterSize() * 2;
const int padding = (this->text->getCharacterSize() / 2);
// Posición horizontal
int despH = 0;
if (options->notifications.posH == pos_left)
{
despH = padding;
}
else if (options->notifications.posH == pos_middle)
{
despH = ((options->screen.windowWidth * options->windowSize) / 2 - (width / 2));
}
else
{
despH = (options->screen.windowWidth * options->windowSize) - width - padding;
}
// Posición vertical
int despV = 0;
if (options->notifications.posV == pos_top)
{
despV = padding;
}
else
{
despV = (options->screen.windowHeight * options->windowSize) - height - padding;
}
const int travelDist = height + padding;
// Offset
int offset = 0;
if (options->notifications.posV == pos_top)
{
offset = (int)notifications.size() > 0 ? notifications.back().y + travelDist : despV;
}
else
{
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;
if (options->notifications.posV == pos_top)
{
n.rect = {despH, offset - travelDist, width, height};
}
else
{
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, padding, 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
if (options->notifications.sound)
{
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 <SDL2/SDL.h>
#include <string> #include <string>
#include "common/utils.h" #include "jail_engine/utils.h"
#ifndef CONST_H #ifndef CONST_H
#define 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; const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3;
// Secciones del programa // Secciones del programa
#define SECTION_PROG_LOGO 0 #define SECTION_LOGO 0
#define SECTION_PROG_INTRO 1 #define SECTION_LOADING_SCREEN 1
#define SECTION_PROG_TITLE 2 #define SECTION_TITLE 2
#define SECTION_PROG_CREDITS 3 #define SECTION_CREDITS 3
#define SECTION_PROG_GAME 4 #define SECTION_GAME 4
#define SECTION_PROG_DEMO 5 #define SECTION_DEMO 5
#define SECTION_PROG_GAME_OVER 6 #define SECTION_GAME_OVER 6
#define SECTION_PROG_ENDING 7 #define SECTION_ENDING 7
#define SECTION_PROG_ENDING2 8 #define SECTION_ENDING2 8
#define SECTION_PROG_ENTER_ID 9 #define SECTION_QUIT 9
#define SECTION_PROG_QUIT 10
// Subsecciones // Subsecciones
#define SUBSECTION_LOGO_TO_INTRO 0 #define SUBSECTION_LOGO_TO_INTRO 0
#define SUBSECTION_LOGO_TO_TITLE 1 #define SUBSECTION_LOGO_TO_TITLE 1
#define SUBSECTION_TITLE_WITH_LOADING_SCREEN 2
#define SUBSECTION_TITLE_WITHOUT_LOADING_SCREEN 3
// Colores // Colores
const color_t borderColor = {0x27, 0x27, 0x36}; const color_t borderColor = {0x27, 0x27, 0x36};

View File

@@ -1,5 +1,5 @@
#include "common/jscore.h" #include "jail_engine/jscore.h"
#include "common/utils.h" #include "jail_engine/utils.h"
#include "director.h" #include "director.h"
#include <errno.h> #include <errno.h>
#include <iostream> #include <iostream>
@@ -14,11 +14,12 @@
// Constructor // Constructor
Director::Director(int argc, char *argv[]) Director::Director(int argc, char *argv[])
{ {
section.name = SECTION_PROG_LOGO; section = new section_t();
section.subsection = SUBSECTION_LOGO_TO_INTRO; section->name = SECTION_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO;
#ifdef DEBUG #ifdef DEBUG
section.name = SECTION_PROG_GAME; section->name = SECTION_TITLE;
#endif #endif
// Crea e inicializa las opciones del programa // Crea e inicializa las opciones del programa
@@ -28,7 +29,12 @@ Director::Director(int argc, char *argv[])
checkProgramArguments(argc, argv); checkProgramArguments(argc, argv);
// Crea la carpeta del sistema donde guardar datos // 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 // Crea el objeto que controla los ficheros de recursos
asset = new Asset(executablePath); asset = new Asset(executablePath);
@@ -57,6 +63,10 @@ Director::Director(int argc, char *argv[])
screen->setBorderColor(borderColor); screen->setBorderColor(borderColor);
debug = new Debug(renderer, screen, asset); debug = new Debug(renderer, screen, asset);
music = JA_LoadMusic(asset->get("title.ogg").c_str()); music = JA_LoadMusic(asset->get("title.ogg").c_str());
online = new Online(options);
// Inicializa los servicios online
initOnline();
} }
Director::~Director() Director::~Director()
@@ -65,12 +75,14 @@ Director::~Director()
saveConfig(); saveConfig();
// Libera la memoria // Libera la memoria
delete section;
delete options; delete options;
delete asset; delete asset;
delete input; delete input;
delete screen; delete screen;
delete debug; delete debug;
delete resource; delete resource;
delete online;
JA_DeleteMusic(music); JA_DeleteMusic(music);
SDL_DestroyRenderer(renderer); SDL_DestroyRenderer(renderer);
@@ -83,16 +95,14 @@ void Director::initOnline()
{ {
if (options->online.jailerID == "") if (options->online.jailerID == "")
{ // Jailer ID no definido { // Jailer ID no definido
options->online.enabled = false; options->online.enabled = false;
} }
else else
{ // Jailer ID iniciado { // Jailer ID iniciado
if (options->online.enabled) if (options->online.enabled)
{ // Establece el servidor y el puerto { // Establece el servidor y el puerto
jscore::init(options->online.server, options->online.port); jscore::init(options->online.server, options->online.port);
options->online.sessionEnabled = true;
const std::string caption = options->online.jailerID + " IS LOGGED IN"; const std::string caption = options->online.jailerID + " IS LOGGED IN";
screen->showNotification(caption); screen->showNotification(caption);
if (options->console) if (options->console)
@@ -129,8 +139,15 @@ void Director::initOptions()
options->borderHeight = 24; options->borderHeight = 24;
options->palette = p_zxspectrum; options->palette = p_zxspectrum;
#ifdef GAME_CONSOLE
options->windowSize = 2;
#endif
// Estos valores no se guardan en el fichero de configuraci´ón // Estos valores no se guardan en el fichero de configuraci´ón
options->console = false; options->console = false;
#ifdef DEBUG
options->console = true;
#endif
options->cheat.infiniteLives = false; options->cheat.infiniteLives = false;
options->cheat.invincible = false; options->cheat.invincible = false;
options->cheat.jailEnabled = false; options->cheat.jailEnabled = false;
@@ -139,11 +156,12 @@ void Director::initOptions()
options->stats.items = 0; options->stats.items = 0;
// Opciones online // Opciones online
options->online.enabled = true; options->online.enabled = false;
options->online.sessionEnabled = false;
options->online.server = "jaildoctor.duckdns.org"; options->online.server = "jaildoctor.duckdns.org";
options->online.port = 9911; options->online.port = 9911;
#ifdef DEBUG #ifdef DEBUG
options->online.gameID = "jaildoctors_dilemma_test"; options->online.gameID = "jaildoctors_dilemma_debug";
#else #else
options->online.gameID = "jaildoctors_dilemma"; options->online.gameID = "jaildoctors_dilemma";
#endif #endif
@@ -153,7 +171,7 @@ void Director::initOptions()
options->notifications.posV = pos_top; options->notifications.posV = pos_top;
options->notifications.posH = pos_left; options->notifications.posH = pos_left;
options->notifications.sound = true; options->notifications.sound = true;
options->notifications.color = {64, 64, 64}; options->notifications.color = {48, 48, 48};
} }
// Comprueba los parametros del programa // Comprueba los parametros del programa
@@ -403,24 +421,18 @@ bool Director::saveConfig()
} }
// Crea la carpeta del sistema donde guardar datos // 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 #ifdef _WIN32
systemFolder = std::string(getenv("APPDATA")) + "/" + folderName; systemFolder = std::string(getenv("APPDATA")) + "/" + folder;
#elif __APPLE__ #elif __APPLE__
struct passwd *pw = getpwuid(getuid()); struct passwd *pw = getpwuid(getuid());
const char *homedir = pw->pw_dir; const char *homedir = pw->pw_dir;
systemFolder = std::string(homedir) + "/Library/Application Support/" + folderName; systemFolder = std::string(homedir) + "/Library/Application Support" + "/" + folder;
#elif __linux__ #elif __linux__
struct passwd *pw = getpwuid(getuid()); struct passwd *pw = getpwuid(getuid());
const char *homedir = pw->pw_dir; const char *homedir = pw->pw_dir;
systemFolder = std::string(homedir) + "/." + folderName; systemFolder = std::string(homedir) + "/." + folder;
#endif #endif
struct stat st = {0}; struct stat st = {0};
@@ -458,14 +470,14 @@ void Director::createSystemFolder()
} }
// Carga los recursos // Carga los recursos
void Director::loadResources(section_t section) void Director::loadResources(section_t *section)
{ {
if (options->console) if (options->console)
{ {
std::cout << "** LOAD RESOURCES" << std::endl; std::cout << "** LOAD RESOURCES" << std::endl;
} }
if (section.name == SECTION_PROG_LOGO) if (section->name == SECTION_LOGO)
{ {
std::vector<std::string> textureList; std::vector<std::string> textureList;
textureList.push_back("jailgames.png"); textureList.push_back("jailgames.png");
@@ -474,7 +486,7 @@ void Director::loadResources(section_t section)
resource->loadTextures(textureList); resource->loadTextures(textureList);
} }
else if (section.name == SECTION_PROG_INTRO) else if (section->name == SECTION_LOADING_SCREEN)
{ {
std::vector<std::string> textureList; std::vector<std::string> textureList;
textureList.push_back("loading_screen_bn.png"); textureList.push_back("loading_screen_bn.png");
@@ -485,23 +497,27 @@ void Director::loadResources(section_t section)
resource->loadTextures(textureList); resource->loadTextures(textureList);
} }
else if (section.name == SECTION_PROG_TITLE) else if (section->name == SECTION_TITLE)
{ {
std::vector<std::string> textureList; std::vector<std::string> textureList;
textureList.push_back("loading_screen_color.png"); textureList.push_back("loading_screen_color.png");
textureList.push_back("loading_screen_color_zxarne.png"); textureList.push_back("loading_screen_color_zxarne.png");
textureList.push_back("smb2.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); resource->loadTextures(textureList);
// Offsets // Offsets
std::vector<std::string> offsetsList; std::vector<std::string> offsetsList;
offsetsList.push_back("smb2.txt"); offsetsList.push_back("smb2.txt");
offsetsList.push_back("subatomic.txt");
resource->loadOffsets(offsetsList); resource->loadOffsets(offsetsList);
} }
else if (section.name == SECTION_PROG_CREDITS) else if (section->name == SECTION_CREDITS)
{ {
// Texturas // Texturas
std::vector<std::string> textureList; std::vector<std::string> textureList;
@@ -523,7 +539,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList); resource->loadOffsets(offsetsList);
} }
else if (section.name == SECTION_PROG_ENDING) else if (section->name == SECTION_ENDING)
{ {
// Texturas // Texturas
std::vector<std::string> textureList; std::vector<std::string> textureList;
@@ -548,7 +564,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList); resource->loadOffsets(offsetsList);
} }
else if (section.name == SECTION_PROG_ENDING2) else if (section->name == SECTION_ENDING2)
{ {
// Texturas // Texturas
std::vector<std::string> textureList; std::vector<std::string> textureList;
@@ -581,7 +597,7 @@ void Director::loadResources(section_t section)
textureList.push_back("demon.png"); textureList.push_back("demon.png");
textureList.push_back("heavy.png"); textureList.push_back("heavy.png");
textureList.push_back("dimallas.png"); textureList.push_back("dimallas.png");
textureList.push_back("diskette.png"); textureList.push_back("floppy.png");
textureList.push_back("dong.png"); textureList.push_back("dong.png");
textureList.push_back("guitar.png"); textureList.push_back("guitar.png");
textureList.push_back("jailbattle_alien.png"); textureList.push_back("jailbattle_alien.png");
@@ -644,7 +660,7 @@ void Director::loadResources(section_t section)
animationList.push_back("demon.ani"); animationList.push_back("demon.ani");
animationList.push_back("heavy.ani"); animationList.push_back("heavy.ani");
animationList.push_back("dimallas.ani"); animationList.push_back("dimallas.ani");
animationList.push_back("diskette.ani"); animationList.push_back("floppy.ani");
animationList.push_back("dong.ani"); animationList.push_back("dong.ani");
animationList.push_back("guitar.ani"); animationList.push_back("guitar.ani");
animationList.push_back("jailbattle_alien.ani"); animationList.push_back("jailbattle_alien.ani");
@@ -686,7 +702,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList); resource->loadOffsets(offsetsList);
} }
else if (section.name == SECTION_PROG_GAME_OVER) else if (section->name == SECTION_GAME_OVER)
{ {
// Texturas // Texturas
std::vector<std::string> textureList; std::vector<std::string> textureList;
@@ -710,7 +726,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList); 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 // Texturas
std::vector<std::string> textureList; std::vector<std::string> textureList;
@@ -755,7 +771,7 @@ void Director::loadResources(section_t section)
textureList.push_back("crosshair.png"); textureList.push_back("crosshair.png");
textureList.push_back("demon.png"); textureList.push_back("demon.png");
textureList.push_back("dimallas.png"); textureList.push_back("dimallas.png");
textureList.push_back("diskette.png"); textureList.push_back("floppy.png");
textureList.push_back("dong.png"); textureList.push_back("dong.png");
textureList.push_back("guitar.png"); textureList.push_back("guitar.png");
textureList.push_back("heavy.png"); textureList.push_back("heavy.png");
@@ -836,7 +852,7 @@ void Director::loadResources(section_t section)
animationList.push_back("crosshair.ani"); animationList.push_back("crosshair.ani");
animationList.push_back("demon.ani"); animationList.push_back("demon.ani");
animationList.push_back("dimallas.ani"); animationList.push_back("dimallas.ani");
animationList.push_back("diskette.ani"); animationList.push_back("floppy.ani");
animationList.push_back("dong.ani"); animationList.push_back("dong.ani");
animationList.push_back("guitar.ani"); animationList.push_back("guitar.ani");
animationList.push_back("heavy.ani"); animationList.push_back("heavy.ani");
@@ -1202,43 +1218,62 @@ void Director::initInput()
// Busca si hay un mando conectado // Busca si hay un mando conectado
input->discoverGameController(); input->discoverGameController();
// Asigna inputs a teclas // Teclado - Movimiento
if (options->keys == ctrl_cursor) if (options->keys == ctrl_cursor)
{ {
input->bindKey(INPUT_UP, SDL_SCANCODE_UP); input->bindKey(input_jump, SDL_SCANCODE_UP);
input->bindKey(INPUT_LEFT, SDL_SCANCODE_LEFT); input->bindKey(input_left, SDL_SCANCODE_LEFT);
input->bindKey(INPUT_RIGHT, SDL_SCANCODE_RIGHT); 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) else if (options->keys == ctrl_opqa)
{ {
input->bindKey(INPUT_UP, SDL_SCANCODE_Q); input->bindKey(input_jump, SDL_SCANCODE_Q);
input->bindKey(INPUT_LEFT, SDL_SCANCODE_O); input->bindKey(input_left, SDL_SCANCODE_O);
input->bindKey(INPUT_RIGHT, SDL_SCANCODE_P); 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) else if (options->keys == ctrl_wasd)
{ {
input->bindKey(INPUT_UP, SDL_SCANCODE_W); input->bindKey(input_jump, SDL_SCANCODE_W);
input->bindKey(INPUT_LEFT, SDL_SCANCODE_A); input->bindKey(input_left, SDL_SCANCODE_A);
input->bindKey(INPUT_RIGHT, SDL_SCANCODE_D); input->bindKey(input_right, SDL_SCANCODE_D);
input->bindKey(input_up, SDL_SCANCODE_W);
input->bindKey(input_down, SDL_SCANCODE_S);
} }
input->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN); // Teclado - Otros
input->bindKey(INPUT_ACCEPT, SDL_SCANCODE_RETURN); input->bindKey(input_accept, SDL_SCANCODE_RETURN);
input->bindKey(INPUT_CANCEL, SDL_SCANCODE_ESCAPE); input->bindKey(input_cancel, SDL_SCANCODE_ESCAPE);
input->bindKey(INPUT_BUTTON_1, SDL_SCANCODE_SPACE); input->bindKey(input_pause, SDL_SCANCODE_H);
input->bindKey(INPUT_BUTTON_2, SDL_SCANCODE_D); input->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
input->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE); input->bindKey(input_window_dec_size, SDL_SCANCODE_F1);
input->bindKey(INPUT_BUTTON_ESCAPE, SDL_SCANCODE_ESCAPE); 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);
input->bindGameControllerButton(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP); // Mando - Movimiento
input->bindGameControllerButton(INPUT_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN); input->bindGameControllerButton(input_jump, SDL_CONTROLLER_BUTTON_B);
input->bindGameControllerButton(INPUT_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT); input->bindGameControllerButton(input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
input->bindGameControllerButton(INPUT_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT); 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); // Mando - Otros
input->bindGameControllerButton(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_B); input->bindGameControllerButton(input_accept, SDL_CONTROLLER_BUTTON_B);
input->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE); input->bindGameControllerButton(input_cancel, SDL_CONTROLLER_BUTTON_A);
input->bindGameControllerButton(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE); #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 // Inicializa JailAudio
@@ -1297,14 +1332,14 @@ bool Director::initSDL()
else else
{ {
// Crea un renderizador para la ventana. El vsync se activa en funcion de las opciones // 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) if (options->vSync)
{ {
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); flags = flags | SDL_RENDERER_PRESENTVSYNC;
}
else
{
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
} }
renderer = SDL_CreateRenderer(window, -1, flags);
if (renderer == nullptr) if (renderer == nullptr)
{ {
@@ -1349,6 +1384,10 @@ bool Director::setFileList()
asset->add(prefix + "/data/font/smb2.txt", t_font); asset->add(prefix + "/data/font/smb2.txt", t_font);
asset->add(prefix + "/data/font/debug.png", 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/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 // Datos
asset->add(prefix + "/data/input/gamecontrollerdb.txt", t_data); asset->add(prefix + "/data/input/gamecontrollerdb.txt", t_data);
@@ -1357,6 +1396,10 @@ bool Director::setFileList()
asset->add(systemFolder + "/config.txt", t_data, false, true); asset->add(systemFolder + "/config.txt", t_data, false, true);
asset->add(systemFolder + "/stats_buffer.csv", 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 + "/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 // Habitaciones
asset->add(prefix + "/data/room/01.room", t_room); asset->add(prefix + "/data/room/01.room", t_room);
@@ -1533,8 +1576,8 @@ bool Director::setFileList()
asset->add(prefix + "/data/enemies/demon.png", t_bitmap); asset->add(prefix + "/data/enemies/demon.png", t_bitmap);
asset->add(prefix + "/data/enemies/dimallas.ani", t_data); asset->add(prefix + "/data/enemies/dimallas.ani", t_data);
asset->add(prefix + "/data/enemies/dimallas.png", t_bitmap); asset->add(prefix + "/data/enemies/dimallas.png", t_bitmap);
asset->add(prefix + "/data/enemies/diskette.ani", t_data); asset->add(prefix + "/data/enemies/floppy.ani", t_data);
asset->add(prefix + "/data/enemies/diskette.png", t_bitmap); asset->add(prefix + "/data/enemies/floppy.png", t_bitmap);
asset->add(prefix + "/data/enemies/dong.ani", t_data); asset->add(prefix + "/data/enemies/dong.ani", t_data);
asset->add(prefix + "/data/enemies/dong.png", t_bitmap); asset->add(prefix + "/data/enemies/dong.png", t_bitmap);
asset->add(prefix + "/data/enemies/guitar.ani", t_data); asset->add(prefix + "/data/enemies/guitar.ani", t_data);
@@ -1661,6 +1704,8 @@ bool Director::setFileList()
asset->add(prefix + "/data/title/loading_screen_color.png", t_bitmap); 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_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_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 // Ending
asset->add(prefix + "/data/ending/ending1.png", t_bitmap); asset->add(prefix + "/data/ending/ending1.png", t_bitmap);
@@ -1681,24 +1726,6 @@ bool Director::setFileList()
return asset->check(); 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 // Ejecuta la seccion de juego con el logo
void Director::runLogo() void Director::runLogo()
{ {
@@ -1707,23 +1734,23 @@ void Director::runLogo()
std::cout << "\n* SECTION: LOGO" << std::endl; std::cout << "\n* SECTION: LOGO" << std::endl;
} }
loadResources(section); loadResources(section);
logo = new Logo(renderer, screen, resource, asset, options, section.subsection); logo = new Logo(renderer, screen, resource, asset, input, options, section);
setSection(logo->run()); logo->run();
delete logo; delete logo;
resource->free(); resource->free();
} }
// Ejecuta la seccion de juego de la introducción // Ejecuta la seccion de juego de la pantalla de carga
void Director::runIntro() void Director::runLoadingScreen()
{ {
if (options->console) if (options->console)
{ {
std::cout << "\n* SECTION: INTRO" << std::endl; std::cout << "\n* SECTION: INTRO" << std::endl;
} }
loadResources(section); loadResources(section);
intro = new Intro(renderer, screen, resource, asset, options); loadingScreen = new LoadingScreen(renderer, screen, resource, asset, input, options, section);
setSection(intro->run()); loadingScreen->run();
delete intro; delete loadingScreen;
resource->free(); resource->free();
} }
@@ -1739,8 +1766,8 @@ void Director::runTitle()
JA_PlayMusic(music); JA_PlayMusic(music);
} }
loadResources(section); loadResources(section);
title = new Title(renderer, screen, resource, asset, options); title = new Title(renderer, screen, resource, asset, input, online, options, section);
setSection(title->run()); title->run();
delete title; delete title;
resource->free(); resource->free();
} }
@@ -1753,8 +1780,8 @@ void Director::runCredits()
std::cout << "\n* SECTION: CREDITS" << std::endl; std::cout << "\n* SECTION: CREDITS" << std::endl;
} }
loadResources(section); loadResources(section);
credits = new Credits(renderer, screen, resource, asset, options); credits = new Credits(renderer, screen, resource, asset, input, options, section);
setSection(credits->run()); credits->run();
delete credits; delete credits;
resource->free(); resource->free();
} }
@@ -1767,26 +1794,12 @@ void Director::runDemo()
std::cout << "\n* SECTION: DEMO" << std::endl; std::cout << "\n* SECTION: DEMO" << std::endl;
} }
loadResources(section); loadResources(section);
demo = new Demo(renderer, screen, resource, asset, options, debug); demo = new Demo(renderer, screen, resource, asset, input, options, section, debug);
setSection(demo->run()); demo->run();
delete demo; delete demo;
resource->free(); 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 // Ejecuta la seccion del final del juego
void Director::runEnding() void Director::runEnding()
{ {
@@ -1795,8 +1808,8 @@ void Director::runEnding()
std::cout << "\n* SECTION: ENDING" << std::endl; std::cout << "\n* SECTION: ENDING" << std::endl;
} }
loadResources(section); loadResources(section);
ending = new Ending(renderer, screen, resource, asset, options); ending = new Ending(renderer, screen, resource, asset, input, options, section);
setSection(ending->run()); ending->run();
delete ending; delete ending;
resource->free(); resource->free();
} }
@@ -1809,8 +1822,8 @@ void Director::runEnding2()
std::cout << "\n* SECTION: ENDING2" << std::endl; std::cout << "\n* SECTION: ENDING2" << std::endl;
} }
loadResources(section); loadResources(section);
ending2 = new Ending2(renderer, screen, resource, asset, options); ending2 = new Ending2(renderer, screen, resource, asset, input, options, section);
setSection(ending2->run()); ending2->run();
delete ending2; delete ending2;
resource->free(); resource->free();
} }
@@ -1823,8 +1836,8 @@ void Director::runGameOver()
std::cout << "\n* SECTION: GAME OVER" << std::endl; std::cout << "\n* SECTION: GAME OVER" << std::endl;
} }
loadResources(section); loadResources(section);
gameOver = new GameOver(renderer, screen, resource, asset, options); gameOver = new GameOver(renderer, screen, resource, asset, input, options, section);
setSection(gameOver->run()); gameOver->run();
delete gameOver; delete gameOver;
resource->free(); resource->free();
} }
@@ -1838,8 +1851,8 @@ void Director::runGame()
} }
JA_StopMusic(); JA_StopMusic();
loadResources(section); loadResources(section);
game = new Game(renderer, screen, resource, asset, options, input, debug); game = new Game(renderer, screen, resource, asset, online, options, input, section, debug);
setSection(game->run()); game->run();
delete game; delete game;
resource->free(); resource->free();
} }
@@ -1847,47 +1860,43 @@ void Director::runGame()
void Director::run() void Director::run()
{ {
// Bucle principal // 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(); runLogo();
break; break;
case SECTION_PROG_INTRO: case SECTION_LOADING_SCREEN:
runIntro(); runLoadingScreen();
break; break;
case SECTION_PROG_TITLE: case SECTION_TITLE:
runTitle(); runTitle();
break; break;
case SECTION_PROG_CREDITS: case SECTION_CREDITS:
runCredits(); runCredits();
break; break;
case SECTION_PROG_DEMO: case SECTION_DEMO:
runDemo(); runDemo();
break; break;
case SECTION_PROG_ENTER_ID: case SECTION_GAME:
runEnterID();
break;
case SECTION_PROG_GAME:
runGame(); runGame();
break; break;
case SECTION_PROG_GAME_OVER: case SECTION_GAME_OVER:
runGameOver(); runGameOver();
break; break;
case SECTION_PROG_ENDING: case SECTION_ENDING:
runEnding(); runEnding();
break; break;
case SECTION_PROG_ENDING2: case SECTION_ENDING2:
runEnding2(); runEnding2();
break; break;
} }

View File

@@ -1,25 +1,26 @@
#pragma once #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "common/asset.h" #include "jail_engine/asset.h"
#include "common/debug.h" #include "jail_engine/debug.h"
#include "common/input.h" #include "jail_engine/input.h"
#include "common/jail_audio.h" #include "jail_engine/jail_audio.h"
#include "common/movingsprite.h" #include "jail_engine/movingsprite.h"
#include "common/resource.h" #include "jail_engine/resource.h"
#include "common/sprite.h" #include "jail_engine/sprite.h"
#include "common/text.h" #include "jail_engine/text.h"
#include "common/utils.h" #include "jail_engine/utils.h"
#include "const.h" #include "const.h"
#include "credits.h" #include "gamestate_credits.h"
#include "demo.h" #include "gamestate_demo.h"
#include "ending.h" #include "gamestate_ending.h"
#include "ending2.h" #include "gamestate_ending2.h"
#include "enter_id.h" #include "enter_id.h"
#include "game_over.h" #include "gamestate_game_over.h"
#include "game.h" #include "gamestate_game.h"
#include "intro.h" #include "gamestate_loading_screen.h"
#include "logo.h" #include "gamestate_logo.h"
#include "title.h" #include "online.h"
#include "gamestate_title.h"
#ifndef DIRECTOR_H #ifndef DIRECTOR_H
#define DIRECTOR_H #define DIRECTOR_H
@@ -37,19 +38,19 @@ private:
Game *game; // Objeto para gestionar la sección del juego Game *game; // Objeto para gestionar la sección del juego
Logo *logo; // Objeto para gestionar la sección del logo del programa Logo *logo; // Objeto para gestionar la sección del logo del programa
Title *title; // Objeto para gestionar la pantalla de título Title *title; // Objeto para gestionar la pantalla de título
Intro *intro; // Objeto para gestionar la introducción del juego LoadingScreen *loadingScreen; // Objeto para gestionar la introducción del juego
Credits *credits; // Objeto para gestionar los creditos 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 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 Ending *ending; // Objeto para gestionar el final del juego
Ending2 *ending2; // 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 GameOver *gameOver; // Objeto para gestionar el final de la partida
Debug *debug; // Objeto para getsionar la información de debug 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 struct options_t *options; // Variable con todas las opciones del programa
section_t *section; // Sección y subsección actual del programa;
// Variables // Variables
section_t section; // Sección y subsección actual del programa; JA_Music_t *music; // Musica del titulo
JA_Music music; // Musica del titulo
std::string executablePath; // Path del ejecutable std::string executablePath; // Path del ejecutable
std::string systemFolder; // Carpeta del sistema donde guardar datos std::string systemFolder; // Carpeta del sistema donde guardar datos
@@ -69,10 +70,10 @@ private:
bool saveConfig(); bool saveConfig();
// Crea la carpeta del sistema donde guardar datos // Crea la carpeta del sistema donde guardar datos
void createSystemFolder(); void createSystemFolder(std::string folder);
// Carga los recursos // Carga los recursos
void loadResources(section_t section); void loadResources(section_t *section);
// Asigna variables a partir de dos cadenas // Asigna variables a partir de dos cadenas
bool setOptions(options_t *options, std::string var, std::string value); bool setOptions(options_t *options, std::string var, std::string value);
@@ -89,20 +90,11 @@ private:
// Crea el indice de ficheros // Crea el indice de ficheros
bool setFileList(); 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 // Ejecuta la seccion de juego con el logo
void runLogo(); void runLogo();
// Ejecuta la seccion de juego de la introducción // Ejecuta la seccion de juego de la pantalla de carga
void runIntro(); void runLoadingScreen();
// Ejecuta la seccion de juego con el titulo y los menus // Ejecuta la seccion de juego con el titulo y los menus
void runTitle(); void runTitle();
@@ -113,9 +105,6 @@ private:
// Ejecuta la seccion de la demo, donde se ven pantallas del juego // Ejecuta la seccion de la demo, donde se ven pantallas del juego
void runDemo(); void runDemo();
// Ejecuta la seccion en la que se solicita al usuario su ID online
void runEnterID();
// Ejecuta la seccion del final del juego // Ejecuta la seccion del final del juego
void runEnding(); void runEnding();

View File

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

View File

@@ -1,17 +1,18 @@
#include "common/jail_audio.h" #include "jail_engine/jail_audio.h"
#include "common/jscore.h" #include "jail_engine/jscore.h"
#include "const.h" #include "const.h"
#include "enter_id.h" #include "enter_id.h"
#include <iostream> #include <iostream>
// Constructor // 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 // Copia la dirección de los objetos
this->renderer = renderer; this->renderer = renderer;
this->screen = screen; this->screen = screen;
this->asset = asset; this->asset = asset;
this->options = options; this->options = options;
this->section = section;
// Reserva memoria para los punteros // Reserva memoria para los punteros
eventHandler = new SDL_Event(); 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); SDL_SetTextureBlendMode(textTexture, SDL_BLENDMODE_BLEND);
// Inicializa variables // Inicializa variables
oldJailerID = options->online.jailerID;
loopRunning = true;
counter = 0; counter = 0;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
pos = 0; jailerIDPos = 0;
name[pos] = 0; initName();
maxLenght = 15;
this->section.subsection = section.subsection;
if (options->online.enabled && options->online.jailerID == "")
{
this->section.name = SECTION_PROG_ENTER_ID;
}
else
{
endSection();
}
// Escribe el texto en la textura // Escribe el texto en la textura
fillTexture(); fillTexture();
@@ -57,25 +49,22 @@ EnterID::~EnterID()
delete eventHandler; delete eventHandler;
delete text; delete text;
delete texture; delete texture;
SDL_DestroyTexture(textTexture);
} }
// Bucle para el logo del juego // Bucle para el logo del juego
section_t EnterID::run() void EnterID::run()
{ {
// Detiene la música while (loopRunning)
JA_StopMusic();
while (section.name == SECTION_PROG_ENTER_ID)
{ {
update(); update();
checkEvents();
render(); render();
} }
return section;
} }
// Comprueba el manejador de eventos // Comprueba el manejador de eventos
void EnterID::checkEventHandler() void EnterID::checkEvents()
{ {
// Comprueba los eventos que hay en la cola // Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0) while (SDL_PollEvent(eventHandler) != 0)
@@ -83,24 +72,21 @@ void EnterID::checkEventHandler()
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT) if (eventHandler->type == SDL_QUIT)
{ {
section.name = SECTION_PROG_QUIT; section->name = SECTION_QUIT;
loopRunning = false;
break; 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 // Comprueba las teclas que se han pulsado
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN)) 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) if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_A && eventHandler->key.keysym.scancode <= SDL_SCANCODE_Z)
{ // Si pulsa una letra { // Si pulsa una letra
if (pos < maxLenght) if (pos < maxLenght)
@@ -138,7 +124,8 @@ void EnterID::checkEventHandler()
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_ESCAPE) else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_ESCAPE)
{ {
section.name = SECTION_PROG_QUIT; section->name = SECTION_QUIT;
loopRunning = false;
break; break;
} }
@@ -184,14 +171,14 @@ void EnterID::update()
// Actualiza el contador de ticks // Actualiza el contador de ticks
ticks = SDL_GetTicks(); ticks = SDL_GetTicks();
// Comprueba el manejador de eventos
checkEventHandler();
// Actualiza el contador // Actualiza el contador
counter++; counter++;
// Actualiza el cursor // Actualiza el cursor
cursor = (counter % 20 >= 10) ? " " : "_"; 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 // Prepara para empezar a dibujar en la textura de juego
screen->start(); screen->start();
// Limpia la pantalla
screen->clean();
// Dibuja la textura con el texto en pantalla // Dibuja la textura con el texto en pantalla
SDL_RenderCopy(renderer, textTexture, nullptr, nullptr); SDL_RenderCopy(renderer, textTexture, nullptr, nullptr);
// Escribe el jailerID // Escribe el jailerID
const std::string jailerID = (std::string)name + cursor; const std::string jailerID = (std::string)name + cursor;
const color_t color = stringToColor(options->palette, "white"); 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 // Vuelca el contenido del renderizador en pantalla
screen->blit(); 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({"", 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({"", stringToColor(options->palette, "white")});
texts.push_back({"YOU HAVE NOT SPECIFIED ANY ID", stringToColor(options->palette, "white")}); texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"FOR THE ONLINE SERVICE", stringToColor(options->palette, "white")}); texts.push_back({"ONLINE CONFIGURATION:", stringToColor(options->palette, "green")});
texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"PLEASE ENTER AN ID OR", 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({"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({"", 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({"JAILER_ID:", stringToColor(options->palette, "green")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")}); jailerIDPos = ((int)texts.size() + 1) * text->getCharacterSize();
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")});
} }
// Escribe el texto en la textura // Escribe el texto en la textura
@@ -271,29 +247,34 @@ void EnterID::fillTexture()
SDL_SetRenderTarget(renderer, nullptr); 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 // Inicializa los servicios online
void EnterID::initOnline() 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 == "") if (options->online.jailerID == "")
{ // Jailer ID no definido { // Jailer ID no definido
options->online.enabled = false; options->online.enabled = false;
options->online.sessionEnabled = false;
} }
else else
{ // Jailer ID iniciado { // Jailer ID iniciado
options->online.enabled = options->online.sessionEnabled = true;
options->online.enabled = true; // Establece el servidor y el puerto
jscore::init(options->online.server, options->online.port); jscore::init(options->online.server, options->online.port);
#ifdef DEBUG
const std::string caption = options->online.jailerID + " IS LOGGED IN"; const std::string caption = "IS LOGGED IN (DEBUG)";
screen->showNotification(caption); #else
const std::string caption = "IS LOGGED IN";
#endif
screen->showNotification(options->online.jailerID, caption, 12);
if (options->console) if (options->console)
{ {
std::cout << caption << std::endl; std::cout << caption << std::endl;
@@ -304,7 +285,42 @@ void EnterID::initOnline()
// Termina la sección // Termina la sección
void EnterID::endSection() void EnterID::endSection()
{ {
loopRunning = false;
initOnline(); 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 #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "common/asset.h" #include "jail_engine/asset.h"
#include "common/screen.h" #include "jail_engine/screen.h"
#include "common/utils.h" #include "jail_engine/utils.h"
#include "common/text.h" #include "jail_engine/text.h"
#include "common/texture.h" #include "jail_engine/texture.h"
#include <string> #include <string>
#include <vector> #include <vector>
#ifndef ENTER_ID_H #ifndef ENTER_ID_H
#define ASK_ME_H #define ENTER_ID_H
class EnterID class EnterID
{ {
@@ -29,18 +29,21 @@ private:
SDL_Texture *textTexture; // Textura para dibujar el texto SDL_Texture *textTexture; // Textura para dibujar el texto
Text *text; // Objeto para escribir texto en pantalla Text *text; // Objeto para escribir texto en pantalla
Texture *texture; // Textura para la fuente para el texto Texture *texture; // Textura para la fuente para el texto
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables // Variables
bool loopRunning; // Indica si ha de terminar el bucle principal
int counter; // Contador 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 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
std::vector<captions_t> texts; // Vector con los textos std::vector<captions_t> texts; // Vector con los textos
std::string cursor; // Contiene el caracter que se muestra como cursor std::string cursor; // Contiene el caracter que se muestra como cursor
char name[15]; char name[15]; // Aqui se guardan los caracteres de las teclas que se van pulsando
int pos; int pos; // Posición actual en el vector name
int maxLenght; // Tamaño máximo del jailerID 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 // Actualiza las variables
void update(); void update();
@@ -49,7 +52,7 @@ private:
void render(); void render();
// Comprueba el manejador de eventos // Comprueba el manejador de eventos
void checkEventHandler(); void checkEvents();
// Inicializa los textos // Inicializa los textos
void iniTexts(); void iniTexts();
@@ -57,24 +60,27 @@ private:
// Escribe el texto en la textura // Escribe el texto en la textura
void fillTexture(); void fillTexture();
// Cambia la paleta
void switchPalette();
// Inicializa los servicios online // Inicializa los servicios online
void initOnline(); void initOnline();
// Termina la sección // Termina la sección
void endSection(); void endSection();
// Inicializa el vector utilizado para almacenar el texto que se escribe en pantalla
void initName();
// Cambia la paleta
void switchPalette();
public: public:
// Constructor // 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 // Destructor
~EnterID(); ~EnterID();
// Bucle principal // Bucle principal
section_t run(); void run();
}; };
#endif #endif

View File

@@ -1,15 +1,17 @@
#include "credits.h" #include "gamestate_credits.h"
#include <iostream> #include <iostream>
// Constructor // 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 // Copia la dirección de los objetos
this->resource = resource;
this->renderer = renderer; this->renderer = renderer;
this->screen = screen; this->screen = screen;
this->resource = resource;
this->asset = asset; this->asset = asset;
this->input = input;
this->options = options; this->options = options;
this->section = section;
// Reserva memoria para los punteros // Reserva memoria para los punteros
eventHandler = new SDL_Event(); eventHandler = new SDL_Event();
@@ -20,8 +22,8 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
counter = 0; counter = 0;
counterEnabled = true; counterEnabled = true;
subCounter = 0; subCounter = 0;
section.name = SECTION_PROG_CREDITS; section->name = SECTION_CREDITS;
section.subsection = 0; section->subsection = 0;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
sprite->setRect({194, 174, 8, 8}); sprite->setRect({194, 174, 8, 8});
@@ -66,7 +68,7 @@ Credits::~Credits()
} }
// Comprueba el manejador de eventos // Comprueba el manejador de eventos
void Credits::checkEventHandler() void Credits::checkEvents()
{ {
// Comprueba los eventos que hay en la cola // Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0) while (SDL_PollEvent(eventHandler) != 0)
@@ -74,59 +76,50 @@ void Credits::checkEventHandler()
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT) if (eventHandler->type == SDL_QUIT)
{ {
section.name = SECTION_PROG_QUIT; section->name = SECTION_QUIT;
break; break;
} }
}
}
// Comprueba las teclas que se han pulsado // Comprueba las entradas
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN)) void Credits::checkInput()
{ {
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_QUIT;
break;
case SDL_SCANCODE_B: if (input->checkInput(input_exit, REPEAT_FALSE))
{
section->name = SECTION_QUIT;
}
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
{
screen->switchBorder(); screen->switchBorder();
resource->reLoadTextures(); }
break;
case SDL_SCANCODE_F: else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode(); screen->switchVideoMode();
resource->reLoadTextures(); }
break;
case SDL_SCANCODE_F1: else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
screen->setWindowSize(1); {
resource->reLoadTextures(); screen->decWindowSize();
break; }
case SDL_SCANCODE_F2: else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
screen->setWindowSize(2); {
resource->reLoadTextures(); screen->incWindowSize();
break; }
case SDL_SCANCODE_F3: else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
screen->setWindowSize(3); {
resource->reLoadTextures();
break;
case SDL_SCANCODE_F4:
screen->setWindowSize(4);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F5:
switchPalette(); switchPalette();
break; }
default: else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
section.name = SECTION_PROG_TITLE; {
section.subsection = 0; section->name = SECTION_TITLE;
break; section->subsection = 0;
}
}
} }
} }
@@ -147,6 +140,7 @@ void Credits::iniTexts()
keys = "A,D AND W"; keys = "A,D AND W";
} }
#ifndef GAME_CONSOLE
texts.clear(); texts.clear();
texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")}); texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
@@ -160,11 +154,11 @@ void Credits::iniTexts()
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")}); texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({keys + " TO MOVE AND JUMP", stringToColor(options->palette, "white")}); texts.push_back({keys + " 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({"M TO SWITCH THE MUSIC", stringToColor(options->palette, "white")});
texts.push_back({"H TO HOLD/PAUSE THE GAME", stringToColor(options->palette, "white")}); texts.push_back({"H TO PAUSE THE GAME", stringToColor(options->palette, "white")});
texts.push_back({"F1-F4 TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")}); texts.push_back({"F1-F2 TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")});
texts.push_back({"F TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")}); texts.push_back({"F3 TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")});
texts.push_back({"B TO SWITCH THE BORDER SCREEN", 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")});
texts.push_back({"", stringToColor(options->palette, "white")}); texts.push_back({"", stringToColor(options->palette, "white")});
@@ -175,6 +169,36 @@ void Credits::iniTexts()
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options->palette, "white")}); texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options->palette, "white")});
texts.push_back({"", 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 // Escribe el texto en la textura
@@ -200,7 +224,7 @@ void Credits::fillTexture()
} }
// Escribe el corazón // 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; const int posX = ((PLAY_AREA_WIDTH - textLenght) / 2) + textLenght;
text->writeColored(posX, 176, "}", stringToColor(options->palette, "bright_red")); text->writeColored(posX, 176, "}", stringToColor(options->palette, "bright_red"));
@@ -259,7 +283,7 @@ void Credits::updateCounter()
// Comprueba si ha terminado la sección // Comprueba si ha terminado la sección
if (counter > 1200) if (counter > 1200)
{ {
section.name = SECTION_PROG_DEMO; section->name = SECTION_DEMO;
} }
} }
@@ -272,8 +296,8 @@ void Credits::update()
// Actualiza el contador de ticks // Actualiza el contador de ticks
ticks = SDL_GetTicks(); ticks = SDL_GetTicks();
// Comprueba el manejador de eventos // Comprueba las entradas
checkEventHandler(); checkInput();
// Actualiza el contador // Actualiza el contador
updateCounter(); updateCounter();
@@ -318,15 +342,14 @@ void Credits::render()
} }
// Bucle para el logo del juego // 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(); update();
checkEvents();
render(); render();
} }
return section;
} }
// Cambia la paleta // Cambia la paleta

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,15 +1,17 @@
#include "ending2.h" #include "gamestate_ending2.h"
#include <algorithm> #include <algorithm>
// Constructor // 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 // Copia los punteros
this->renderer = renderer; this->renderer = renderer;
this->screen = screen; this->screen = screen;
this->resource = resource; this->resource = resource;
this->asset = asset; this->asset = asset;
this->input = input;
this->options = options; this->options = options;
this->section = section;
// Reserva memoria para los punteros a objetos // Reserva memoria para los punteros a objetos
eventHandler = new SDL_Event(); eventHandler = new SDL_Event();
@@ -21,8 +23,8 @@ Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
preCounter = 0; preCounter = 0;
postCounter = 0; postCounter = 0;
postCounterEnabled = false; postCounterEnabled = false;
section.name = SECTION_PROG_ENDING2; section->name = SECTION_ENDING2;
section.subsection = 0; section->subsection = 0;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
distSpriteText = 8; distSpriteText = 8;
@@ -79,8 +81,8 @@ void Ending2::update()
// Actualiza el contador de ticks // Actualiza el contador de ticks
ticks = SDL_GetTicks(); ticks = SDL_GetTicks();
// Comprueba el manejador de eventos // Comprueba las entradas
checkEventHandler(); checkInput();
// Actualiza los contadores // Actualiza los contadores
updateCounters(); updateCounters();
@@ -176,7 +178,7 @@ void Ending2::render()
} }
// Comprueba el manejador de eventos // Comprueba el manejador de eventos
void Ending2::checkEventHandler() void Ending2::checkEvents()
{ {
// Comprueba los eventos que hay en la cola // Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0) while (SDL_PollEvent(eventHandler) != 0)
@@ -184,75 +186,62 @@ void Ending2::checkEventHandler()
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT) if (eventHandler->type == SDL_QUIT)
{ {
section.name = SECTION_PROG_QUIT; section->name = SECTION_QUIT;
break; break;
} }
}
}
// Comprueba las teclas que se han pulsado // Comprueba las entradas
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN)) void Ending2::checkInput()
{ {
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_QUIT;
break;
case SDL_SCANCODE_B: 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(); screen->switchBorder();
resource->reLoadTextures(); }
break;
case SDL_SCANCODE_F: else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode(); screen->switchVideoMode();
resource->reLoadTextures(); }
break;
case SDL_SCANCODE_F1: else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
screen->setWindowSize(1); {
resource->reLoadTextures(); screen->decWindowSize();
break; }
case SDL_SCANCODE_F2: else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
screen->setWindowSize(2); {
resource->reLoadTextures(); screen->incWindowSize();
break; }
case SDL_SCANCODE_F3: else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
screen->setWindowSize(3); {
resource->reLoadTextures();
break;
case SDL_SCANCODE_F4:
screen->setWindowSize(4);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F5:
switchPalette(); switchPalette();
break;
default:
break;
}
}
} }
} }
// Bucle principal // Bucle principal
section_t Ending2::run() void Ending2::run()
{ {
JA_PlayMusic(music); JA_PlayMusic(music);
while (section.name == SECTION_PROG_ENDING2) while (section->name == SECTION_ENDING2)
{ {
update(); update();
checkEvents();
render(); render();
} }
JA_StopMusic(); JA_StopMusic();
JA_SetVolume(128); JA_SetVolume(128);
return section;
} }
// Actualiza los contadores // Actualiza los contadores
@@ -275,8 +264,8 @@ void Ending2::updateCounters()
if (postCounter > 600) if (postCounter > 600)
{ {
section.name = SECTION_PROG_LOGO; section->name = SECTION_LOGO;
section.subsection = SUBSECTION_LOGO_TO_INTRO; section->subsection = SUBSECTION_LOGO_TO_INTRO;
} }
} }
@@ -288,7 +277,7 @@ void Ending2::iniSpriteList()
// Añade los valores // Añade los valores
spriteList.push_back("bin"); spriteList.push_back("bin");
spriteList.push_back("diskette"); spriteList.push_back("floppy");
spriteList.push_back("bird"); spriteList.push_back("bird");
spriteList.push_back("chip"); spriteList.push_back("chip");
spriteList.push_back("jeannine"); spriteList.push_back("jeannine");
@@ -469,13 +458,13 @@ void Ending2::placeSprites()
{ {
const int x = i % 2 == 0 ? firstCol : secondCol; const int x = i % 2 == 0 ? firstCol : secondCol;
const int y = (i / 1) * (maxSpriteHeight + distSpriteText + text->getCharacterSize() + distSpriteSprite) + GAMECANVAS_HEIGHT + 40; 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 w = sprites[i]->getAnimationClip(0, 0).w;
const int h = sprites.at(i)->getAnimationClip(0, 0).h; const int h = sprites[i]->getAnimationClip(0, 0).h;
const int dx = -(w / 2); const int dx = -(w / 2);
const int dy = i % 1 == 0 ? maxSpriteHeight - h : (int)(maxSpriteHeight * 1.5f) - h; const int dy = i % 1 == 0 ? maxSpriteHeight - h : (int)(maxSpriteHeight * 1.5f) - h;
sprites.at(i)->setRect({x + dx, y + dy, w, h}); sprites[i]->setRect({x + dx, y + dy, w, h});
sprites.at(i)->setVelY(despSpeed); sprites[i]->setVelY(despSpeed);
} }
// Recoloca el último sprite, que es el del jugador // 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) for (int i = 0; i < (int)spriteList.size(); ++i)
{ {
// Calcula constantes // Calcula constantes
std::string txt = spriteList.at(i); std::string txt = spriteList[i];
std::replace(txt.begin(), txt.end(), '_', ' '); std::replace(txt.begin(), txt.end(), '_', ' ');
txt = txt == "player" ? "JAILDOCTOR" : txt; // Reemplaza el texto txt = txt == "player" ? "JAILDOCTOR" : txt; // Reemplaza el texto
const int w = text->lenght(txt, 1); const int w = text->lenght(txt, 1);
const int h = text->getCharacterSize(); const int h = text->getCharacterSize();
const int x = i % 2 == 0 ? firstCol : secondCol; const int x = i % 2 == 0 ? firstCol : secondCol;
const int dx = -(w / 2); 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 // Cambia la posición del último sprite
const int X = (i == (int)spriteList.size() - 1) ? GAMECANVAS_CENTER_X - (w / 2) : x + dx; 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) for (int i = 0; i < (int)list.size(); ++i)
{ {
// Calcula constantes // 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 h = text->getCharacterSize();
const int x = GAMECANVAS_CENTER_X; const int x = GAMECANVAS_CENTER_X;
const int dx = -(w / 2); const int dx = -(w / 2);
@@ -547,7 +536,7 @@ void Ending2::createTexts()
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET); texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
texture->setAsRenderTarget(renderer); texture->setAsRenderTarget(renderer);
texture->setBlendMode(SDL_BLENDMODE_BLEND); texture->setBlendMode(SDL_BLENDMODE_BLEND);
text->write(0, 0, list.at(i)); text->write(0, 0, list[i]);
// Crea el sprite // Crea el sprite
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer); 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) for (int i = 0; i < (int)list.size(); ++i)
{ {
// Calcula constantes // 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 h = text->getCharacterSize();
const int x = GAMECANVAS_CENTER_X; const int x = GAMECANVAS_CENTER_X;
const int dx = -(w / 2); const int dx = -(w / 2);
@@ -576,7 +565,7 @@ void Ending2::createTexts()
texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET); texture->createBlank(renderer, w, h, SDL_TEXTUREACCESS_TARGET);
texture->setAsRenderTarget(renderer); texture->setAsRenderTarget(renderer);
texture->setBlendMode(SDL_BLENDMODE_BLEND); texture->setBlendMode(SDL_BLENDMODE_BLEND);
text->write(0, 0, list.at(i)); text->write(0, 0, list[i]);
// Crea el sprite // Crea el sprite
MovingSprite *sprite = new MovingSprite(x + dx, y, w, h, 0.0f, despSpeed, 0.0f, 0.0f, texture, renderer); 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) 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 #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "common/animatedsprite.h" #include "jail_engine/animatedsprite.h"
#include "common/asset.h" #include "jail_engine/asset.h"
#include "common/jail_audio.h" #include "jail_engine/input.h"
#include "common/resource.h" #include "jail_engine/jail_audio.h"
#include "common/screen.h" #include "jail_engine/resource.h"
#include "common/sprite.h" #include "jail_engine/screen.h"
#include "common/text.h" #include "jail_engine/sprite.h"
#include "common/texture.h" #include "jail_engine/text.h"
#include "common/utils.h" #include "jail_engine/texture.h"
#include "jail_engine/utils.h"
#include "const.h" #include "const.h"
#include <vector> #include <vector>
#include <string> #include <string>
@@ -25,21 +26,22 @@ private:
Screen *screen; // Objeto encargado de dibujar en pantalla Screen *screen; // Objeto encargado de dibujar en pantalla
SDL_Event *eventHandler; // Manejador de eventos SDL_Event *eventHandler; // Manejador de eventos
SDL_Renderer *renderer; // El renderizador de la ventana SDL_Renderer *renderer; // El renderizador de la ventana
Input *input; // Objeto pata gestionar la entrada
Text *text; // Objeto para escribir texto en pantalla Text *text; // Objeto para escribir texto en pantalla
options_t *options; // Puntero a las opciones del juego options_t *options; // Puntero a las opciones del juego
std::vector<AnimatedSprite *> sprites; // Vector con todos los sprites a dibujar 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 *> spriteTexts; // Vector con los sprites de texto de los sprites
std::vector<MovingSprite *> texts; // Vector con los sprites de texto 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 // Variables
bool counterEnabled; // Indica si está el contador habilitado bool counterEnabled; // Indica si está el contador habilitado
int preCounter; // Contador previo int preCounter; // Contador previo
int postCounter; // Contador posterior int postCounter; // Contador posterior
bool postCounterEnabled; // Indica si está habilitado el contador 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 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles 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<std::string> spriteList; // Lista con todos los sprites a dibujar
std::vector<color_t> colors; // Vector con los colores para el fade std::vector<color_t> colors; // Vector con los colores para el fade
int maxSpriteWidth; // El valor de ancho del sprite mas ancho int maxSpriteWidth; // El valor de ancho del sprite mas ancho
@@ -57,7 +59,10 @@ private:
void render(); void render();
// Comprueba el manejador de eventos // Comprueba el manejador de eventos
void checkEventHandler(); void checkEvents();
// Comprueba las entradas
void checkInput();
// Actualiza los contadores // Actualiza los contadores
void updateCounters(); void updateCounters();
@@ -115,13 +120,13 @@ private:
public: public:
// Constructor // 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 // Destructor
~Ending2(); ~Ending2();
// Bucle principal // Bucle principal
section_t run(); void run();
}; };
#endif #endif

View File

@@ -1,33 +1,37 @@
#include "game.h" #include "gamestate_game.h"
#include <iostream> #include <iostream>
// Constructor // 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 // Copia los punteros
this->resource = resource; this->resource = resource;
this->renderer = renderer; this->renderer = renderer;
this->asset = asset; this->asset = asset;
this->online = online;
this->screen = screen; this->screen = screen;
this->input = input; this->input = input;
this->debug = debug; this->debug = debug;
this->options = options; this->options = options;
this->section = section;
// Inicia algunas variables
board.iniClock = SDL_GetTicks();
#ifdef DEBUG #ifdef DEBUG
currentRoom = "01.room"; currentRoom = "03.room";
const int x1 = 25; const int x = 25;
const int y1 = 13; const int y = 13;
spawnPoint = {x1 * 8, y1 * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL}; 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 #endif
// Crea los objetos // Crea los objetos
cheevos = new Cheevos(screen, options, asset->get("cheevos.bin"), online);
scoreboard = new ScoreBoard(renderer, resource, asset, options, &board); scoreboard = new ScoreBoard(renderer, resource, asset, options, &board);
itemTracker = new ItemTracker(); itemTracker = new ItemTracker();
roomTracker = new RoomTracker(); roomTracker = new RoomTracker();
@@ -40,7 +44,26 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer); text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
music = JA_LoadMusic(asset->get("game.ogg").c_str()); music = JA_LoadMusic(asset->get("game.ogg").c_str());
deathSound = JA_LoadSound(asset->get("death.wav").c_str()); deathSound = JA_LoadSound(asset->get("death.wav").c_str());
stats = new Stats(asset->get("stats.csv"), asset->get("stats_buffer.csv"), options); stats = new Stats(asset->get("stats.csv"), asset->get("stats_buffer.csv"), options, 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 // Inicializa el resto de variables
ticks = 0; ticks = 0;
@@ -61,14 +84,17 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
totalItems = getTotalItems(); totalItems = getTotalItems();
initStats(); initStats();
stats->addVisit(room->getName()); 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->name = SECTION_GAME;
section.subsection = 0; section->subsection = 0;
} }
Game::~Game() Game::~Game()
{ {
// Libera la memoria de los objetos // Libera la memoria de los objetos
delete cheevos;
delete scoreboard; delete scoreboard;
delete itemTracker; delete itemTracker;
delete roomTracker; delete roomTracker;
@@ -78,12 +104,14 @@ Game::~Game()
delete text; delete text;
delete stats; delete stats;
SDL_DestroyTexture(roomNameTexture);
JA_DeleteMusic(music); JA_DeleteMusic(music);
JA_DeleteSound(deathSound); JA_DeleteSound(deathSound);
} }
// Comprueba los eventos de la cola // Comprueba los eventos de la cola
void Game::checkEventHandler() void Game::checkEvents()
{ {
// Comprueba los eventos que hay en la cola // Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0) while (SDL_PollEvent(eventHandler) != 0)
@@ -91,7 +119,7 @@ void Game::checkEventHandler()
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT) if (eventHandler->type == SDL_QUIT)
{ {
section.name = SECTION_PROG_QUIT; section->name = SECTION_QUIT;
screen->setBorderColor(stringToColor(options->palette, "black")); screen->setBorderColor(stringToColor(options->palette, "black"));
break; break;
} }
@@ -101,13 +129,10 @@ void Game::checkEventHandler()
reLoadTextures(); 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) switch (eventHandler->key.keysym.scancode)
{ {
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_TITLE;
break;
#ifdef DEBUG #ifdef DEBUG
case SDL_SCANCODE_G: case SDL_SCANCODE_G:
debug->switchEnabled(); debug->switchEnabled();
@@ -137,53 +162,21 @@ void Game::checkEventHandler()
break; break;
case SDL_SCANCODE_F6: 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; break;
#endif #endif
case SDL_SCANCODE_M:
board.music = !board.music;
board.music ? JA_ResumeMusic() : JA_PauseMusic();
break;
case SDL_SCANCODE_H:
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: default:
break; 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 // Bucle para el juego
section_t Game::run() void Game::run()
{ {
JA_PlayMusic(music); JA_PlayMusic(music);
if (!board.music) if (!board.music)
@@ -200,15 +242,14 @@ section_t Game::run()
JA_PauseMusic(); JA_PauseMusic();
} }
while (section.name == SECTION_PROG_GAME) while (section->name == SECTION_GAME)
{ {
update(); update();
checkEvents();
render(); render();
} }
JA_StopMusic(); JA_StopMusic();
return section;
} }
// Actualiza el juego, las variables, comprueba la entrada, etc. // Actualiza el juego, las variables, comprueba la entrada, etc.
@@ -220,8 +261,8 @@ void Game::update()
// Actualiza el contador de ticks // Actualiza el contador de ticks
ticks = SDL_GetTicks(); ticks = SDL_GetTicks();
// Comprueba los eventos de la cola // Comprueba el teclado
checkEventHandler(); checkInput();
#ifdef DEBUG #ifdef DEBUG
debug->clear(); debug->clear();
@@ -237,6 +278,7 @@ void Game::update()
checkGameOver(); checkGameOver();
checkEndGame(); checkEndGame();
checkRestoringJail(); checkRestoringJail();
checkSomeCheevos();
scoreboard->update(); scoreboard->update();
input->update(); input->update();
@@ -256,8 +298,8 @@ void Game::render()
{ {
// Prepara para dibujar el frame // Prepara para dibujar el frame
screen->start(); screen->start();
screen->clean(room->getBGColor());
// Dibuja los elementos del juego en orden
room->renderMap(); room->renderMap();
room->renderEnemies(); room->renderEnemies();
room->renderItems(); room->renderItems();
@@ -317,13 +359,8 @@ void Game::renderDebugInfo()
// Escribe el nombre de la pantalla // Escribe el nombre de la pantalla
void Game::renderRoomName() void Game::renderRoomName()
{ {
// Texto en el centro de la pantalla // Dibuja la textura con el nombre de la habitación
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2}; SDL_RenderCopy(renderer, roomNameTexture, nullptr, &roomNameRect);
color_t color = stringToColor(options->palette, "white");
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
SDL_RenderFillRect(renderer, &rect);
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, 16 * 8 + 4, room->getName(), 1, room->getBGColor());
} }
// Cambia de habitación // Cambia de habitación
@@ -345,6 +382,9 @@ bool Game::changeRoom(std::string file)
// Crea un objeto habitación nuevo a partir del fichero // Crea un objeto habitación nuevo a partir del fichero
room = new Room(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug); room = new Room(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
// Pone el nombre de la habitación en la textura
fillRoomNameTexture();
// Pone el color del marcador en función del color del borde de la habitación // Pone el color del marcador en función del color del borde de la habitación
setScoreBoardColor(); setScoreBoardColor();
@@ -413,7 +453,7 @@ void Game::checkGameOver()
{ {
if (board.lives < 0 && blackScreenCounter > 17) 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 // Actualiza las estadisticas
stats->addDeath(room->getName()); stats->addDeath(room->getName());
// Invalida el logro de pasarse el juego sin morir
cheevos->invalidate(11);
// Destruye la habitacion y el jugador // Destruye la habitacion y el jugador
delete room; delete room;
delete this->player; delete this->player;
@@ -540,7 +583,7 @@ void Game::setScoreBoardColor()
bool Game::checkEndGame() bool Game::checkEndGame()
{ {
const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca
const bool haveTheItems = board.items >= int(totalItems * 0.9f); // Con mas del 90% de los items recogidos 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) const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
if (haveTheItems) if (haveTheItems)
@@ -548,15 +591,12 @@ bool Game::checkEndGame()
board.jailEnabled = true; board.jailEnabled = true;
} }
if (isOnTheRoom && haveTheItems && isOnTheDoor) if (haveTheItems && isOnTheRoom && isOnTheDoor)
{ {
section.name = SECTION_PROG_ENDING; // Comprueba los logros de completar el juego
return true; checkEndGameCheevos();
}
if (options->cheat.jailEnabled && isOnTheRoom && isOnTheDoor) section->name = SECTION_ENDING;
{
section.name = SECTION_PROG_ENDING;
return true; return true;
} }
@@ -616,12 +656,25 @@ void Game::checkRestoringJail()
} }
static int counter = 0; static int counter = 0;
if (!paused)
{
counter++; counter++;
}
// Incrementa el numero de vidas
if (counter == 100) if (counter == 100)
{ {
counter = 0; counter = 0;
board.lives++; board.lives++;
JA_PlaySound(deathSound); 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);
}
} }
} }
@@ -638,3 +691,91 @@ void Game::initStats()
stats->init(); stats->init();
} }
// Crea la textura con el nombre de la habitación
void Game::fillRoomNameTexture()
{
// Pone la textura como destino de renderizado
SDL_SetRenderTarget(renderer, roomNameTexture);
// Rellena la textura de color
const color_t color = stringToColor(options->palette, "white");
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
SDL_RenderClear(renderer);
// Escribe el texto en la textura
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, text->getCharacterSize() / 2, room->getName(), 1, room->getBGColor());
// Deja el renderizador por defecto
SDL_SetRenderTarget(renderer, nullptr);
}
// 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 #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "common/animatedsprite.h" #include "cheevos.h"
#include "common/asset.h" #include "jail_engine/animatedsprite.h"
#include "common/debug.h" #include "jail_engine/asset.h"
#include "common/input.h" #include "jail_engine/debug.h"
#include "common/jail_audio.h" #include "jail_engine/input.h"
#include "common/resource.h" #include "jail_engine/jail_audio.h"
#include "common/screen.h" #include "jail_engine/resource.h"
#include "common/sprite.h" #include "jail_engine/screen.h"
#include "common/text.h" #include "jail_engine/sprite.h"
#include "common/utils.h" #include "jail_engine/text.h"
#include "jail_engine/utils.h"
#include "const.h" #include "const.h"
#include "item_tracker.h" #include "item_tracker.h"
#include "player.h" #include "player.h"
@@ -18,6 +19,7 @@
#include "room.h" #include "room.h"
#include "scoreboard.h" #include "scoreboard.h"
#include "stats.h" #include "stats.h"
#include "online.h"
#ifndef GAME_H #ifndef GAME_H
#define GAME_H #define GAME_H
@@ -36,25 +38,29 @@ private:
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada Input *input; // Objeto pata gestionar la entrada
Text *text; // Objeto para los textos del juego Text *text; // Objeto para los textos del juego
Online *online; // Objeto para gestionar la lectura y escritura de datos en el servidor remoto
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
Cheevos *cheevos; // Objeto encargado de gestionar los logros del juego
Resource *resource; // Objeto con los recursos Resource *resource; // Objeto con los recursos
Debug *debug; // Objeto para gestionar la información de debug Debug *debug; // Objeto para gestionar la información de debug
options_t *options; // Puntero a las opciones del juego options_t *options; // Puntero a las opciones del juego
Stats *stats; // Objeto encargado de gestionar las estadísticas Stats *stats; // Objeto encargado de gestionar las estadísticas
SDL_Texture *roomNameTexture; // Textura para escribir el nombre de la habitación
section_t *section; // Seccion actual dentro del juego
// Variables // 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 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles 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 std::string currentRoom; // Fichero de la habitación actual
playerSpawn_t spawnPoint; // Lugar de la habitación donde aparece el jugador 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 board_t board; // Estructura con los datos del marcador
bool paused; // Indica si el juego se encuentra en pausa 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 bool blackScreen; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador
int blackScreenCounter; // Contador para temporizar la pantalla en negro int blackScreenCounter; // Contador para temporizar la pantalla en negro
int totalItems; // Cantidad total de items que hay en el mapeado del juego int totalItems; // Cantidad total de items que hay en el mapeado del juego
SDL_Rect roomNameRect; // Rectangulo donde pintar la textura con el nombre de la habitación
// Actualiza el juego, las variables, comprueba la entrada, etc. // Actualiza el juego, las variables, comprueba la entrada, etc.
void update(); void update();
@@ -63,7 +69,7 @@ private:
void render(); void render();
// Comprueba los eventos de la cola // Comprueba los eventos de la cola
void checkEventHandler(); void checkEvents();
#ifdef DEBUG #ifdef DEBUG
// Pone la información de debug en pantalla // Pone la información de debug en pantalla
@@ -79,6 +85,9 @@ private:
// Cambia de habitación // Cambia de habitación
bool changeRoom(std::string file); bool changeRoom(std::string file);
// Comprueba el teclado
void checkInput();
// Comprueba si el jugador esta en el borde de la pantalla y actua // Comprueba si el jugador esta en el borde de la pantalla y actua
void checkPlayerOnBorder(); void checkPlayerOnBorder();
@@ -133,15 +142,24 @@ private:
// Inicializa el diccionario de las estadísticas // Inicializa el diccionario de las estadísticas
void initStats(); void initStats();
// Pone el nombre de la habitación en la textura
void fillRoomNameTexture();
// Comprueba algunos logros
void checkSomeCheevos();
// Comprueba los logros de completar el juego
void checkEndGameCheevos();
public: public:
// Constructor // Constructor
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug); Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Online *online, options_t *options, Input *input, section_t *section, Debug *debug);
// Destructor // Destructor
~Game(); ~Game();
// Bucle para el juego // Bucle para el juego
section_t run(); void run();
}; };
#endif #endif

View File

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

View File

@@ -1,14 +1,15 @@
#pragma once #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "common/animatedsprite.h" #include "jail_engine/animatedsprite.h"
#include "common/asset.h" #include "jail_engine/asset.h"
#include "common/jail_audio.h" #include "jail_engine/input.h"
#include "common/resource.h" #include "jail_engine/jail_audio.h"
#include "common/screen.h" #include "jail_engine/resource.h"
#include "common/sprite.h" #include "jail_engine/screen.h"
#include "common/text.h" #include "jail_engine/sprite.h"
#include "common/texture.h" #include "jail_engine/text.h"
#include "common/utils.h" #include "jail_engine/texture.h"
#include "jail_engine/utils.h"
#include "const.h" #include "const.h"
#include <vector> #include <vector>
@@ -23,16 +24,17 @@ private:
Screen *screen; // Objeto encargado de dibujar en pantalla Screen *screen; // Objeto encargado de dibujar en pantalla
Resource *resource; // Objeto con los recursos Resource *resource; // Objeto con los recursos
Asset *asset; // Objeto con los ficheros de 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 options_t *options; // Puntero a las opciones del juego
SDL_Event *eventHandler; // Manejador de eventos SDL_Event *eventHandler; // Manejador de eventos
Text *text; // Objeto para escribir texto en pantalla Text *text; // Objeto para escribir texto en pantalla
AnimatedSprite *playerSprite; // Sprite con el jugador AnimatedSprite *playerSprite; // Sprite con el jugador
AnimatedSprite *tvSprite; // Sprite con el televisor AnimatedSprite *tvSprite; // Sprite con el televisor
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables // Variables
int preCounter; // Contador previo int preCounter; // Contador previo
int counter; // Contador 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 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles 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 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 endSection; // Contador: cuando acaba la sección
int iniFade; // Contador: cuando emiepza el fade int iniFade; // Contador: cuando emiepza el fade
int fadeLenght; // Contador: duración del 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 // Actualiza el objeto
void update(); void update();
@@ -49,7 +51,10 @@ private:
void render(); void render();
// Comprueba el manejador de eventos // Comprueba el manejador de eventos
void checkEventHandler(); void checkEvents();
// Comprueba las entradas
void checkInput();
// Actualiza el color usado para renderizar los textos e imagenes // Actualiza el color usado para renderizar los textos e imagenes
void updateColor(); void updateColor();
@@ -65,13 +70,13 @@ private:
public: public:
// Constructor // 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 // Destructor
~GameOver(); ~GameOver();
// Bucle principal // Bucle principal
section_t run(); void run();
}; };
#endif #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> #include <iostream>
// Constructor // 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 // Copia la dirección de los objetos
this->resource = resource; this->resource = resource;
this->renderer = renderer; this->renderer = renderer;
this->screen = screen; this->screen = screen;
this->asset = asset; this->asset = asset;
this->input = input;
this->options = options; this->options = options;
this->section = section;
// Reserva memoria para los punteros // Reserva memoria para los punteros
eventHandler = new SDL_Event(); 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); sprite.back()->setSpriteClip(0, i, texture->getWidth(), 1);
if (i % 2 == 0) if (i % 2 == 0)
{ {
sprite.at(i)->setPosX(256 + (i * 3)); sprite[i]->setPosX(256 + (i * 3));
} }
else 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 // Inicializa variables
counter = 0; counter = 0;
section.name = SECTION_PROG_LOGO; section->name = SECTION_LOGO;
section.subsection = subsection;
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
initFade = 300; initFade = 300;
@@ -69,7 +70,7 @@ Logo::~Logo()
} }
// Comprueba el manejador de eventos // Comprueba el manejador de eventos
void Logo::checkEventHandler() void Logo::checkEvents()
{ {
// Comprueba los eventos que hay en la cola // Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0) while (SDL_PollEvent(eventHandler) != 0)
@@ -77,59 +78,49 @@ void Logo::checkEventHandler()
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT) if (eventHandler->type == SDL_QUIT)
{ {
section.name = SECTION_PROG_QUIT; section->name = SECTION_QUIT;
break; break;
} }
}
}
// Comprueba las teclas que se han pulsado // Comprueba las entradas
if ((eventHandler->type == SDL_KEYUP && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONUP)) void Logo::checkInput()
{ {
switch (eventHandler->key.keysym.scancode) if (input->checkInput(input_exit, REPEAT_FALSE))
{ {
case SDL_SCANCODE_ESCAPE: section->name = SECTION_TITLE;
section.name = SECTION_PROG_QUIT; }
break;
case SDL_SCANCODE_B: else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
{
screen->switchBorder(); screen->switchBorder();
resource->reLoadTextures(); }
break;
case SDL_SCANCODE_F: else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode(); screen->switchVideoMode();
resource->reLoadTextures(); }
break;
case SDL_SCANCODE_F1: else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
screen->setWindowSize(1); {
resource->reLoadTextures(); screen->decWindowSize();
break; }
case SDL_SCANCODE_F2: else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
screen->setWindowSize(2); {
resource->reLoadTextures(); screen->incWindowSize();
break; }
case SDL_SCANCODE_F3: else if (input->checkInput(input_swap_palette, REPEAT_FALSE))
screen->setWindowSize(3); {
resource->reLoadTextures();
break;
case SDL_SCANCODE_F4:
screen->setWindowSize(4);
resource->reLoadTextures();
break;
case SDL_SCANCODE_F5:
switchPalette(); switchPalette();
break; }
default: 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; {
section->subsection = SUBSECTION_LOGO_TO_TITLE;
endSection(); endSection();
break;
}
}
} }
} }
@@ -142,22 +133,22 @@ void Logo::updateJAILGAMES()
{ {
const int speed = 8; const int speed = 8;
const int dest = 37; const int dest = 37;
if (sprite.at(i)->getPosX() != 37) if (sprite[i]->getPosX() != 37)
{ {
if (i % 2 == 0) if (i % 2 == 0)
{ {
sprite.at(i)->incPosX(-speed); sprite[i]->incPosX(-speed);
if (sprite.at(i)->getPosX() < dest) if (sprite[i]->getPosX() < dest)
{ {
sprite.at(i)->setPosX(dest); sprite[i]->setPosX(dest);
} }
} }
else else
{ {
sprite.at(i)->incPosX(speed); sprite[i]->incPosX(speed);
if (sprite.at(i)->getPosX() > dest) 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) 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) 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) 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) 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) 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) 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) 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) 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) else if (counter == initFade + inc * 0)
{ {
texture->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.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 == initFade + inc * 1) else if (counter == initFade + inc * 1)
{ {
texture->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.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 == initFade + inc * 2) else if (counter == initFade + inc * 2)
{ {
texture->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.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 == initFade + inc * 3) else if (counter == initFade + inc * 3)
{ {
texture->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.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 == initFade + inc * 4) else if (counter == initFade + inc * 4)
{ {
texture->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.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 == initFade + inc * 5) else if (counter == initFade + inc * 5)
{ {
texture->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.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 == initFade + inc * 6) else if (counter == initFade + inc * 6)
{ {
texture->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.at(0).r, color.at(0).g, color.at(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 // Actualiza el contador de ticks
ticks = SDL_GetTicks(); ticks = SDL_GetTicks();
// Comprueba el manejador de eventos // Comprueba las entradas
checkEventHandler(); checkInput();
// Incrementa el contador // Incrementa el contador
counter++; counter++;
@@ -295,18 +298,17 @@ void Logo::render()
} }
// Bucle para el logo del juego // Bucle para el logo del juego
section_t Logo::run() void Logo::run()
{ {
// Detiene la música // Detiene la música
JA_StopMusic(); JA_StopMusic();
while (section.name == SECTION_PROG_LOGO) while (section->name == SECTION_LOGO)
{ {
update(); update();
checkEvents();
render(); render();
} }
return section;
} }
// Cambia la paleta // Cambia la paleta
@@ -318,5 +320,13 @@ void Logo::switchPalette()
// Termina la sección // Termina la sección
void Logo::endSection() 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 #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "common/asset.h" #include "jail_engine/asset.h"
#include "common/jail_audio.h" #include "jail_engine/input.h"
#include "common/resource.h" #include "jail_engine/jail_audio.h"
#include "common/screen.h" #include "jail_engine/resource.h"
#include "common/sprite.h" #include "jail_engine/screen.h"
#include "common/utils.h" #include "jail_engine/sprite.h"
#include "jail_engine/utils.h"
#include "const.h" #include "const.h"
#include <vector> #include <vector>
@@ -21,17 +22,18 @@ private:
Screen *screen; // Objeto encargado de dibujar en pantalla Screen *screen; // Objeto encargado de dibujar en pantalla
Resource *resource; // Objeto con los recursos Resource *resource; // Objeto con los recursos
Asset *asset; // Objeto con los ficheros de recursos Asset *asset; // Objeto con los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada
Texture *texture; // Textura con los graficos "JAILGAMES" Texture *texture; // Textura con los graficos "JAILGAMES"
Texture *texture2; // Textura con los graficos "Since 1998" Texture *texture2; // Textura con los graficos "Since 1998"
SDL_Event *eventHandler; // Manejador de eventos SDL_Event *eventHandler; // Manejador de eventos
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
Sprite *sprite2; // Sprite para manejar la textura2 Sprite *sprite2; // Sprite para manejar la textura2
options_t *options; // Puntero a las opciones del juego options_t *options; // Puntero a las opciones del juego
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables // Variables
std::vector<color_t> color; // Vector con los colores para el fade std::vector<color_t> color; // Vector con los colores para el fade
int counter; // Contador int counter; // Contador
section_t section; // Estado del bucle principal para saber si continua o se sale
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles 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 int initFade; // Tiempo del contador cuando inicia el fade a negro
@@ -45,7 +47,10 @@ private:
void render(); void render();
// Comprueba el manejador de eventos // Comprueba el manejador de eventos
void checkEventHandler(); void checkEvents();
// Comprueba las entradas
void checkInput();
// Gestiona el logo de JAILGAME // Gestiona el logo de JAILGAME
void updateJAILGAMES(); void updateJAILGAMES();
@@ -61,13 +66,13 @@ private:
public: public:
// Constructor // 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 // Destructor
~Logo(); ~Logo();
// Bucle principal // Bucle principal
section_t run(); void run();
}; };
#endif #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);
}

127
source/gamestate_title.h Normal file
View File

@@ -0,0 +1,127 @@
#pragma once
#include <SDL2/SDL.h>
#include "cheevos.h"
#include "enter_id.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/paleta.h"
#include "jail_engine/screen.h"
#include "jail_engine/sprite.h"
#include "jail_engine/text.h"
#include "jail_engine/utils.h"
#include "online.h"
#include "const.h"
#include <vector>
#ifndef TITLE_H
#define TITLE_H
class Title
{
private:
struct letter_t
{
std::string letter; // Letra a escribir
int x; // Posición en el eje x
bool enabled; // Solo se escriben y mueven si estan habilitadas
};
enum states_e
{
show_loading_screen,
fade_loading_screen,
show_menu
};
// 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
Online *online; // Objeto para gestionar la lectura y escritura de datos en el servidor remoto
SDL_Event *eventHandler; // Manejador de eventos
Texture *texture; // Textura con los graficos
Sprite *sprite; // Sprite para manejar la textura
SDL_Texture *bgTexture; // Textura para dibujar el fondo de la pantalla
Text *text; // Objeto para escribir texto en pantalla
Text *infoText; // Objeto para escribir texto en pantalla
options_t *options; // Puntero a las opciones del juego
Texture *cheevosTexture; // Textura con lo lista de logros
Sprite *cheevosSprite; // Sprite para manejar la textura con la lista de logros
Cheevos *cheevos; // Objeto encargado de gestionar los logros del juego
EnterID *enterID; // Objeto para recoger el JailerID desde el teclado
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables
int counter; // Contador
std::string longText; // Texto que aparece en la parte inferior del titulo
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<letter_t> letters; // Vector con las letras de la marquesina
int marqueeSpeed; // Velocidad de desplazamiento de la marquesina
bool showCheevos; // Indica si se muestra por pantalla el listado de logros
SDL_Rect cheevosTextureView; // Zona visible de la textura con el listado de logros
states_e state; // Estado en el que se encuentra el bucle principal
jSurface loading_screen; // Surface con los gráficos de 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();
// Inicializa la marquesina
void initMarquee();
// Actualiza la marquesina
void updateMarquee();
// Dibuja la marquesina
void renderMarquee();
// Dibuja la linea de información inferior
void renderInfo();
// Recarga las texturas
void reLoadTextures();
// Cambia la paleta
void switchPalette();
// Desplaza la lista de logros
void moveCheevosList(int direction);
// Ejecuta la seccion en la que se solicita al usuario su ID online
void runEnterID();
// Rellena la textura de fondo con todos los gráficos
void fillTexture();
// Crea y rellena la textura para mostrar los logros
void createCheevosTexture();
// Oculta la lista de logros
void hideCheevosList();
public:
// Constructor
Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, Online *online, options_t *options, section_t *section);
// Destructor
~Title();
// Bucle principal
void run();
};
#endif

View File

@@ -1,315 +0,0 @@
#include "intro.h"
// Constructor
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options)
{
// Copia la dirección de los objetos
this->resource = resource;
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->options = options;
// 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_PROG_INTRO;
section.subsection = 0;
ticks = 0;
ticksSpeed = 15;
loadCounter = 0;
lineCounter = 0;
loadingFirstPart = true;
// Ls lineas que tapan la primera textura
for (int i = 0; i < 192; ++i)
{
lines[i].x1 = 0;
lines[i].x2 = 257;
lines[i].y = i;
}
// 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
Intro::~Intro()
{
delete sprite1;
delete sprite2;
delete eventHandler;
JA_DeleteMusic(loadingSound1);
JA_DeleteMusic(loadingSound2);
JA_DeleteMusic(loadingSound3);
}
// Comprueba el manejador de eventos
void Intro::checkEventHandler()
{
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0)
{
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
break;
}
// 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:
section.name = SECTION_PROG_TITLE;
section.subsection = 0;
break;
}
}
}
}
// Gestiona el contador de carga
void Intro::updateLoad()
{
// Primera parte de la carga, la parte en blanco ynegro
if (loadingFirstPart)
{
// Cada 5 pasos el loadCounter se incrementa en uno
const int numSteps = 5;
loadCounter = counter / numSteps;
if (loadCounter < 192)
{
const int step = 256 / numSteps;
lines[lineIndex[loadCounter]].x1 = step * (counter % numSteps);
// Elimina por completo la linea anterior
if (loadCounter > 0)
{
lines[lineIndex[loadCounter - 1]].x1 = 256;
}
}
// Una vez actualizadas las 192 lineas, pasa a la segunda fase de la carga
else if (loadCounter == 192)
{
loadingFirstPart = false;
loadCounter = 0;
JA_PlayMusic(loadingSound3);
}
}
// Segunda parte de la carga, la parte de los bloques en color
else
{
loadCounter += 2;
loadCounter = std::min(loadCounter, 768);
}
}
// Gestiona el contador interno
void Intro::updateCounter()
{
if (preCounter >= 50)
{ // Si el contador previo ha llegado a 50, empieza a contar el contador normal
if (counter == 0)
{
JA_PlayMusic(loadingSound2);
}
counter++;
}
else
{ // Actualiza el precontador
preCounter++;
}
}
// Dibuja la pantalla de carga
void Intro::renderLoad()
{
// Carga 1 - Blanco y negro
if (loadingFirstPart)
{
// Dibuja la textura de pantalla de carga en blanco y negro en pantalla
sprite1->render();
// Dibuja las 192 lineas negras sobre la textura
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
for (int i = 0; i < 192; ++i)
{
SDL_RenderDrawLine(renderer, lines[i].x1, lines[i].y, lines[i].x2, lines[i].y);
}
}
else
// Carga 2 - Color
{
sprite1->render();
SDL_Rect rect = {0, 0, 8, 8};
for (int i = 0; i < loadCounter; ++i)
{
rect.x = (i * 8) % 256;
rect.y = (i / 32) * 8;
sprite2->setRect(rect);
sprite2->setSpriteClip(rect);
sprite2->render();
}
}
}
// Actualiza las variables
void Intro::update()
{
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
if (SDL_GetTicks() - ticks > ticksSpeed)
{
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Comprueba el manejador de eventos
checkEventHandler();
// Gestiona el contador interno
updateCounter();
// Gestiona el contador de carga
updateLoad();
// Actualiza las notificaciones
screen->updateNotifier();
// Comprueba si ha terminado la intro
if (loadCounter >= 768)
{
section.name = SECTION_PROG_TITLE;
section.subsection = 0;
JA_StopMusic();
}
}
}
// Dibuja en pantalla
void Intro::render()
{
// Prepara para empezar a dibujar en la textura de juego
screen->start();
// Limpia la pantalla
screen->clean();
// Dibuja la pantalla de carga
renderLoad();
// Vuelca el contenido del renderizador en pantalla
screen->blit();
}
// Bucle para el logo del juego
section_t Intro::run()
{
// Inicia el sonido de carga
JA_SetVolume(64);
JA_PlayMusic(loadingSound1);
while (section.name == SECTION_PROG_INTRO)
{
update();
render();
}
JA_SetVolume(128);
return section;
}
// Cambia la paleta
void Intro::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"));
}
}

View File

@@ -1,81 +0,0 @@
#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 "const.h"
#include <vector>
#include <string>
#include "common/text.h"
#ifndef INTRO_H
#define INTRO_H
class Intro
{
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
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
// Variables
int preCounter; // Contador previo para realizar una pausa inicial
int counter; // Contador
section_t section; // Estado del bucle principal para saber si continua o se sale
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
int lineCounter; // Contador para dibujar las lineas de carga
bool loadingFirstPart; // Para saber en que parte de la carga se encuentra
JA_Music loadingSound1; // Sonidos para imitar la carga tipo spectrum
JA_Music loadingSound2; // Sonidos para imitar la carga tipo spectrum
JA_Music loadingSound3; // Sonidos para imitar la carga tipo spectrum
h_line_t lines[192]; // Las 192 lineas que forman la pantalla de carga
int lineIndex[192]; // El orden en el que se procesan las 192 lineas de la pantalla de carga
// Actualiza las variables
void update();
// Dibuja en pantalla
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
// Gestiona el contador interno
void updateCounter();
// Gestiona el contador de carga
void updateLoad();
// Dibuja la pantalla de carga
void renderLoad();
// Cambia la paleta
void switchPalette();
public:
// Constructor
Intro(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
// Destructor
~Intro();
// Bucle principal
section_t run();
};
#endif

View File

@@ -36,7 +36,7 @@ Item::~Item()
void Item::render() void Item::render()
{ {
const int index = (counter / colorChangeSpeed) % color.size(); const int index = (counter / colorChangeSpeed) % color.size();
sprite->getTexture()->setColor(color.at(index).r, color.at(index).g, color.at(index).b); sprite->getTexture()->setColor(color[index].r, color[index].g, color[index].b);
sprite->render(); sprite->render();
sprite->getTexture()->setColor(255, 255, 255); sprite->getTexture()->setColor(255, 255, 255);
} }

View File

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

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "common/utils.h" #include "jail_engine/utils.h"
#include <string> #include <string>
#include <vector> #include <vector>

View File

@@ -222,121 +222,121 @@ int AnimatedSprite::getIndex(std::string name)
// Calcula el frame correspondiente a la animación // Calcula el frame correspondiente a la animación
void AnimatedSprite::animate() void AnimatedSprite::animate()
{ {
if (!enabled || animation.at(currentAnimation).speed == 0) if (!enabled || animation[currentAnimation].speed == 0)
{ {
return; return;
} }
// Calcula el frame actual a partir del contador // Calcula el frame actual a partir del contador
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).counter / animation.at(currentAnimation).speed; animation[currentAnimation].currentFrame = animation[currentAnimation].counter / animation[currentAnimation].speed;
// Si alcanza el final de la animación, reinicia el contador de la animación // Si alcanza el final de la animación, reinicia el contador de la animación
// en función de la variable loop y coloca el nuevo frame // en función de la variable loop y coloca el nuevo frame
if (animation.at(currentAnimation).currentFrame >= (int)animation.at(currentAnimation).frames.size()) if (animation[currentAnimation].currentFrame >= (int)animation[currentAnimation].frames.size())
{ {
if (animation.at(currentAnimation).loop == -1) if (animation[currentAnimation].loop == -1)
{ // Si no hay loop, deja el último frame { // Si no hay loop, deja el último frame
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).frames.size(); animation[currentAnimation].currentFrame = animation[currentAnimation].frames.size();
animation.at(currentAnimation).completed = true; animation[currentAnimation].completed = true;
} }
else else
{ // Si hay loop, vuelve al frame indicado { // Si hay loop, vuelve al frame indicado
animation.at(currentAnimation).counter = 0; animation[currentAnimation].counter = 0;
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).loop; animation[currentAnimation].currentFrame = animation[currentAnimation].loop;
} }
} }
// En caso contrario // En caso contrario
else else
{ {
// Escoge el frame correspondiente de la animación // Escoge el frame correspondiente de la animación
setSpriteClip(animation.at(currentAnimation).frames.at(animation.at(currentAnimation).currentFrame)); setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
// Incrementa el contador de la animacion // Incrementa el contador de la animacion
animation.at(currentAnimation).counter++; animation[currentAnimation].counter++;
} }
} }
// Obtiene el numero de frames de la animación actual // Obtiene el numero de frames de la animación actual
int AnimatedSprite::getNumFrames() int AnimatedSprite::getNumFrames()
{ {
return (int)animation.at(currentAnimation).frames.size(); return (int)animation[currentAnimation].frames.size();
} }
// Establece el frame actual de la animación // Establece el frame actual de la animación
void AnimatedSprite::setCurrentFrame(int num) void AnimatedSprite::setCurrentFrame(int num)
{ {
// Descarta valores fuera de rango // Descarta valores fuera de rango
if (num >= (int)animation.at(currentAnimation).frames.size()) if (num >= (int)animation[currentAnimation].frames.size())
{ {
num = 0; num = 0;
} }
// Cambia el valor de la variable // Cambia el valor de la variable
animation.at(currentAnimation).currentFrame = num; animation[currentAnimation].currentFrame = num;
animation.at(currentAnimation).counter = 0; animation[currentAnimation].counter = 0;
// Escoge el frame correspondiente de la animación // Escoge el frame correspondiente de la animación
setSpriteClip(animation.at(currentAnimation).frames.at(animation.at(currentAnimation).currentFrame)); setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
} }
// Establece el valor del contador // Establece el valor del contador
void AnimatedSprite::setAnimationCounter(std::string name, int num) void AnimatedSprite::setAnimationCounter(std::string name, int num)
{ {
animation.at(getIndex(name)).counter = num; animation[getIndex(name)].counter = num;
} }
// Establece la velocidad de una animación // Establece la velocidad de una animación
void AnimatedSprite::setAnimationSpeed(std::string name, int speed) void AnimatedSprite::setAnimationSpeed(std::string name, int speed)
{ {
animation.at(getIndex(name)).counter = speed; animation[getIndex(name)].counter = speed;
} }
// Establece la velocidad de una animación // Establece la velocidad de una animación
void AnimatedSprite::setAnimationSpeed(int index, int speed) void AnimatedSprite::setAnimationSpeed(int index, int speed)
{ {
animation.at(index).counter = speed; animation[index].counter = speed;
} }
// Establece si la animación se reproduce en bucle // Establece si la animación se reproduce en bucle
void AnimatedSprite::setAnimationLoop(std::string name, int loop) void AnimatedSprite::setAnimationLoop(std::string name, int loop)
{ {
animation.at(getIndex(name)).loop = loop; animation[getIndex(name)].loop = loop;
} }
// Establece si la animación se reproduce en bucle // Establece si la animación se reproduce en bucle
void AnimatedSprite::setAnimationLoop(int index, int loop) void AnimatedSprite::setAnimationLoop(int index, int loop)
{ {
animation.at(index).loop = loop; animation[index].loop = loop;
} }
// Establece el valor de la variable // Establece el valor de la variable
void AnimatedSprite::setAnimationCompleted(std::string name, bool value) void AnimatedSprite::setAnimationCompleted(std::string name, bool value)
{ {
animation.at(getIndex(name)).completed = value; animation[getIndex(name)].completed = value;
} }
// OLD - Establece el valor de la variable // OLD - Establece el valor de la variable
void AnimatedSprite::setAnimationCompleted(int index, bool value) void AnimatedSprite::setAnimationCompleted(int index, bool value)
{ {
animation.at(index).completed = value; animation[index].completed = value;
} }
// Comprueba si ha terminado la animación // Comprueba si ha terminado la animación
bool AnimatedSprite::animationIsCompleted() bool AnimatedSprite::animationIsCompleted()
{ {
return animation.at(currentAnimation).completed; return animation[currentAnimation].completed;
} }
// Devuelve el rectangulo de una animación y frame concreto // Devuelve el rectangulo de una animación y frame concreto
SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index) SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
{ {
return animation.at(getIndex(name)).frames.at(index); return animation[getIndex(name)].frames[index];
} }
// Devuelve el rectangulo de una animación y frame concreto // Devuelve el rectangulo de una animación y frame concreto
SDL_Rect AnimatedSprite::getAnimationClip(int indexA, Uint8 indexF) SDL_Rect AnimatedSprite::getAnimationClip(int indexA, Uint8 indexF)
{ {
return animation.at(indexA).frames.at(indexF); return animation[indexA].frames[indexF];
} }
// Carga la animación desde un vector // Carga la animación desde un vector
@@ -484,9 +484,9 @@ void AnimatedSprite::setCurrentAnimation(std::string name)
if (currentAnimation != newAnimation) if (currentAnimation != newAnimation)
{ {
currentAnimation = newAnimation; currentAnimation = newAnimation;
animation.at(currentAnimation).currentFrame = 0; animation[currentAnimation].currentFrame = 0;
animation.at(currentAnimation).counter = 0; animation[currentAnimation].counter = 0;
animation.at(currentAnimation).completed = false; animation[currentAnimation].completed = false;
} }
} }
@@ -497,9 +497,9 @@ void AnimatedSprite::setCurrentAnimation(int index)
if (currentAnimation != newAnimation) if (currentAnimation != newAnimation)
{ {
currentAnimation = newAnimation; currentAnimation = newAnimation;
animation.at(currentAnimation).currentFrame = 0; animation[currentAnimation].currentFrame = 0;
animation.at(currentAnimation).counter = 0; animation[currentAnimation].counter = 0;
animation.at(currentAnimation).completed = false; animation[currentAnimation].completed = false;
} }
} }
@@ -513,7 +513,7 @@ void AnimatedSprite::update()
// Establece el rectangulo para un frame de una animación // Establece el rectangulo para un frame de una animación
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h) void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
{ {
animation.at(index_animation).frames.push_back({x, y, w, h}); animation[index_animation].frames.push_back({x, y, w, h});
} }
// OLD - Establece el contador para todas las animaciones // OLD - Establece el contador para todas las animaciones
@@ -528,7 +528,7 @@ void AnimatedSprite::setAnimationCounter(int value)
// Reinicia la animación // Reinicia la animación
void AnimatedSprite::resetAnimation() void AnimatedSprite::resetAnimation()
{ {
animation.at(currentAnimation).currentFrame = 0; animation[currentAnimation].currentFrame = 0;
animation.at(currentAnimation).counter = 0; animation[currentAnimation].counter = 0;
animation.at(currentAnimation).completed = false; animation[currentAnimation].completed = false;
} }

478
source/jail_engine/gif.c Normal file
View File

@@ -0,0 +1,478 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#define EXTENSION_INTRODUCER 0x21
#define IMAGE_DESCRIPTOR 0x2C
#define TRAILER 0x3B
#define GRAPHIC_CONTROL 0xF9
#define APPLICATION_EXTENSION 0xFF
#define COMMENT_EXTENSION 0xFE
#define PLAINTEXT_EXTENSION 0x01
#define READ(dst, size) memcpy(dst, buffer, size); buffer += size
typedef struct
{
unsigned short width;
unsigned short height;
unsigned char fields;
unsigned char background_color_index;
unsigned char pixel_aspect_ratio;
}
screen_descriptor_t;
typedef struct
{
unsigned char r;
unsigned char g;
unsigned char b;
}
rgb;
typedef struct
{
unsigned short image_left_position;
unsigned short image_top_position;
unsigned short image_width;
unsigned short image_height;
unsigned char fields;
}
image_descriptor_t;
typedef struct
{
unsigned char byte;
int prev;
int len;
}
dictionary_entry_t;
typedef struct
{
unsigned char extension_code;
unsigned char block_size;
}
extension_t;
typedef struct
{
unsigned char fields;
unsigned short delay_time;
unsigned char transparent_color_index;
}
graphic_control_extension_t;
typedef struct
{
unsigned char application_id[ 8 ];
unsigned char version[ 3 ];
}
application_extension_t;
typedef struct
{
unsigned short left;
unsigned short top;
unsigned short width;
unsigned short height;
unsigned char cell_width;
unsigned char cell_height;
unsigned char foreground_color;
unsigned char background_color;
}
plaintext_extension_t;
//static unsigned short width = 0;
//static unsigned short height = 0;
//static unsigned char* uncompressed_data = NULL;
void uncompress( int code_length,
const unsigned char *input,
int input_length,
unsigned char *out )
{
//int maxbits;
int i, bit;
int code, prev = -1;
dictionary_entry_t *dictionary;
int dictionary_ind;
unsigned int mask = 0x01;
int reset_code_length;
int clear_code; // This varies depending on code_length
int stop_code; // one more than clear code
int match_len;
clear_code = 1 << ( code_length );
stop_code = clear_code + 1;
// To handle clear codes
reset_code_length = code_length;
// Create a dictionary large enough to hold "code_length" entries.
// Once the dictionary overflows, code_length increases
dictionary = ( dictionary_entry_t * )
malloc( sizeof( dictionary_entry_t ) * ( 1 << ( code_length + 1 ) ) );
// Initialize the first 2^code_len entries of the dictionary with their
// indices. The rest of the entries will be built up dynamically.
// Technically, it shouldn't be necessary to initialize the
// dictionary. The spec says that the encoder "should output a
// clear code as the first code in the image data stream". It doesn't
// say must, though...
for ( dictionary_ind = 0;
dictionary_ind < ( 1 << code_length );
dictionary_ind++ )
{
dictionary[ dictionary_ind ].byte = dictionary_ind;
// XXX this only works because prev is a 32-bit int (> 12 bits)
dictionary[ dictionary_ind ].prev = -1;
dictionary[ dictionary_ind ].len = 1;
}
// 2^code_len + 1 is the special "end" code; don't give it an entry here
dictionary_ind++;
dictionary_ind++;
// TODO verify that the very last byte is clear_code + 1
while ( input_length )
{
code = 0x0;
// Always read one more bit than the code length
for ( i = 0; i < ( code_length + 1 ); i++ )
{
// This is different than in the file read example; that
// was a call to "next_bit"
bit = ( *input & mask ) ? 1 : 0;
mask <<= 1;
if ( mask == 0x100 )
{
mask = 0x01;
input++;
input_length--;
}
code = code | ( bit << i );
}
if ( code == clear_code )
{
code_length = reset_code_length;
dictionary = ( dictionary_entry_t * ) realloc( dictionary,
sizeof( dictionary_entry_t ) * ( 1 << ( code_length + 1 ) ) );
for ( dictionary_ind = 0;
dictionary_ind < ( 1 << code_length );
dictionary_ind++ )
{
dictionary[ dictionary_ind ].byte = dictionary_ind;
// XXX this only works because prev is a 32-bit int (> 12 bits)
dictionary[ dictionary_ind ].prev = -1;
dictionary[ dictionary_ind ].len = 1;
}
dictionary_ind++;
dictionary_ind++;
prev = -1;
continue;
}
else if ( code == stop_code )
{
/*if ( input_length > 1 )
{
fprintf( stderr, "Malformed GIF (early stop code)\n" );
exit( 0 );
}*/
break;
}
// Update the dictionary with this character plus the _entry_
// (character or string) that came before it
if ( ( prev > -1 ) && ( code_length < 12 ) )
{
if ( code > dictionary_ind )
{
fprintf( stderr, "code = %.02x, but dictionary_ind = %.02x\n",
code, dictionary_ind );
exit( 0 );
}
// Special handling for KwKwK
if ( code == dictionary_ind )
{
int ptr = prev;
while ( dictionary[ ptr ].prev != -1 )
{
ptr = dictionary[ ptr ].prev;
}
dictionary[ dictionary_ind ].byte = dictionary[ ptr ].byte;
}
else
{
int ptr = code;
while ( dictionary[ ptr ].prev != -1 )
{
ptr = dictionary[ ptr ].prev;
}
dictionary[ dictionary_ind ].byte = dictionary[ ptr ].byte;
}
dictionary[ dictionary_ind ].prev = prev;
dictionary[ dictionary_ind ].len = dictionary[ prev ].len + 1;
dictionary_ind++;
// GIF89a mandates that this stops at 12 bits
if ( ( dictionary_ind == ( 1 << ( code_length + 1 ) ) ) &&
( code_length < 11 ) )
{
code_length++;
dictionary = ( dictionary_entry_t * ) realloc( dictionary,
sizeof( dictionary_entry_t ) * ( 1 << ( code_length + 1 ) ) );
}
}
prev = code;
// Now copy the dictionary entry backwards into "out"
match_len = dictionary[ code ].len;
while ( code != -1 )
{
out[ dictionary[ code ].len - 1 ] = dictionary[ code ].byte;
if ( dictionary[ code ].prev == code )
{
fprintf( stderr, "Internal error; self-reference." );
exit( 0 );
}
code = dictionary[ code ].prev;
}
out += match_len;
}
}
static int read_sub_blocks( unsigned char* buffer, unsigned char **data )
{
int data_length;
int index;
unsigned char block_size;
// Everything following are data sub-blocks, until a 0-sized block is
// encountered.
data_length = 0;
*data = NULL;
index = 0;
while ( 1 )
{
READ(&block_size, 1);
if ( block_size == 0 ) // end of sub-blocks
{
break;
}
data_length += block_size;
*data = (unsigned char*)realloc( *data, data_length );
// TODO this could be split across block size boundaries
READ(*data + index, block_size);
index += block_size;
}
return data_length;
}
unsigned char* process_image_descriptor( unsigned char* buffer,
rgb *gct,
int gct_size,
int resolution_bits )
{
image_descriptor_t image_descriptor;
int compressed_data_length;
unsigned char *compressed_data = NULL;
unsigned char lzw_code_size;
int uncompressed_data_length = 0;
unsigned char *uncompressed_data = NULL;
// TODO there could actually be lots of these
READ(&image_descriptor, 9);
// TODO if LCT = true, read the LCT
READ(&lzw_code_size, 1);
compressed_data_length = read_sub_blocks( buffer, &compressed_data );
// width = image_descriptor.image_width;
// height = image_descriptor.image_height;
uncompressed_data_length = image_descriptor.image_width *
image_descriptor.image_height;
uncompressed_data = (unsigned char*)malloc( uncompressed_data_length );
uncompress( lzw_code_size, compressed_data, compressed_data_length,
uncompressed_data );
if ( compressed_data ) free( compressed_data );
//if ( uncompressed_data )
// free( uncompressed_data );
return uncompressed_data;
}
/**
* @param gif_file the file descriptor of a file containing a
* GIF-encoded file. This should point to the first byte in
* the file when invoked.
*/
#define rb (*(buffer++))
uint32_t* LoadPalette(unsigned char *buffer) {
unsigned char header[7];
screen_descriptor_t screen_descriptor;
//int color_resolution_bits;
int global_color_table_size = 0; // number of entries in global_color_table
uint32_t *global_color_table = NULL;
READ(header, 6);
READ(&screen_descriptor, 7);
//color_resolution_bits = ((screen_descriptor.fields & 0x70) >> 4) + 1;
global_color_table = (uint32_t *)calloc(1, 1024);
if (screen_descriptor.fields & 0x80) {
global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1));
//global_color_table = (rgb *)malloc(3 * global_color_table_size);
//READ(global_color_table, 3 * global_color_table_size);
for (int i=0; i<global_color_table_size;++i) {
global_color_table[i] = (buffer[0]<<16) + (buffer[1]<<8) + buffer[2];
buffer+=3;
}
}
return global_color_table;
}
static unsigned char* process_gif_stream(unsigned char *buffer, unsigned short* w, unsigned short* h)
{
unsigned char header[ 7 ];
screen_descriptor_t screen_descriptor;
int color_resolution_bits;
int global_color_table_size =0; // number of entries in global_color_table
rgb *global_color_table = NULL;
unsigned char block_type = 0x0;
// A GIF file starts with a Header (section 17)
READ(header, 6);
header[ 6 ] = 0x0;
// XXX there's another format, GIF87a, that you may still find
// floating around.
/*if ( strcmp( "GIF89a", (char*)header ) )
{
fprintf( stderr,
"Invalid GIF file (header is '%s', should be 'GIF89a')\n",
header );
return NULL;
}*/
// Followed by a logical screen descriptor
// Note that this works because GIFs specify little-endian order; on a
// big-endian machine, the height & width would need to be reversed.
// Can't use sizeof here since GCC does byte alignment;
// sizeof( screen_descriptor_t ) = 8!
READ(&screen_descriptor, 7);
*w = screen_descriptor.width;
*h = screen_descriptor.height;
color_resolution_bits = ( ( screen_descriptor.fields & 0x70 ) >> 4 ) + 1;
if ( screen_descriptor.fields & 0x80 )
{
//int i;
// If bit 7 is set, the next block is a global color table; read it
global_color_table_size = 1 <<
( ( ( screen_descriptor.fields & 0x07 ) + 1 ) );
global_color_table = ( rgb * ) malloc( 3 * global_color_table_size );
// XXX this could conceivably return a short count...
READ(global_color_table, 3 * global_color_table_size);
}
while ( block_type != TRAILER )
{
READ(&block_type, 1);
unsigned char size;
switch ( block_type )
{
case IMAGE_DESCRIPTOR:
return process_image_descriptor(buffer,
global_color_table,
global_color_table_size,
color_resolution_bits);
break;
case EXTENSION_INTRODUCER:
buffer++;
size = *(buffer++);
buffer += size;
do {
size = *(buffer++);
buffer += size;
} while (size != 0);
/*if ( !process_extension( buffer ) )
{
return NULL;
}*/
break;
case TRAILER:
break;
default:
fprintf( stderr, "Bailing on unrecognized block type %.02x\n",
block_type );
return NULL;
}
}
return NULL;
}
unsigned char* LoadGif(unsigned char *buffer, unsigned short* w, unsigned short* h) {
return process_gif_stream(buffer, w, h);
}
/*int main( int argc, char *argv[] )
{
FILE* gif_file;
if ( argc < 2 )
{
fprintf( stderr, "Usage: %s <path-to-gif-file>\n", argv[ 0 ] );
exit( 0 );
}
gif_file = fopen( argv[ 1 ], "rb" );
if ( gif_file == NULL )
{
fprintf( stderr, "Unable to open file '%s'", argv[ 1 ] );
perror( ": " );
}
process_gif_stream( gif_file );
fclose( gif_file );
}*/

View File

@@ -11,12 +11,12 @@ Input::Input(std::string file)
keyBindings_t kb; keyBindings_t kb;
kb.scancode = 0; kb.scancode = 0;
kb.active = false; kb.active = false;
keyBindings.resize(17, kb); keyBindings.resize(input_number_of_inputs, kb);
GameControllerBindings_t gcb; GameControllerBindings_t gcb;
gcb.button = SDL_CONTROLLER_BUTTON_INVALID; gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
gcb.active = false; gcb.active = false;
gameControllerBindings.resize(17, gcb); gameControllerBindings.resize(input_number_of_inputs, gcb);
verbose = true; verbose = true;
enabled = true; enabled = true;
@@ -34,13 +34,13 @@ void Input::update()
// Asigna inputs a teclas // Asigna inputs a teclas
void Input::bindKey(Uint8 input, SDL_Scancode code) void Input::bindKey(Uint8 input, SDL_Scancode code)
{ {
keyBindings.at(input).scancode = code; keyBindings[input].scancode = code;
} }
// Asigna inputs a botones del mando // Asigna inputs a botones del mando
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button) void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
{ {
gameControllerBindings.at(input).button = button; gameControllerBindings[input].button = button;
} }
// Comprueba si un input esta activo // Comprueba si un input esta activo
@@ -65,7 +65,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
if (repeat) if (repeat)
{ {
if (keyStates[keyBindings.at(input).scancode] != 0) if (keyStates[keyBindings[input].scancode] != 0)
{ {
successKeyboard = true; successKeyboard = true;
} }
@@ -76,11 +76,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
} }
else else
{ {
if (!keyBindings.at(input).active) if (!keyBindings[input].active)
{ {
if (keyStates[keyBindings.at(input).scancode] != 0) if (keyStates[keyBindings[input].scancode] != 0)
{ {
keyBindings.at(input).active = true; keyBindings[input].active = true;
successKeyboard = true; successKeyboard = true;
} }
else else
@@ -90,9 +90,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
} }
else else
{ {
if (keyStates[keyBindings.at(input).scancode] == 0) if (keyStates[keyBindings[input].scancode] == 0)
{ {
keyBindings.at(input).active = false; keyBindings[input].active = false;
successKeyboard = false; successKeyboard = false;
} }
else else
@@ -108,7 +108,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
{ {
if (repeat) if (repeat)
{ {
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0) if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0)
{ {
successGameController = true; successGameController = true;
} }
@@ -119,11 +119,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
} }
else else
{ {
if (!gameControllerBindings.at(input).active) if (!gameControllerBindings[input].active)
{ {
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0) if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0)
{ {
gameControllerBindings.at(input).active = true; gameControllerBindings[input].active = true;
successGameController = true; successGameController = true;
} }
else else
@@ -133,9 +133,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
} }
else else
{ {
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) == 0) if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) == 0)
{ {
gameControllerBindings.at(input).active = false; gameControllerBindings[input].active = false;
successGameController = false; successGameController = false;
} }
else else
@@ -163,7 +163,7 @@ bool Input::checkAnyInput(int device, int index)
for (int i = 0; i < (int)keyBindings.size(); ++i) for (int i = 0; i < (int)keyBindings.size(); ++i)
{ {
if (mKeystates[keyBindings.at(i).scancode] != 0) if (mKeystates[keyBindings[i].scancode] != 0)
{ {
return true; return true;
} }
@@ -176,7 +176,7 @@ bool Input::checkAnyInput(int device, int index)
{ {
for (int i = 0; i < (int)gameControllerBindings.size(); ++i) for (int i = 0; i < (int)gameControllerBindings.size(); ++i)
{ {
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(i).button) != 0) if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[i].button) != 0)
{ {
return true; return true;
} }
@@ -277,7 +277,7 @@ std::string Input::getControllerName(int index)
{ {
if (numGamepads > 0) if (numGamepads > 0)
{ {
return controllerNames.at(index); return controllerNames[index];
} }
else else
{ {

View File

@@ -7,23 +7,31 @@
#ifndef INPUT_H #ifndef INPUT_H
#define INPUT_H #define INPUT_H
#define INPUT_NULL 0 enum inputs_e
#define INPUT_UP 1 {
#define INPUT_DOWN 2 // Inputs obligatorios
#define INPUT_LEFT 3 input_null,
#define INPUT_RIGHT 4 input_up,
#define INPUT_ACCEPT 5 input_down,
#define INPUT_CANCEL 6 input_left,
#define INPUT_BUTTON_1 7 input_right,
#define INPUT_BUTTON_2 8 input_pause,
#define INPUT_BUTTON_3 9 input_exit,
#define INPUT_BUTTON_4 10 input_accept,
#define INPUT_BUTTON_5 11 input_cancel,
#define INPUT_BUTTON_6 12
#define INPUT_BUTTON_7 13 // Inputs personalizados
#define INPUT_BUTTON_8 14 input_jump,
#define INPUT_BUTTON_PAUSE 15 input_window_fullscreen,
#define INPUT_BUTTON_ESCAPE 16 input_window_inc_size,
input_window_dec_size,
input_toggle_border,
input_switch_music,
input_swap_palette,
// Input obligatorio
input_number_of_inputs
};
#define REPEAT_TRUE true #define REPEAT_TRUE true
#define REPEAT_FALSE false #define REPEAT_FALSE false
@@ -81,7 +89,7 @@ public:
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button); void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
// Comprueba si un input esta activo // Comprueba si un input esta activo
bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0); bool checkInput(Uint8 input, bool repeat = true, int device = INPUT_USE_ANY, int index = 0);
// Comprueba si hay almenos un input activo // Comprueba si hay almenos un input activo
bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0); bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0);

View File

@@ -1,3 +1,4 @@
#ifndef JA_USESDLMIXER
#include "jail_audio.h" #include "jail_audio.h"
#include "stb_vorbis.c" #include "stb_vorbis.c"
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
@@ -11,7 +12,7 @@ struct JA_Sound_t {
}; };
struct JA_Channel_t { struct JA_Channel_t {
JA_Sound sound; JA_Sound_t *sound;
int pos {0}; int pos {0};
int times {0}; int times {0};
JA_Channel_state state { JA_CHANNEL_FREE }; JA_Channel_state state { JA_CHANNEL_FREE };
@@ -25,7 +26,7 @@ struct JA_Music_t {
JA_Music_state state {JA_MUSIC_INVALID}; JA_Music_state state {JA_MUSIC_INVALID};
}; };
JA_Music current_music{NULL}; JA_Music_t *current_music{NULL};
JA_Channel_t channels[JA_MAX_SIMULTANEOUS_CHANNELS]; JA_Channel_t channels[JA_MAX_SIMULTANEOUS_CHANNELS];
int JA_freq {48000}; int JA_freq {48000};
@@ -86,7 +87,7 @@ void JA_Quit() {
sdlAudioDevice = 0; sdlAudioDevice = 0;
} }
JA_Music JA_LoadMusic(const char* filename) { JA_Music_t *JA_LoadMusic(const char* filename) {
int chan, samplerate; int chan, samplerate;
// [RZC 28/08/22] Carreguem primer el arxiu en memòria i després el descomprimim. Es algo més rapid. // [RZC 28/08/22] Carreguem primer el arxiu en memòria i després el descomprimim. Es algo més rapid.
@@ -98,7 +99,7 @@ JA_Music JA_LoadMusic(const char* filename) {
if (fread(buffer, fsize, 1, f)!=1) return NULL; if (fread(buffer, fsize, 1, f)!=1) return NULL;
fclose(f); fclose(f);
JA_Music music = new JA_Music_t(); JA_Music_t *music = new JA_Music_t();
music->samples = stb_vorbis_decode_memory(buffer, fsize, &chan, &samplerate, &music->output); music->samples = stb_vorbis_decode_memory(buffer, fsize, &chan, &samplerate, &music->output);
free(buffer); free(buffer);
@@ -121,7 +122,7 @@ JA_Music JA_LoadMusic(const char* filename) {
return music; return music;
} }
void JA_PlayMusic(JA_Music music, const int loop) { void JA_PlayMusic(JA_Music_t *music, const int loop) {
if (current_music != NULL) { if (current_music != NULL) {
current_music->pos = 0; current_music->pos = 0;
current_music->state = JA_MUSIC_STOPPED; current_music->state = JA_MUSIC_STOPPED;
@@ -153,21 +154,21 @@ JA_Music_state JA_GetMusicState() {
return current_music->state; return current_music->state;
} }
void JA_DeleteMusic(JA_Music music) { void JA_DeleteMusic(JA_Music_t *music) {
if (current_music == music) current_music = NULL; if (current_music == music) current_music = NULL;
free(music->output); free(music->output);
delete music; delete music;
} }
JA_Sound JA_NewSound(Uint8* buffer, Uint32 length) { JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length) {
JA_Sound sound = new JA_Sound_t(); JA_Sound_t *sound = new JA_Sound_t();
sound->buffer = buffer; sound->buffer = buffer;
sound->length = length; sound->length = length;
return sound; return sound;
} }
JA_Sound JA_LoadSound(const char* filename) { JA_Sound_t *JA_LoadSound(const char* filename) {
JA_Sound sound = new JA_Sound_t(); JA_Sound_t *sound = new JA_Sound_t();
SDL_AudioSpec wavSpec; SDL_AudioSpec wavSpec;
SDL_LoadWAV(filename, &wavSpec, &sound->buffer, &sound->length); SDL_LoadWAV(filename, &wavSpec, &sound->buffer, &sound->length);
@@ -184,7 +185,7 @@ JA_Sound JA_LoadSound(const char* filename) {
return sound; return sound;
} }
int JA_PlaySound(JA_Sound sound, const int loop) { int JA_PlaySound(JA_Sound_t *sound, const int loop) {
int channel = 0; int channel = 0;
while (channel < JA_MAX_SIMULTANEOUS_CHANNELS && channels[channel].state != JA_CHANNEL_FREE) { channel++; } while (channel < JA_MAX_SIMULTANEOUS_CHANNELS && channels[channel].state != JA_CHANNEL_FREE) { channel++; }
if (channel == JA_MAX_SIMULTANEOUS_CHANNELS) channel = 0; if (channel == JA_MAX_SIMULTANEOUS_CHANNELS) channel = 0;
@@ -196,7 +197,7 @@ int JA_PlaySound(JA_Sound sound, const int loop) {
return channel; return channel;
} }
void JA_DeleteSound(JA_Sound sound) { void JA_DeleteSound(JA_Sound_t *sound) {
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) { for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
if (channels[i].sound == sound) JA_StopChannel(i); if (channels[i].sound == sound) JA_StopChannel(i);
} }
@@ -247,3 +248,4 @@ int JA_SetVolume(int volume) {
JA_volume = volume > 128 ? 128 : volume < 0 ? 0 : volume; JA_volume = volume > 128 ? 128 : volume < 0 ? 0 : volume;
return JA_volume; return JA_volume;
} }
#endif

View File

@@ -4,27 +4,27 @@
enum JA_Channel_state { JA_CHANNEL_INVALID, JA_CHANNEL_FREE, JA_CHANNEL_PLAYING, JA_CHANNEL_PAUSED }; enum JA_Channel_state { JA_CHANNEL_INVALID, JA_CHANNEL_FREE, JA_CHANNEL_PLAYING, JA_CHANNEL_PAUSED };
enum JA_Music_state { JA_MUSIC_INVALID, JA_MUSIC_PLAYING, JA_MUSIC_PAUSED, JA_MUSIC_STOPPED }; enum JA_Music_state { JA_MUSIC_INVALID, JA_MUSIC_PLAYING, JA_MUSIC_PAUSED, JA_MUSIC_STOPPED };
typedef struct JA_Sound_t *JA_Sound; struct JA_Sound_t;
typedef struct JA_Music_t *JA_Music; struct JA_Music_t;
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels); void JA_Init(const int freq, const SDL_AudioFormat format, const int channels);
void JA_Quit(); void JA_Quit();
JA_Music JA_LoadMusic(const char* filename); JA_Music_t *JA_LoadMusic(const char* filename);
void JA_PlayMusic(JA_Music music, const int loop = -1); void JA_PlayMusic(JA_Music_t *music, const int loop = -1);
void JA_PauseMusic(); void JA_PauseMusic();
void JA_ResumeMusic(); void JA_ResumeMusic();
void JA_StopMusic(); void JA_StopMusic();
JA_Music_state JA_GetMusicState(); JA_Music_state JA_GetMusicState();
void JA_DeleteMusic(JA_Music music); void JA_DeleteMusic(JA_Music_t *music);
JA_Sound JA_NewSound(Uint8* buffer, Uint32 length); JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length);
JA_Sound JA_LoadSound(const char* filename); JA_Sound_t *JA_LoadSound(const char* filename);
int JA_PlaySound(JA_Sound sound, const int loop = 0); int JA_PlaySound(JA_Sound_t *sound, const int loop = 0);
void JA_PauseChannel(const int channel); void JA_PauseChannel(const int channel);
void JA_ResumeChannel(const int channel); void JA_ResumeChannel(const int channel);
void JA_StopChannel(const int channel); void JA_StopChannel(const int channel);
JA_Channel_state JA_GetChannelState(const int channel); JA_Channel_state JA_GetChannelState(const int channel);
void JA_DeleteSound(JA_Sound sound); void JA_DeleteSound(JA_Sound_t *sound);
int JA_SetVolume(int volume); int JA_SetVolume(int volume);

View File

@@ -0,0 +1,101 @@
#ifdef JA_USESDLMIXER
#include "jail_audio.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <stdio.h>
struct JA_Sound_t {}; // Dummy structs
struct JA_Music_t {};
int JA_freq {48000};
SDL_AudioFormat JA_format {AUDIO_S16};
Uint8 JA_channels {2};
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels) {
JA_freq = freq;
JA_format = format;
JA_channels = channels;
Mix_OpenAudio(JA_freq, JA_format, JA_channels, 1024);
}
void JA_Quit() {
Mix_CloseAudio();
}
JA_Music_t *JA_LoadMusic(const char* filename) {
return (JA_Music_t*)Mix_LoadMUS(filename);
}
void JA_PlayMusic(JA_Music_t *music, const int loop) {
Mix_PlayMusic((Mix_Music*)music, loop);
}
void JA_PauseMusic() {
Mix_PauseMusic();
}
void JA_ResumeMusic() {
Mix_ResumeMusic();
}
void JA_StopMusic() {
Mix_HaltMusic();
}
JA_Music_state JA_GetMusicState() {
if (Mix_PausedMusic()) {
return JA_MUSIC_PAUSED;
} else if (Mix_PlayingMusic()) {
return JA_MUSIC_PLAYING;
} else {
return JA_MUSIC_STOPPED;
}
}
void JA_DeleteMusic(JA_Music_t *music) {
Mix_FreeMusic((Mix_Music*)music);
}
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length) {
return NULL;
}
JA_Sound_t *JA_LoadSound(const char* filename) {
JA_Sound_t *sound = (JA_Sound_t*)Mix_LoadWAV(filename);
return sound;
}
int JA_PlaySound(JA_Sound_t *sound, const int loop) {
return Mix_PlayChannel(-1, (Mix_Chunk*)sound, loop);
}
void JA_DeleteSound(JA_Sound_t *sound) {
Mix_FreeChunk((Mix_Chunk*)sound);
}
void JA_PauseChannel(const int channel) {
Mix_Pause(channel);
}
void JA_ResumeChannel(const int channel) {
Mix_Resume(channel);
}
void JA_StopChannel(const int channel) {
Mix_HaltChannel(channel);
}
JA_Channel_state JA_GetChannelState(const int channel) {
if (Mix_Paused(channel)) {
return JA_CHANNEL_PAUSED;
} else if (Mix_Playing(channel)) {
return JA_CHANNEL_PLAYING;
} else {
return JA_CHANNEL_FREE;
}
}
int JA_SetVolume(int volume) {
return Mix_Volume(-1, volume);
}
#endif

View File

@@ -458,7 +458,7 @@ void Menu::setSelectorPos(int index)
if (index < (int)item.size()) if (index < (int)item.size())
{ {
selector.index = index; selector.index = index;
selector.rect.y = selector.y = selector.originY = selector.targetY = item.at(selector.index).rect.y; selector.rect.y = selector.y = selector.originY = selector.targetY = item[selector.index].rect.y;
selector.rect.w = rectBG.rect.w; selector.rect.w = rectBG.rect.w;
selector.rect.x = rectBG.rect.x; selector.rect.x = rectBG.rect.x;
selector.originH = selector.targetH = selector.rect.h = getSelectorHeight(selector.index); selector.originH = selector.targetH = selector.rect.h = getSelectorHeight(selector.index);
@@ -486,13 +486,13 @@ void Menu::reset()
{ {
itemSelected = MENU_NO_OPTION; itemSelected = MENU_NO_OPTION;
selector.index = 0; selector.index = 0;
selector.originY = selector.targetY = selector.y = item.at(0).rect.y; selector.originY = selector.targetY = selector.y = item[0].rect.y;
selector.originH = selector.targetH = item.at(0).rect.h; selector.originH = selector.targetH = item[0].rect.h;
selector.moving = false; selector.moving = false;
selector.resizing = false; selector.resizing = false;
// Si el primer elemento no es seleccionable, incrementa el selector // Si el primer elemento no es seleccionable, incrementa el selector
if (!item.at(selector.index).selectable) if (!item[selector.index].selectable)
{ {
increaseSelectorIndex(); increaseSelectorIndex();
setSelectorPos(selector.index); setSelectorPos(selector.index);
@@ -524,18 +524,18 @@ void Menu::reorganize()
bool Menu::increaseSelectorIndex() bool Menu::increaseSelectorIndex()
{ {
// Obten las coordenadas del elemento actual // Obten las coordenadas del elemento actual
selector.y = selector.originY = item.at(selector.index).rect.y; selector.y = selector.originY = item[selector.index].rect.y;
selector.h = selector.originH = getSelectorHeight(selector.index); selector.h = selector.originH = getSelectorHeight(selector.index);
// Calcula cual es el siguiente elemento // Calcula cual es el siguiente elemento
++selector.index %= item.size(); ++selector.index %= item.size();
while (!item.at(selector.index).selectable) while (!item[selector.index].selectable)
{ {
++selector.index %= item.size(); ++selector.index %= item.size();
} }
// Establece las coordenadas y altura de destino // Establece las coordenadas y altura de destino
selector.targetY = item.at(selector.index).rect.y; selector.targetY = item[selector.index].rect.y;
selector.despY = (selector.targetY - selector.originY) / selector.numJumps; selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
selector.targetH = getSelectorHeight(selector.index); selector.targetH = getSelectorHeight(selector.index);
@@ -554,7 +554,7 @@ bool Menu::increaseSelectorIndex()
bool Menu::decreaseSelectorIndex() bool Menu::decreaseSelectorIndex()
{ {
// Obten las coordenadas del elemento actual // Obten las coordenadas del elemento actual
selector.y = selector.originY = item.at(selector.index).rect.y; selector.y = selector.originY = item[selector.index].rect.y;
selector.h = selector.originH = getSelectorHeight(selector.index); selector.h = selector.originH = getSelectorHeight(selector.index);
// Calcula cual es el siguiente elemento // Calcula cual es el siguiente elemento
@@ -567,7 +567,7 @@ bool Menu::decreaseSelectorIndex()
selector.index--; selector.index--;
} }
while (!item.at(selector.index).selectable) while (!item[selector.index].selectable)
{ {
if (selector.index == 0) if (selector.index == 0)
{ {
@@ -580,7 +580,7 @@ bool Menu::decreaseSelectorIndex()
} }
// Establece las coordenadas y altura de destino // Establece las coordenadas y altura de destino
selector.targetY = item.at(selector.index).rect.y; selector.targetY = item[selector.index].rect.y;
selector.despY = (selector.targetY - selector.originY) / selector.numJumps; selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
selector.targetH = getSelectorHeight(selector.index); selector.targetH = getSelectorHeight(selector.index);
@@ -630,29 +630,29 @@ void Menu::render()
if (i == selector.index) if (i == selector.index)
{ {
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b}; const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color); text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
} }
else if (item.at(i).selectable) else if (item[i].selectable)
{ {
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label); text->write(item[i].rect.x, item[i].rect.y, item[i].label);
} }
else if (item.at(i).greyed) else if (item[i].greyed)
{ {
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, colorGreyed); text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, colorGreyed);
} }
else else
{ // No seleccionable { // No seleccionable
if ((item.at(i).linkedUp) && (i == selector.index + 1)) if ((item[i].linkedUp) && (i == selector.index + 1))
{ {
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b}; const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color); text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
} }
else // No enlazado con el de arriba else // No enlazado con el de arriba
{ {
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label); text->write(item[i].rect.x, item[i].rect.y, item[i].label);
} }
} }
} }
@@ -822,7 +822,7 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
if (item.size() > 1) if (item.size() > 1)
{ {
if (item.at(item.size() - 2).linkedDown) if (item[item.size() - 2].linkedDown)
{ {
item.back().linkedUp = true; item.back().linkedUp = true;
} }
@@ -835,9 +835,9 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
// Cambia el texto de un item // Cambia el texto de un item
void Menu::setItemCaption(int index, std::string text) void Menu::setItemCaption(int index, std::string text)
{ {
item.at(index).label = text; item[index].label = text;
item.at(index).rect.w = this->text->lenght(item.at(index).label); item[index].rect.w = this->text->lenght(item[index].label);
item.at(index).rect.h = this->text->getCharacterSize(); item[index].rect.h = this->text->getCharacterSize();
reorganize(); reorganize();
} }
@@ -850,7 +850,7 @@ void Menu::setDefaultActionWhenCancel(int item)
// Gestiona la entrada de teclado y mando durante el menu // Gestiona la entrada de teclado y mando durante el menu
void Menu::checkInput() void Menu::checkInput()
{ {
if (input->checkInput(INPUT_UP, REPEAT_FALSE)) if (input->checkInput(input_up, REPEAT_FALSE))
{ {
if (decreaseSelectorIndex()) if (decreaseSelectorIndex())
{ {
@@ -861,7 +861,7 @@ void Menu::checkInput()
} }
} }
if (input->checkInput(INPUT_DOWN, REPEAT_FALSE)) if (input->checkInput(input_down, REPEAT_FALSE))
{ {
if (increaseSelectorIndex()) if (increaseSelectorIndex())
{ {
@@ -872,7 +872,7 @@ void Menu::checkInput()
} }
} }
if (input->checkInput(INPUT_ACCEPT, REPEAT_FALSE)) if (input->checkInput(input_accept, REPEAT_FALSE))
{ {
itemSelected = selector.index; itemSelected = selector.index;
if (soundAccept) if (soundAccept)
@@ -881,7 +881,7 @@ void Menu::checkInput()
} }
} }
if (input->checkInput(INPUT_CANCEL, REPEAT_FALSE)) if (input->checkInput(input_cancel, REPEAT_FALSE))
{ {
itemSelected = defaultActionWhenCancel; itemSelected = defaultActionWhenCancel;
if (soundCancel) if (soundCancel)
@@ -914,42 +914,42 @@ int Menu::findHeight()
// Recoloca los elementos del menu en el eje Y // Recoloca los elementos del menu en el eje Y
void Menu::replaceElementsOnY() void Menu::replaceElementsOnY()
{ {
item.at(0).rect.y = y; item[0].rect.y = y;
for (int i = 1; i < (int)item.size(); i++) for (int i = 1; i < (int)item.size(); i++)
{ {
item.at(i).rect.y = item.at(i - 1).rect.y + item.at(i - 1).rect.h + item.at(i - 1).hPaddingDown; item[i].rect.y = item[i - 1].rect.y + item[i - 1].rect.h + item[i - 1].hPaddingDown;
} }
} }
// Establece el estado seleccionable de un item // Establece el estado seleccionable de un item
void Menu::setSelectable(int index, bool value) void Menu::setSelectable(int index, bool value)
{ {
item.at(index).selectable = value; item[index].selectable = value;
} }
// Establece el estado agrisado de un item // Establece el estado agrisado de un item
void Menu::setGreyed(int index, bool value) void Menu::setGreyed(int index, bool value)
{ {
item.at(index).greyed = value; item[index].greyed = value;
} }
// Establece el estado de enlace de un item // Establece el estado de enlace de un item
void Menu::setLinkedDown(int index, bool value) void Menu::setLinkedDown(int index, bool value)
{ {
item.at(index).linkedDown = value; item[index].linkedDown = value;
} }
// Calcula la altura del selector // Calcula la altura del selector
int Menu::getSelectorHeight(int value) int Menu::getSelectorHeight(int value)
{ {
if (item.at(value).linkedDown) if (item[value].linkedDown)
{ {
return item.at(value).rect.h + item.at(value).hPaddingDown + item.at(value + 1).rect.h; return item[value].rect.h + item[value].hPaddingDown + item[value + 1].rect.h;
} }
else else
{ {
return item.at(value).rect.h; return item[value].rect.h;
} }
} }

View File

@@ -91,9 +91,9 @@ private:
bool isCenteredOnY; // Variable para saber si el menu debe estar centrado respecto a un punto en el eje Y bool isCenteredOnY; // Variable para saber si el menu debe estar centrado respecto a un punto en el eje Y
bool areElementsCenteredOnX; // Variable para saber si los elementos van centrados en el eje X bool areElementsCenteredOnX; // Variable para saber si los elementos van centrados en el eje X
int widestItem; // Anchura del elemento más ancho int widestItem; // Anchura del elemento más ancho
JA_Sound soundAccept; // Sonido al aceptar o elegir una opción del menu JA_Sound_t* soundAccept; // Sonido al aceptar o elegir una opción del menu
JA_Sound soundCancel; // Sonido al cancelar el menu JA_Sound_t* soundCancel; // Sonido al cancelar el menu
JA_Sound soundMove; // Sonido al mover el selector JA_Sound_t* soundMove; // Sonido al mover el selector
color_t colorGreyed; // Color para los elementos agrisados color_t colorGreyed; // Color para los elementos agrisados
rectangle_t rectBG; // Rectangulo de fondo del menu rectangle_t rectBG; // Rectangulo de fondo del menu
std::vector<item_t> item; // Estructura para cada elemento del menu std::vector<item_t> item; // Estructura para cada elemento del menu

View File

@@ -0,0 +1,285 @@
#include "notify.h"
#include <string>
#include <stdio.h>
#include <iostream>
// Constructor
Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options)
{
// Inicializa variables
this->renderer = renderer;
this->options = options;
bgColor = options->notifications.color;
waitTime = 300;
// Crea objetos
iconTexture = new Texture(renderer, iconFile);
textTexture = new Texture(renderer, bitmapFile);
text = new Text(textFile, textTexture, renderer);
sound = JA_LoadSound(soundFile.c_str());
}
// Destructor
Notify::~Notify()
{
// Libera la memoria de los objetos
delete textTexture;
delete iconTexture;
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[i].sprite->render();
}
}
// Actualiza el estado de las notificaiones
void Notify::update()
{
for (int i = 0; i < (int)notifications.size(); ++i)
{
// Si la notificación anterior está "saliendo", no hagas nada
if (i > 0)
{
if (notifications[i - 1].state == ns_rising)
{
break;
}
}
notifications[i].counter++;
// Hace sonar la notificación en el primer frame
if (notifications[i].counter == 1)
{
if (options->notifications.sound)
{
if (notifications[i].state == ns_rising)
{ // Reproduce el sonido de la notificación
JA_PlaySound(sound);
}
}
}
// Comprueba los estados
if (notifications[i].state == ns_rising)
{
const float step = ((float)notifications[i].counter / notifications[i].travelDist);
const int alpha = 255 * step;
if (options->notifications.posV == pos_top)
{
notifications[i].rect.y++;
}
else
{
notifications[i].rect.y--;
}
notifications[i].texture->setAlpha(alpha);
if (notifications[i].rect.y == notifications[i].y)
{
notifications[i].state = ns_stay;
notifications[i].texture->setAlpha(255);
notifications[i].counter = 0;
}
}
else if (notifications[i].state == ns_stay)
{
if (notifications[i].counter == waitTime)
{
notifications[i].state = ns_vanishing;
notifications[i].counter = 0;
}
}
else if (notifications[i].state == ns_vanishing)
{
const float step = (notifications[i].counter / (float)notifications[i].travelDist);
const int alpha = 255 * (1 - step);
if (options->notifications.posV == pos_top)
{
notifications[i].rect.y--;
}
else
{
notifications[i].rect.y++;
}
notifications[i].texture->setAlpha(alpha);
if (notifications[i].rect.y == notifications[i].y - notifications[i].travelDist)
{
notifications[i].state = ns_finished;
}
}
notifications[i].sprite->setRect(notifications[i].rect);
}
clearFinishedNotifications();
}
// Elimina las notificaciones finalizadas
void Notify::clearFinishedNotifications()
{
for (int i = (int)notifications.size() - 1; i >= 0; --i)
{
if (notifications[i].state == ns_finished)
{
delete notifications[i].sprite;
delete notifications[i].texture;
notifications.erase(notifications.begin() + i);
}
}
}
// Muestra una notificación de texto por pantalla;
void Notify::showText(std::string text1, std::string text2, int icon)
{
// Inicializa variables
const int iconSize = 16;
const int padding = text->getCharacterSize();
const int iconSpace = icon >= 0 ? iconSize + padding : 0;
const std::string txt = text1.length() > text2.length() ? text1 : text2;
const int width = text->lenght(txt) + (padding * 2) + iconSpace;
const int height = (text->getCharacterSize() * 2) + (padding * 2);
// Posición horizontal
int despH = 0;
if (options->notifications.posH == pos_left)
{
despH = padding;
}
else if (options->notifications.posH == pos_middle)
{
despH = ((options->screen.windowWidth * options->windowSize) / 2 - (width / 2));
}
else
{
despH = (options->screen.windowWidth * options->windowSize) - width - padding;
}
// Posición vertical
int despV = 0;
if (options->notifications.posV == pos_top)
{
despV = padding;
}
else
{
despV = (options->screen.windowHeight * options->windowSize) - height - padding;
}
const int travelDist = height + padding;
// Offset
int offset = 0;
if (options->notifications.posV == pos_top)
{
offset = (int)notifications.size() > 0 ? notifications.back().y + travelDist : despV;
}
else
{
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.text1 = text1;
n.text2 = text2;
if (options->notifications.posV == pos_top)
{
n.rect = {despH, offset - travelDist, width, height};
}
else
{
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->setBlendMode(SDL_BLENDMODE_BLEND);
// Prepara para dibujar en la textura
n.texture->setAsRenderTarget(renderer);
// Dibuja el fondo de la notificación
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
SDL_Rect rect;
rect = {4, 0, width - (4 * 2), height};
SDL_RenderFillRect(renderer, &rect);
rect = {4 / 2, 1, width - 4, height - 2};
SDL_RenderFillRect(renderer, &rect);
rect = {1, 4 / 2, width - 2, height - 4};
SDL_RenderFillRect(renderer, &rect);
rect = {0, 4, width, height - (4 * 2)};
SDL_RenderFillRect(renderer, &rect);
// Dibuja el icono de la notificación
if (icon >= 0)
{
Sprite *sp = new Sprite({0, 0, iconSize, iconSize}, iconTexture, renderer);
sp->setPos({padding, padding, iconSize, iconSize});
sp->setSpriteClip({iconSize * (icon % 10), iconSize * (icon / 10), iconSize, iconSize});
sp->render();
delete sp;
}
// Escribe el texto de la notificación
color_t color = {255, 255, 255};
if (text2 != "")
{ // Dos lineas de texto
text->writeColored(padding + iconSpace, padding, text1, color);
text->writeColored(padding + iconSpace, padding + text->getCharacterSize() + 1, text2, color);
}
else
{ // Una linea de texto
text->writeColored(padding + iconSpace, (height / 2) - (text->getCharacterSize() / 2), text1, color);
}
// Deja de dibujar en la textura
SDL_SetRenderTarget(renderer, nullptr);
// Crea el sprite de la notificación
n.sprite = new Sprite(n.rect, n.texture, renderer);
// Deja la notificación invisible
n.texture->setAlpha(0);
// Añade la notificación a la lista
notifications.push_back(n);
}
// Indica si hay notificaciones activas
bool Notify::active()
{
if ((int)notifications.size() > 0)
{
return true;
}
return false;
}

View File

@@ -36,7 +36,8 @@ private:
struct notification_t struct notification_t
{ {
std::string text; std::string text1;
std::string text2;
int counter; int counter;
notification_state_e state; notification_state_e state;
notification_position_e position; notification_position_e position;
@@ -49,7 +50,8 @@ private:
// Objetos y punteros // Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana SDL_Renderer *renderer; // El renderizador de la ventana
Texture *texture; // Textura para la fuente de las notificaciones Texture *textTexture; // Textura para la fuente de las notificaciones
Texture *iconTexture; // Textura para los iconos de las notificaciones
Text *text; // Objeto para dibujar texto Text *text; // Objeto para dibujar texto
options_t *options; // Variable con todas las opciones del programa options_t *options; // Variable con todas las opciones del programa
@@ -57,7 +59,7 @@ private:
color_t bgColor; // Color de fondo de las notificaciones color_t bgColor; // Color de fondo de las notificaciones
int waitTime; // Tiempo que se ve la notificación int waitTime; // Tiempo que se ve la notificación
std::vector<notification_t> notifications; // La lista de notificaciones activas std::vector<notification_t> notifications; // La lista de notificaciones activas
JA_Sound sound; // Sonido a reproducir cuando suena la notificación JA_Sound_t *sound; // Sonido a reproducir cuando suena la notificación
// Elimina las notificaciones finalizadas // Elimina las notificaciones finalizadas
void clearFinishedNotifications(); void clearFinishedNotifications();
@@ -70,13 +72,13 @@ public:
void update(); void update();
// Constructor // Constructor
Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options); Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options);
// Destructor // Destructor
~Notify(); ~Notify();
// Muestra una notificación de texto por pantalla; // Muestra una notificación de texto por pantalla;
void showText(std::string text); void showText(std::string text1 = "", std::string text2 = "", int icon = -1);
// Indica si hay notificaciones activas // Indica si hay notificaciones activas
bool active(); bool active();

View File

@@ -0,0 +1,176 @@
#include "paleta.h"
#include "gif.c"
#include <stdio.h>
struct jSurface_s
{
Uint8 *data;
Uint16 w, h;
};
static SDL_Texture *jTex = NULL;
static jSurface jScreen;
static jSurface jDestSurf;
static jSurface jSourceSurf = NULL;
static Uint32 paleta[256];
static int jWidth = 256;
static int jHeight = 128;
static int transparentColor = 255;
void pInit(SDL_Renderer *renderer, int w, int h)
{
jWidth = w;
jHeight = h;
jTex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h);
jScreen = pNewSurface(w, h);
jDestSurf = jScreen;
}
jSurface pNewSurface(int w, int h)
{
jSurface surf = (jSurface)malloc(sizeof(jSurface_s));
surf->w = w;
surf->h = h;
surf->data = (Uint8 *)malloc(w * h);
return surf;
}
void pDeleteSurface(jSurface surf)
{
if (surf == NULL)
return;
if (surf->data != NULL)
free(surf->data);
free(surf);
}
void pSetDest(jSurface surf)
{
if (surf == NULL)
jDestSurf = jScreen;
else
jDestSurf = surf;
}
void pSetSource(jSurface surf)
{
jSourceSurf = surf;
}
void pBlit(int dx, int dy, int sx, int sy, int w, int h)
{
if (jSourceSurf == NULL)
return;
for (int iy = 0; iy < h; ++iy)
{
for (int ix = 0; ix < w; ++ix)
pPutPixel(dx + ix, dy + iy, pGetPixel(sx + ix, sy + iy));
}
}
jSurface pLoadSurface(const char *filename)
{
FILE *f = fopen(filename, "rb");
if (!f)
return NULL;
fseek(f, 0, SEEK_END);
long size = ftell(f);
fseek(f, 0, SEEK_SET);
Uint8 *buffer = (Uint8 *)malloc(size);
fread(buffer, size, 1, f);
fclose(f);
Uint16 w, h;
Uint8 *pixels = LoadGif(buffer, &w, &h);
if (pixels == NULL)
{
return NULL;
}
jSurface surf = (jSurface)malloc(sizeof(jSurface_s));
surf->w = w;
surf->h = h;
surf->data = pixels;
free(buffer);
return surf;
}
void pLoadPal(const char *filename)
{
FILE *f = fopen(filename, "rb");
if (!f)
return;
fseek(f, 0, SEEK_END);
long size = ftell(f);
fseek(f, 0, SEEK_SET);
Uint8 *buffer = (Uint8 *)malloc(size);
fread(buffer, size, 1, f);
fclose(f);
Uint32 *pal = LoadPalette(buffer);
if (pal == NULL)
{
return;
}
free(buffer);
for (int i = 0; i < 256; ++i)
{
paleta[i] = pal[i];
}
}
void pSetPal(int index, Uint32 color)
{
paleta[index] = color;
}
void pCls(Uint8 color)
{
for (int i = 0; i < jDestSurf->w * jDestSurf->h; ++i)
jDestSurf->data[i] = color;
}
void pFlip(SDL_Renderer *renderer)
{
Uint32 *pixels;
int pitch;
SDL_LockTexture(jTex, NULL, (void **)&pixels, &pitch);
for (int i = 0; i < jWidth * jHeight; ++i)
pixels[i] = paleta[jScreen->data[i]];
SDL_UnlockTexture(jTex);
SDL_Rect rect = {0, 64, 256, 128};
SDL_RenderCopy(renderer, jTex, NULL, &rect);
}
void pPutPixel(int x, int y, Uint8 color)
{
if (x < 0 || y < 0 || x >= jDestSurf->w || y >= jDestSurf->h || color == transparentColor)
return;
jDestSurf->data[x + y * jDestSurf->w] = color;
}
Uint8 pGetPixel(int x, int y)
{
return jSourceSurf->data[x + y * jSourceSurf->w];
}
bool pFadePal()
{
// Colores pares
for (int i = 18; i > 0; i = i - 2)
{
paleta[i] = paleta[i - 2];
}
// Colores impares
for (int i = 17; i > 1; i = i - 2)
{
paleta[i] = paleta[i - 2];
}
paleta[1] = paleta[0];
return paleta[15] == paleta[0] ? true : false;
}

View File

@@ -0,0 +1,27 @@
#pragma once
#include <SDL2/SDL.h>
typedef struct jSurface_s *jSurface;
jSurface pNewSurface(int w, int h);
void pDeleteSurface(jSurface surf);
void pSetDest(jSurface surf);
void pSetSource(jSurface surf);
jSurface pLoadSurface(const char* filename);
void pPutPixel(int x, int y, Uint8 color);
Uint8 pGetPixel(int x, int y);
void pBlit(int dx, int dy, int sx, int sy, int w, int h);
void pInit(SDL_Renderer *renderer, int w, int h);
void pSetPal(int index, Uint32 color);
void pLoadPal(const char *filename);
void pCls(Uint8 color);
void pFlip(SDL_Renderer *renderer);
bool pFadePal();

View File

@@ -12,12 +12,10 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
this->asset = asset; this->asset = asset;
// Crea los objetos // Crea los objetos
notify = new Notify(renderer, asset->get("smb2.png"), asset->get("smb2.txt"), asset->get("notify.wav"), options); notify = new Notify(renderer, asset->get("notify.png"), asset->get("smb2.png"), asset->get("smb2.txt"), asset->get("notify.wav"), options);
gameCanvasWidth = options->gameWidth; gameCanvasWidth = options->gameWidth;
gameCanvasHeight = options->gameHeight; gameCanvasHeight = options->gameHeight;
borderWidth = options->borderWidth * 2;
borderHeight = options->borderHeight * 2;
notificationLogicalWidth = gameCanvasWidth; notificationLogicalWidth = gameCanvasWidth;
notificationLogicalHeight = gameCanvasHeight; notificationLogicalHeight = gameCanvasHeight;
@@ -33,10 +31,21 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
{ {
if (options->console) if (options->console)
{ {
std::cout << "TitleSurface could not be created!\nSDL Error: " << SDL_GetError() << std::endl; std::cout << "gameCanvas could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
} }
} }
// Crea la textura donde se dibuja el borde que rodea el area de juego
borderCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth + options->borderWidth * 2, gameCanvasHeight + options->borderHeight * 2);
if (borderCanvas == nullptr)
{
if (options->console)
{
std::cout << "borderCanvas could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
}
}
setBorderColor(borderColor);
// Establece el modo de video // Establece el modo de video
setVideoMode(options->videoMode); setVideoMode(options->videoMode);
@@ -48,6 +57,8 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
Screen::~Screen() Screen::~Screen()
{ {
delete notify; delete notify;
SDL_DestroyTexture(gameCanvas);
SDL_DestroyTexture(borderCanvas);
} }
// Limpia la pantalla // Limpia la pantalla
@@ -63,6 +74,12 @@ void Screen::start()
SDL_SetRenderTarget(renderer, gameCanvas); SDL_SetRenderTarget(renderer, gameCanvas);
} }
// Prepara para empezar a dibujar en la textura del borde
void Screen::startDrawOnBorder()
{
SDL_SetRenderTarget(renderer, borderCanvas);
}
// Vuelca el contenido del renderizador en pantalla // Vuelca el contenido del renderizador en pantalla
void Screen::blit() void Screen::blit()
{ {
@@ -70,10 +87,16 @@ void Screen::blit()
SDL_SetRenderTarget(renderer, nullptr); SDL_SetRenderTarget(renderer, nullptr);
// Borra el contenido previo // Borra el contenido previo
SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF); // SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF);
SDL_RenderClear(renderer); // SDL_RenderClear(renderer);
// Copia la textura de juego en el renderizador en la posición adecuada // Copia la textura del borde en la ventana
if (options->borderEnabled)
{
SDL_RenderCopy(renderer, borderCanvas, nullptr, nullptr);
}
// Copia la textura de juego en la ventana en la posición adecuada
SDL_RenderCopy(renderer, gameCanvas, nullptr, &dest); SDL_RenderCopy(renderer, gameCanvas, nullptr, &dest);
// Dibuja las notificaciones // Dibuja las notificaciones
@@ -86,20 +109,24 @@ void Screen::blit()
// Establece el modo de video // Establece el modo de video
void Screen::setVideoMode(int videoMode) void Screen::setVideoMode(int videoMode)
{ {
// Muestra el puntero
SDL_ShowCursor(SDL_ENABLE);
// Aplica el modo de video // Aplica el modo de video
SDL_SetWindowFullscreen(window, videoMode); SDL_SetWindowFullscreen(window, videoMode);
// Si está activo el modo ventana quita el borde // Modo ventana
if (videoMode == 0) if (videoMode == 0)
{ {
// Muestra el puntero
SDL_ShowCursor(SDL_ENABLE);
// Esconde la ventana
// SDL_HideWindow(window);
// Modifica el tamaño de la ventana en función del borde
if (options->borderEnabled) if (options->borderEnabled)
{ {
windowWidth = gameCanvasWidth + borderWidth; windowWidth = gameCanvasWidth + options->borderWidth * 2;
windowHeight = gameCanvasHeight + borderHeight; windowHeight = gameCanvasHeight + options->borderHeight * 2;
dest = {0 + (borderWidth / 2), 0 + (borderHeight / 2), gameCanvasWidth, gameCanvasHeight}; dest = {options->borderWidth, options->borderHeight, gameCanvasWidth, gameCanvasHeight};
} }
else else
@@ -109,9 +136,12 @@ void Screen::setVideoMode(int videoMode)
dest = {0, 0, gameCanvasWidth, gameCanvasHeight}; dest = {0, 0, gameCanvasWidth, gameCanvasHeight};
} }
// Modifica el tamaño del renderizador y de la ventana // Modifica el tamaño de la ventana
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
SDL_SetWindowSize(window, windowWidth * options->windowSize, windowHeight * options->windowSize); SDL_SetWindowSize(window, windowWidth * options->windowSize, windowHeight * options->windowSize);
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
// Muestra la ventana
// SDL_ShowWindow(window);
} }
// Si está activo el modo de pantalla completa añade el borde // Si está activo el modo de pantalla completa añade el borde
@@ -162,10 +192,10 @@ void Screen::setVideoMode(int videoMode)
dest.h = windowHeight; dest.h = windowHeight;
dest.x = dest.y = 0; dest.x = dest.y = 0;
} }
}
// Modifica el tamaño del renderizador // Modifica el tamaño del renderizador
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
}
// Actualiza las opciones // Actualiza las opciones
options->videoMode = videoMode; options->videoMode = videoMode;
@@ -190,10 +220,30 @@ void Screen::setWindowSize(int size)
setVideoMode(0); setVideoMode(0);
} }
// Reduce el tamaño de la ventana
void Screen::decWindowSize()
{
--options->windowSize;
options->windowSize = std::max(options->windowSize, 1);
setVideoMode(0);
}
// Aumenta el tamaño de la ventana
void Screen::incWindowSize()
{
++options->windowSize;
options->windowSize = std::min(options->windowSize, 4);
setVideoMode(0);
}
// Cambia el color del borde // Cambia el color del borde
void Screen::setBorderColor(color_t color) void Screen::setBorderColor(color_t color)
{ {
borderColor = color; borderColor = color;
SDL_SetRenderTarget(renderer, borderCanvas);
SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF);
SDL_RenderClear(renderer);
SDL_SetRenderTarget(renderer, nullptr);
} }
// Cambia el tipo de mezcla // Cambia el tipo de mezcla
@@ -344,7 +394,7 @@ void Screen::renderSpectrumFade()
const float step = (float)spectrumFadeCounter / (float)spectrumFadeLenght; const float step = (float)spectrumFadeCounter / (float)spectrumFadeLenght;
const int max = spectrumColor.size() - 1; const int max = spectrumColor.size() - 1;
const int index = max + (0 - max) * step; const int index = max + (0 - max) * step;
const color_t c = spectrumColor.at(index); const color_t c = spectrumColor[index];
SDL_SetTextureColorMod(gameCanvas, c.r, c.g, c.b); SDL_SetTextureColorMod(gameCanvas, c.r, c.g, c.b);
} }
@@ -370,9 +420,9 @@ void Screen::updateNotifier()
} }
// Muestra una notificación de texto por pantalla; // Muestra una notificación de texto por pantalla;
void Screen::showNotification(std::string text) void Screen::showNotification(std::string text1, std::string text2, int icon)
{ {
notify->showText(text); notify->showText(text1, text2, icon);
} }
// Dibuja las notificaciones // Dibuja las notificaciones

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