Compare commits
144 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e525642a0 | |||
| c7db6aeaa3 | |||
| 5ff04daf20 | |||
| 5bb2b5e7c4 | |||
| 7a685c0cc8 | |||
| 07e83fc811 | |||
| 3167251eae | |||
| 4efbb61fbc | |||
| 3992fc08bf | |||
| 366fe404ca | |||
| 217781c621 | |||
| 212b2b481c | |||
| 59e766f5c3 | |||
| 2e11fec2cb | |||
| 0d7ab830c9 | |||
| 0cec9f8556 | |||
| c6474cb2da | |||
| e6fd4225a2 | |||
| 85ab5ea03f | |||
| 2457517f2b | |||
| 64880a427e | |||
| a8e5517a77 | |||
| a07a08adb7 | |||
| 32c31a8cb6 | |||
| c9da5135b2 | |||
| 817140825a | |||
| e6f101ece6 | |||
| 48971cd5d1 | |||
| 5bb5be9c33 | |||
| 2ee0c70319 | |||
| 3ba4293e8a | |||
| 8ae686a70b | |||
| 2ac425483b | |||
| fc01676df2 | |||
| e361d295c1 | |||
| f6098a479b | |||
| 7a0bc5c9ae | |||
| 5f68c6256f | |||
| debcc3409e | |||
| c86a6496b3 | |||
| 6bb877b510 | |||
| ec73c5fa30 | |||
| 4dd6c94730 | |||
| e1d6aff724 | |||
| bcb2e96069 | |||
| e23f6b5ed9 | |||
| 9cb57e2ff2 | |||
| cc0f050c50 | |||
| d75a733985 | |||
| 33d91dab55 | |||
| bd6807d655 | |||
| c6d15bb96f | |||
| e20cc3b4bb | |||
| 0baf7e5e2c | |||
| d9d4818d8a | |||
| 944784b329 | |||
| df4c1366fe | |||
| 1ee1ea560b | |||
| 5c7f72253c | |||
| e2e41cf435 | |||
| 674323d445 | |||
| f4e2c11f1b | |||
| 1b130feb85 | |||
| 5f3ecbbd79 | |||
| 250efd69bf | |||
| 7cd5fec3f8 | |||
| 8e612aaa2e | |||
| 2d045642ff | |||
| 01dff96fdc | |||
| 62d1a566c0 | |||
| 39016a3912 | |||
| 866cb56f1b | |||
| 6de3050255 | |||
| f602b5ff7a | |||
| c34b4d8944 | |||
| c835f943b5 | |||
| 9b265c6cca | |||
| 6a526df9b3 | |||
| 3def97bcb8 | |||
| 0a07edcb5c | |||
| 62d90a605f | |||
| d718e20767 | |||
| 20c63c7ef5 | |||
| a68ffa8e21 | |||
| 693939a6d5 | |||
| 031e4b99f4 | |||
| 1a095d292f | |||
| d51d564642 | |||
| bafde2a778 | |||
| 7dcc1d7809 | |||
| 38aadb984d | |||
| e259313cc9 | |||
| c49323cfdf | |||
| 619acbc9b4 | |||
| e39806f1a3 | |||
| e2618f40db | |||
| 97a6ba474f | |||
| 07054544e4 | |||
| 99f6ea7dd4 | |||
| 45b75dc75f | |||
| a4fd00794d | |||
| ee261f4509 | |||
| eb713006c6 | |||
| a07eeff6e4 | |||
| cce0ccba76 | |||
| 0ea7eb0b9c | |||
| 4a2d27dc59 | |||
| 71be364141 | |||
| 16cc725cb3 | |||
| a05dbc7581 | |||
| 2db0b43d23 | |||
| d6c100379e | |||
| 22e8579337 | |||
| d0c0715640 | |||
| 38e0573a0e | |||
| f259fbb3a5 | |||
| 663e1ed32e | |||
| b1887fe6da | |||
| 3fcf3b23e0 | |||
| 284f7d5bad | |||
| adab0b420c | |||
| 4f9d8bec42 | |||
| 31e657d138 | |||
| 8b3d257baf | |||
| d1143b9dfe | |||
| 68ebff722e | |||
| 3be9d4459c | |||
| 76e928e21d | |||
| 9c6924d7bb | |||
| 5007bea835 | |||
| 5e7be1c2fb | |||
| faf2e69b63 | |||
| 4c3c844ccf | |||
| 48b8ae049a | |||
| c0d4eddde7 | |||
| f590101047 | |||
| c7fcbd0258 | |||
| b2061c86d2 | |||
| 510a6ca718 | |||
| ec8209265a | |||
| e963251fd9 | |||
| a2f1efd2a6 | |||
| 8959b7bcce | |||
| 4d8bb46a52 |
5
.gitignore
vendored
@@ -11,3 +11,8 @@ thumbs.db
|
|||||||
*.zip
|
*.zip
|
||||||
*.app
|
*.app
|
||||||
*_debug*
|
*_debug*
|
||||||
|
sync_jail_engine.sh
|
||||||
|
jaildoctors_dilemma*
|
||||||
|
todo
|
||||||
|
build/
|
||||||
|
linux_utils/
|
||||||
85
CMakeLists.txt
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
# CMakeLists.txt
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
project(jaildoctors_dilemma VERSION 1.00)
|
||||||
|
|
||||||
|
# Configuración de compilador para MinGW en Windows, si es necesario
|
||||||
|
if(WIN32 AND NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
|
set(CMAKE_CXX_COMPILER "g++")
|
||||||
|
set(CMAKE_C_COMPILER "gcc")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Establecer estándar de C++
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
|
# Configuración global de flags de compilación
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os -ffunction-sections -fdata-sections")
|
||||||
|
|
||||||
|
# Define el directorio de los archivos fuente
|
||||||
|
set(DIR_SOURCES "${CMAKE_SOURCE_DIR}/source")
|
||||||
|
|
||||||
|
# Cargar todos los archivos fuente en DIR_SOURCES
|
||||||
|
file(GLOB SOURCES "${DIR_SOURCES}/*.cpp")
|
||||||
|
|
||||||
|
# Verificar si se encontraron archivos fuente
|
||||||
|
if(NOT SOURCES)
|
||||||
|
message(FATAL_ERROR "No se encontraron archivos fuente en ${DIR_SOURCES}. Verifica que el directorio existe y contiene archivos .cpp.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Configuración de SDL2
|
||||||
|
find_package(SDL2 REQUIRED)
|
||||||
|
if(SDL2_FOUND)
|
||||||
|
message(STATUS "SDL2 encontrado: ${SDL2_INCLUDE_DIRS}")
|
||||||
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
|
link_directories(${SDL2_LIBDIR})
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "SDL2 no encontrado")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Incluye rutas de SDL2 obtenidas con pkg-config
|
||||||
|
include_directories(/usr/local/include /usr/local/include/SDL2)
|
||||||
|
link_directories(/usr/local/lib)
|
||||||
|
|
||||||
|
# Definir las bibliotecas comunes
|
||||||
|
set(LIBS SDL2)
|
||||||
|
|
||||||
|
# Configuración común de salida de ejecutables en el directorio raíz
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
|
# Añadir ejecutable principal
|
||||||
|
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||||
|
|
||||||
|
# Añadir definiciones de compilación dependiendo del tipo de build
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<CONFIG:DEBUG>:DEBUG VERBOSE>)
|
||||||
|
|
||||||
|
# Enlazar bibliotecas
|
||||||
|
target_link_libraries(${PROJECT_NAME} ${LIBS})
|
||||||
|
|
||||||
|
# Configuración específica para cada plataforma
|
||||||
|
if(WIN32)
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE WINDOWS_BUILD)
|
||||||
|
target_link_libraries(${PROJECT_NAME} mingw32 opengl32 gdi32 winmm imm32 ole32 version)
|
||||||
|
elseif(APPLE)
|
||||||
|
set(LIBS ${LIBS} "-framework OpenGL")
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE MACOS_BUILD)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
|
||||||
|
# Configurar compilación para Apple Silicon
|
||||||
|
set(CMAKE_OSX_ARCHITECTURES "arm64")
|
||||||
|
elseif(UNIX AND NOT APPLE)
|
||||||
|
set(LIBS ${LIBS} GL)
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE LINUX_BUILD)
|
||||||
|
target_link_libraries(${PROJECT_NAME} ${LIBS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Añadir OpenGL a las bibliotecas enlazadas
|
||||||
|
if(NOT WIN32)
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
if(OPENGL_FOUND)
|
||||||
|
message(STATUS "OpenGL encontrado: ${OPENGL_LIBRARIES}")
|
||||||
|
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES})
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "OpenGL no encontrado")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
232
LICENSE.txt
@@ -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>.
|
|
||||||
33
Makefile
@@ -1,8 +1,8 @@
|
|||||||
executable = jaildoctors_dilemma
|
executable = jaildoctors_dilemma
|
||||||
source = source/*.cpp source/common/*.cpp
|
source = source/*.cpp
|
||||||
appName = JailDoctor's Dilemma
|
appName = JailDoctor's Dilemma
|
||||||
releaseFolder = jdd_release
|
releaseFolder = jdd_release
|
||||||
version = v1.07
|
version = v1.09
|
||||||
|
|
||||||
# Release names
|
# Release names
|
||||||
windowsRelease = $(executable)-$(version)-win32-x64.zip
|
windowsRelease = $(executable)-$(version)-win32-x64.zip
|
||||||
@@ -10,14 +10,17 @@ macosIntelRelease = $(executable)-$(version)-macos-intel.dmg
|
|||||||
macosAppleSiliconRelease = $(executable)-$(version)-macos-apple-silicon.dmg
|
macosAppleSiliconRelease = $(executable)-$(version)-macos-apple-silicon.dmg
|
||||||
linuxRelease = $(executable)-$(version)-linux.tar.gz
|
linuxRelease = $(executable)-$(version)-linux.tar.gz
|
||||||
|
|
||||||
|
# Specify the C++ standard
|
||||||
|
cpp_standard = c++20
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
@echo off
|
@echo off
|
||||||
g++ $(source) -std=c++11 -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(executable).exe"
|
g++ $(source) -std=$(cpp_standard) -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -lopengl32 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(executable).exe"
|
||||||
strip -s -R .comment -R .gnu.version "$(executable).exe" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(executable).exe" --strip-unneeded
|
||||||
|
|
||||||
windows_debug:
|
windows_debug:
|
||||||
@echo off
|
@echo off
|
||||||
g++ $(source) -D DEBUG -std=c++11 -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(executable)_debug.exe"
|
g++ $(source) -D DEBUG -std=$(cpp_standard) -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -lopengl32 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(executable)_debug.exe"
|
||||||
strip -s -R .comment -R .gnu.version "$(executable)_debug.exe" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(executable)_debug.exe" --strip-unneeded
|
||||||
|
|
||||||
windows_release:
|
windows_release:
|
||||||
@@ -33,12 +36,12 @@ 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)"
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
g++ $(source) -std=c++11 -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(releaseFolder)/$(executable).exe"
|
g++ $(source) -std=$(cpp_standard) -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -lopengl32 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(releaseFolder)/$(executable).exe"
|
||||||
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable).exe" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable).exe" --strip-unneeded
|
||||||
|
|
||||||
# Create ZIP
|
# Create ZIP
|
||||||
@@ -49,10 +52,10 @@ windows_release:
|
|||||||
powershell if (Test-Path "$(releaseFolder)") {Remove-Item "$(releaseFolder)" -Recurse -Force}
|
powershell if (Test-Path "$(releaseFolder)") {Remove-Item "$(releaseFolder)" -Recurse -Force}
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
clang++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o "$(executable)"
|
clang++ $(source) -std=$(cpp_standard) -Wall -Os -lSDL2 -framework OpenGL -Wno-deprecated -ffunction-sections -fdata-sections -o "$(executable)"
|
||||||
|
|
||||||
macos_debug:
|
macos_debug:
|
||||||
clang++ $(source) -D DEBUG -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o "$(executable)_debug"
|
clang++ $(source) -D DEBUG -std=$(cpp_standard) -Wall -Os -lSDL2 -framework OpenGL -Wno-deprecated -ffunction-sections -fdata-sections -o "$(executable)_debug"
|
||||||
|
|
||||||
macos_release:
|
macos_release:
|
||||||
# Remove data and possible data from previous builds
|
# Remove data and possible data from previous builds
|
||||||
@@ -80,14 +83,14 @@ 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
|
||||||
ln -s /Applications "$(releaseFolder)"/Applications
|
ln -s /Applications "$(releaseFolder)"/Applications
|
||||||
|
|
||||||
# Build INTEL
|
# Build INTEL
|
||||||
clang++ $(source) -D MACOS_BUNDLE -std=c++11 -Wall -Os -framework SDL2 -F ./Frameworks -ffunction-sections -fdata-sections -o "$(releaseFolder)/$(appName).app/Contents/MacOS/$(executable)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12
|
clang++ $(source) -D MACOS_BUNDLE -std=$(cpp_standard) -Wall -Os -framework SDL2 -F ./Frameworks -framework OpenGL -Wno-deprecated -ffunction-sections -fdata-sections -o "$(releaseFolder)/$(appName).app/Contents/MacOS/$(executable)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12
|
||||||
|
|
||||||
# Build INTEL DMG
|
# Build INTEL DMG
|
||||||
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
||||||
@@ -95,7 +98,7 @@ macos_release:
|
|||||||
rm -f tmp.dmg
|
rm -f tmp.dmg
|
||||||
|
|
||||||
# Build APPLE SILICON
|
# Build APPLE SILICON
|
||||||
clang++ $(source) -D MACOS_BUNDLE -std=c++11 -Wall -Os -framework SDL2 -F ./Frameworks -ffunction-sections -fdata-sections -o "$(releaseFolder)/$(appName).app/Contents/MacOS/$(executable)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11
|
clang++ $(source) -D MACOS_BUNDLE -std=$(cpp_standard) -Wall -Os -framework SDL2 -F ./Frameworks -framework OpenGL -Wno-deprecated -ffunction-sections -fdata-sections -o "$(releaseFolder)/$(appName).app/Contents/MacOS/$(executable)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11
|
||||||
|
|
||||||
# Build APPLE SILICON DMG
|
# Build APPLE SILICON DMG
|
||||||
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
||||||
@@ -107,11 +110,11 @@ macos_release:
|
|||||||
rm -rdf "$(releaseFolder)"
|
rm -rdf "$(releaseFolder)"
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
g++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)"
|
g++ $(source) -std=$(cpp_standard) -Wall -Os -lSDL2 -lGL -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)"
|
||||||
strip -s -R .comment -R .gnu.version "$(executable)" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(executable)" --strip-unneeded
|
||||||
|
|
||||||
linux_debug:
|
linux_debug:
|
||||||
g++ $(source) -D DEBUG -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)_debug"
|
g++ $(source) -D DEBUG -std=$(cpp_standard) -Wall -Os -lSDL2 -lGL -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)_debug"
|
||||||
strip -s -R .comment -R .gnu.version "$(executable)_debug" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(executable)_debug" --strip-unneeded
|
||||||
|
|
||||||
linux_release:
|
linux_release:
|
||||||
@@ -123,7 +126,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
|
||||||
@@ -131,7 +134,7 @@ linux_release:
|
|||||||
rm -f "$(releaseFolder)/data/room/standard.tsx"
|
rm -f "$(releaseFolder)/data/room/standard.tsx"
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
g++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(releaseFolder)/$(executable)"
|
g++ $(source) -std=$(cpp_standard) -Wall -Os -lSDL2 -lGL -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(releaseFolder)/$(executable)"
|
||||||
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable)" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable)" --strip-unneeded
|
||||||
|
|
||||||
# Pack files
|
# Pack files
|
||||||
|
|||||||
100
README.md
@@ -1,87 +1,65 @@
|
|||||||
# JailDoctor's Dilemma (v1.07)
|
# 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 és un Jailer. Als Jailers els agrada començar projectes. A ningú li agrada acabar-los. Els Jailers viuen a la Jail. A la Jail s'hi va a començar projectes. A la Jail s'hi va a ensenyar els projectes. A la Jail s'hi va a aprendre com començar nous projectes. A la Jail s'hi va a ajudar els companys a començar nous projectes.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
JailDoc és un Jailer destacat entre els Jailers. Té més projectes començats que ningú i és qui més ajuda als altres a iniciar els seus.
|
||||||
|
|
||||||

|
Però un dia, va passar una cosa inesperada. Algú va acabar un projecte. Algú va alliberar el *Puzzle Jail Facker*. Un autèntic desaprensiu.
|
||||||
|
|
||||||
|
Això va fer que JailDoc prenguera una decisió: acabaria i lliuraria un dels seus projectes. Però, quin? *JailBattle*? *Sigmasuá*? *Calculín Doom*? Quin dilema! Finalment, es va arromangar i va decidir acabar i lliurar **tots** els seus projectes inacabats. Ho aconseguirà?
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
JailDoc es un Jailer destacado entre los Jailers. Tiene más proyectos empezados que nadie y es el que más ayuda a que los demas empiecen los suyos.
|
## Jugabilitat
|
||||||
|
|
||||||
|
Ajuda a JailDoc a recuperar les peces dels seus projectes, que estan escampades per qualsevol racó de l'Univers Jailer. Hi ha més de **150 peces** repartides en **60 pantalles**. Algunes són senzilles, però en altres hauràs de calcular molt bé els teus moviments si no vols acabar com un *arounder* més.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
Un día, ocurrió algo. Alguien terminó un proyecto. Alguien liberó el *Puzzle Jail Facker*. Algún desaprensivo.
|
Quan hages recuperat la major part de les peces, dirigeix-te a la Jail per mostrar als Jailers com es finalitza un projecte. Però compte! Bry no et deixarà entrar així com així. Només aquells que han creat un *Fire Effect* o un *Facedor de Tornejos* són dignes d'aquesta fita.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Controls
|
||||||
|
|
||||||
Esto hizo que JailDoc decidiera terminar y entregar uno de sus proyectos, pero, ¿cual? ¿JailBattle? ¿Sigmasuá? ¿Calculín Doom? Menudo dilema. JailDoc se arremangó y decidió finalizar y entregar todos sus proyectos inacabados. ¿Lo logrará?
|
El joc permet tant l'ús del teclat com d'un comandament. Les tecles per a jugar són les següents:
|
||||||
|
|
||||||
|
- **Cursors**: Per moure's a l'esquerra o dreta i per saltar. Es poden modificar les tecles en el fitxer de configuració, triant entre aquestes opcions:
|
||||||
|
- O, P per moure's i Q per saltar.
|
||||||
|
- A, D per moure's i W per saltar.
|
||||||
|
|
||||||
|
- **Tecla M**: Activa o desactiva la música.
|
||||||
|
- **Tecla P**: Pausa el joc.
|
||||||
|
- **Tecla ESC**: Ix del joc si estàs jugant. Tanca el programa en qualsevol altra circumstància.
|
||||||
|
- **Tecla F1**: Disminueix la mida de la finestra.
|
||||||
|
- **Tecla F2**: Augmenta la mida de la finestra.
|
||||||
|
- **Tecla F3**: Alterna entre el mode de pantalla completa i el mode finestra.
|
||||||
|
- **Tecla F4**: Activa o desactiva els shaders
|
||||||
|
- **Tecla F5**: Canvia la paleta de colors del joc.
|
||||||
|
- **Tecla B**: Activa o desactiva el marge de colors en mode finestra.
|
||||||
|
|
||||||
## Jugabilidad
|

|
||||||
|
|
||||||
Ayuda a JailDoc a recuperar las partes de su proyecto que estan desperdigadas por cualquier lugar del Universo Jailer. Hay mas de **150 piezas** desperdigadas por **60 pantallas**. Algunas son un paseo, pero en otras tendras que calcular muy bien tus movimientos si no quieres acabar como un arounder del montón.
|
---
|
||||||
|
|
||||||
|
## Dades del programa
|
||||||
|
|
||||||
|
El programa guarda automàticament la configuració del mode de vídeo i les estadístiques del joc a la teua carpeta personal del sistema. La ubicació d'aquesta carpeta depén del sistema operatiu que utilitzes:
|
||||||
|
|
||||||

|
- **Windows**: `C:\Users\<nom_d'usuari>\AppData\Roaming\jailgames\jaildoctors_dilemma`
|
||||||
|
- **MacOS**: `~/Library/Application Support/jailgames/jaildoctors_dilemma`
|
||||||
|
- **Linux**: `~/.jailgames/jaildoctors_dilemma`
|
||||||
|
|
||||||
|
Dins de la carpeta es troba el fitxer de configuració `config.txt`, on es pot modificar la configuració per connectar-se al servei en línia, i els fitxers `stats.csv` i `stats_buffer.csv`, que contenen informació sobre les estadístiques del joc.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
Cuando consigas recuperar gran parte de las piezas desperdigadas, dirigete a la Jail a mostrar a los Jailers como se termina un proyecto. Ten en cuenta que Bry no te dejará entrar. Solo aquellos que han realizado un *Fire Effect* o un *Facedor de Tornejos* son dignos de tal privilegio.
|
## Agraïments
|
||||||
|
|
||||||
|
Gràcies, com sempre, a tots els Jailers per motivar-me a crear aquest joc i per ajudar-me en els moments de dubte en escriure el codi. I, com sempre, un agraïment especial a JailDoc per la seua unitat de *Jail_Audio* i per qualsevol altre codi, ajuda o ensenyament que haja necessitat per a completar el programa.
|
||||||
|
|
||||||
|
Si no he perdut el compte, aquest és el quart joc que aconseguisc crear.
|
||||||
|
|
||||||
## Controles
|
*13 de novembre de 2022, JailDesigner*
|
||||||
|
|
||||||
El juego permite tanto el uso del teclado como de un mando de control. Las teclas para manejar el juego son las siguientes:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- **Cursores**: Para mover a izquierda o derecha a JailDoc y para saltar. En el fichero de configuración se pueden cambiar las teclas por otras opciones prefijadas: O, P para moverse y Q para saltar o A, D para moverse y W para saltar.
|
|
||||||
|
|
||||||
- **Tecla M**: Activa o desactiva la música
|
|
||||||
|
|
||||||
- **Tecla P**: Pone en pausa el juego
|
|
||||||
|
|
||||||
- **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
|
|
||||||
|
|
||||||
- **Teclas F1 a F4**: Cambian el tamaño de la ventana
|
|
||||||
|
|
||||||
- **Tecla B**: Activa o desactiva el borde de colores de la pantalla cuando el programa se ejecuta en modo de ventana
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Datos del programa
|
|
||||||
El programa guarda automáticamente la configuración del modo de video y las estadísticas de juego en tu carpeta personal del sistema. Esta carpeta tiene una ubicación distinta en función del sistema operativo que utilices.
|
|
||||||
|
|
||||||
En **Windows** se encuentra en:
|
|
||||||
`C:\Users\<nombre_de_usuario>\AppData\Roaming\jaildoctors_dilemma`
|
|
||||||
|
|
||||||
En **MacOS** se encuentra en:
|
|
||||||
`~/Library/Application Support/jaildoctors_dilemma`
|
|
||||||
|
|
||||||
En **Linux** se encuentra en:
|
|
||||||
`~/.jaildoctors_dilemma`
|
|
||||||
|
|
||||||
La primera vez, el juego te pregunta por tu identificador online. Esta información se guarda para futuras partidas.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
## Agradecimientos
|
|
||||||
|
|
||||||
Agradecimientos como siempre a todos los Jailers por motivarme a hacer el juego y ayudarme en los momentos de duda a la hora de escribir el código. Y, como siempre, en especial a JailDoc por su unidad de Jail_Audio y cualquier otro código/ayuda/enseñanzas que haya necesitado para terminar el programa.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Si no me he descontado, este es el cuarto juego que consigo crear.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*13 de noviembre de 2022, JailDesigner*
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=8
|
frame_height=8
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=8
|
frame_height=8
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=9
|
frame_width=9
|
||||||
frameHeight=7
|
frame_height=7
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=8
|
frame_height=8
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=24
|
frame_width=24
|
||||||
frameHeight=32
|
frame_height=32
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=10
|
frame_width=10
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=22
|
frame_width=22
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=7
|
frame_width=7
|
||||||
frameHeight=7
|
frame_height=7
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=13
|
frame_width=13
|
||||||
frameHeight=15
|
frame_height=15
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=11
|
frame_width=11
|
||||||
frameHeight=13
|
frame_height=13
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=32
|
frame_height=32
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=8
|
frame_height=8
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=43
|
frame_width=43
|
||||||
frameHeight=44
|
frame_height=44
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=79
|
frame_width=79
|
||||||
frameHeight=90
|
frame_height=90
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=62
|
frame_width=62
|
||||||
frameHeight=47
|
frame_height=47
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=64
|
frame_width=64
|
||||||
frameHeight=64
|
frame_height=64
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=8
|
frame_height=8
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=7
|
frame_width=7
|
||||||
frameHeight=8
|
frame_height=8
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=18
|
frame_height=18
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=24
|
frame_width=24
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=5
|
frame_width=5
|
||||||
frameHeight=8
|
frame_height=8
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=8
|
frame_height=8
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=16
|
frame_width=16
|
||||||
frameHeight=32
|
frame_height=32
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
BIN
data/font/8bithud.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
194
data/font/8bithud.txt
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
# box width
|
||||||
|
8
|
||||||
|
# box height
|
||||||
|
8
|
||||||
|
# 32 espacio ( )
|
||||||
|
2
|
||||||
|
# 33 !
|
||||||
|
2
|
||||||
|
# 34 "
|
||||||
|
5
|
||||||
|
# 35 #
|
||||||
|
6
|
||||||
|
# 36 $
|
||||||
|
6
|
||||||
|
# 37 %
|
||||||
|
6
|
||||||
|
# 38 &
|
||||||
|
6
|
||||||
|
# 39 '
|
||||||
|
2
|
||||||
|
# 40 (
|
||||||
|
3
|
||||||
|
# 41 )
|
||||||
|
3
|
||||||
|
# 42 *
|
||||||
|
4
|
||||||
|
# 43 +
|
||||||
|
3
|
||||||
|
# 44 ,
|
||||||
|
2
|
||||||
|
# 45 -
|
||||||
|
3
|
||||||
|
# 46 .
|
||||||
|
2
|
||||||
|
# 47 /
|
||||||
|
4
|
||||||
|
# 48 0
|
||||||
|
6
|
||||||
|
# 49 1
|
||||||
|
6
|
||||||
|
# 50 2
|
||||||
|
6
|
||||||
|
# 51 3
|
||||||
|
6
|
||||||
|
# 52 4
|
||||||
|
6
|
||||||
|
# 53 5
|
||||||
|
6
|
||||||
|
# 54 6
|
||||||
|
6
|
||||||
|
# 55 7
|
||||||
|
6
|
||||||
|
# 56 8
|
||||||
|
6
|
||||||
|
# 57 9
|
||||||
|
6
|
||||||
|
# 58 :
|
||||||
|
2
|
||||||
|
# 59 ;
|
||||||
|
2
|
||||||
|
# 60 <
|
||||||
|
4
|
||||||
|
# 61 =
|
||||||
|
3
|
||||||
|
# 62 >
|
||||||
|
4
|
||||||
|
# 63 ?
|
||||||
|
6
|
||||||
|
# 64 @
|
||||||
|
8
|
||||||
|
# 65 A
|
||||||
|
6
|
||||||
|
# 66 B
|
||||||
|
6
|
||||||
|
# 67 C
|
||||||
|
6
|
||||||
|
# 68 D
|
||||||
|
6
|
||||||
|
# 69 E
|
||||||
|
6
|
||||||
|
# 70 F
|
||||||
|
6
|
||||||
|
# 71 G
|
||||||
|
6
|
||||||
|
# 72 H
|
||||||
|
6
|
||||||
|
# 73 I
|
||||||
|
6
|
||||||
|
# 74 J
|
||||||
|
6
|
||||||
|
# 75 K
|
||||||
|
6
|
||||||
|
# 76 L
|
||||||
|
6
|
||||||
|
# 77 M
|
||||||
|
6
|
||||||
|
# 78 N
|
||||||
|
6
|
||||||
|
# 79 O
|
||||||
|
6
|
||||||
|
# 80 P
|
||||||
|
6
|
||||||
|
# 81 Q
|
||||||
|
6
|
||||||
|
# 82 R
|
||||||
|
6
|
||||||
|
# 83 S
|
||||||
|
6
|
||||||
|
# 84 T
|
||||||
|
6
|
||||||
|
# 85 U
|
||||||
|
6
|
||||||
|
# 86 V
|
||||||
|
5
|
||||||
|
# 87 W
|
||||||
|
6
|
||||||
|
# 88 X
|
||||||
|
6
|
||||||
|
# 89 Y
|
||||||
|
6
|
||||||
|
# 90 Z
|
||||||
|
6
|
||||||
|
# 91 [
|
||||||
|
3
|
||||||
|
# 92 \
|
||||||
|
5
|
||||||
|
# 93 ]
|
||||||
|
3
|
||||||
|
# 94 ^
|
||||||
|
4
|
||||||
|
# 95 _
|
||||||
|
6
|
||||||
|
# 96 `
|
||||||
|
2
|
||||||
|
# 97 a
|
||||||
|
5
|
||||||
|
# 98 b
|
||||||
|
5
|
||||||
|
# 99 c
|
||||||
|
5
|
||||||
|
# 100 d
|
||||||
|
5
|
||||||
|
# 101 e
|
||||||
|
5
|
||||||
|
# 102 f
|
||||||
|
5
|
||||||
|
# 103 g
|
||||||
|
5
|
||||||
|
# 104 h
|
||||||
|
5
|
||||||
|
# 105 i
|
||||||
|
4
|
||||||
|
# 106 j
|
||||||
|
5
|
||||||
|
# 107 k
|
||||||
|
5
|
||||||
|
# 108 l
|
||||||
|
5
|
||||||
|
# 109 m
|
||||||
|
6
|
||||||
|
# 110 n
|
||||||
|
5
|
||||||
|
# 111 o
|
||||||
|
5
|
||||||
|
# 112 p
|
||||||
|
5
|
||||||
|
# 113 q
|
||||||
|
5
|
||||||
|
# 114 r
|
||||||
|
5
|
||||||
|
# 115 s
|
||||||
|
5
|
||||||
|
# 116 t
|
||||||
|
4
|
||||||
|
# 117 u
|
||||||
|
5
|
||||||
|
# 118 v
|
||||||
|
5
|
||||||
|
# 119 w
|
||||||
|
6
|
||||||
|
# 120 x
|
||||||
|
4
|
||||||
|
# 121 y
|
||||||
|
4
|
||||||
|
# 122 z
|
||||||
|
5
|
||||||
|
# 123 {
|
||||||
|
3
|
||||||
|
# 124 |
|
||||||
|
2
|
||||||
|
# 125 }
|
||||||
|
3
|
||||||
|
# 126 ~
|
||||||
|
3
|
||||||
BIN
data/font/gauntlet.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
194
data/font/gauntlet.txt
Normal 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
|
After Width: | Height: | Size: 902 B |
194
data/font/subatomic.txt
Normal 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
|
||||||
BIN
data/notifications/notify.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=stand
|
name=stand
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=8
|
frame_width=8
|
||||||
frameHeight=16
|
frame_height=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=stand
|
name=stand
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
frameWidth=19
|
frame_width=19
|
||||||
frameHeight=18
|
frame_height=18
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
|
|||||||
234
data/shaders/crtpi_192.glsl
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
/*
|
||||||
|
crt-pi - A Raspberry Pi friendly CRT shader.
|
||||||
|
|
||||||
|
Copyright (C) 2015-2016 davej
|
||||||
|
|
||||||
|
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 2 of the License, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
This shader is designed to work well on Raspberry Pi GPUs (i.e. 1080P @ 60Hz on a game with a 4:3 aspect ratio). It pushes the Pi's GPU hard and enabling some features will slow it down so that it is no longer able to match 1080P @ 60Hz. You will need to overclock your Pi to the fastest setting in raspi-config to get the best results from this shader: 'Pi2' for Pi2 and 'Turbo' for original Pi and Pi Zero. Note: Pi2s are slower at running the shader than other Pis, this seems to be down to Pi2s lower maximum memory speed. Pi2s don't quite manage 1080P @ 60Hz - they drop about 1 in 1000 frames. You probably won't notice this, but if you do, try enabling FAKE_GAMMA.
|
||||||
|
|
||||||
|
SCANLINES enables scanlines. You'll almost certainly want to use it with MULTISAMPLE to reduce moire effects. SCANLINE_WEIGHT defines how wide scanlines are (it is an inverse value so a higher number = thinner lines). SCANLINE_GAP_BRIGHTNESS defines how dark the gaps between the scan lines are. Darker gaps between scan lines make moire effects more likely.
|
||||||
|
|
||||||
|
GAMMA enables gamma correction using the values in INPUT_GAMMA and OUTPUT_GAMMA. FAKE_GAMMA causes it to ignore the values in INPUT_GAMMA and OUTPUT_GAMMA and approximate gamma correction in a way which is faster than true gamma whilst still looking better than having none. You must have GAMMA defined to enable FAKE_GAMMA.
|
||||||
|
|
||||||
|
CURVATURE distorts the screen by CURVATURE_X and CURVATURE_Y. Curvature slows things down a lot.
|
||||||
|
|
||||||
|
By default the shader uses linear blending horizontally. If you find this too blury, enable SHARPER.
|
||||||
|
|
||||||
|
BLOOM_FACTOR controls the increase in width for bright scanlines.
|
||||||
|
|
||||||
|
MASK_TYPE defines what, if any, shadow mask to use. MASK_BRIGHTNESS defines how much the mask type darkens the screen.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma parameter CURVATURE_X "Screen curvature - horizontal" 0.10 0.0 1.0 0.01
|
||||||
|
#pragma parameter CURVATURE_Y "Screen curvature - vertical" 0.15 0.0 1.0 0.01
|
||||||
|
#pragma parameter MASK_BRIGHTNESS "Mask brightness" 0.70 0.0 1.0 0.01
|
||||||
|
#pragma parameter SCANLINE_WEIGHT "Scanline weight" 6.0 0.0 15.0 0.1
|
||||||
|
#pragma parameter SCANLINE_GAP_BRIGHTNESS "Scanline gap brightness" 0.12 0.0 1.0 0.01
|
||||||
|
#pragma parameter BLOOM_FACTOR "Bloom factor" 1.5 0.0 5.0 0.01
|
||||||
|
#pragma parameter INPUT_GAMMA "Input gamma" 2.4 0.0 5.0 0.01
|
||||||
|
#pragma parameter OUTPUT_GAMMA "Output gamma" 2.2 0.0 5.0 0.01
|
||||||
|
|
||||||
|
// Haven't put these as parameters as it would slow the code down.
|
||||||
|
#define SCANLINES
|
||||||
|
#define MULTISAMPLE
|
||||||
|
#define GAMMA
|
||||||
|
//#define FAKE_GAMMA
|
||||||
|
//#define CURVATURE
|
||||||
|
//#define SHARPER
|
||||||
|
// MASK_TYPE: 0 = none, 1 = green/magenta, 2 = trinitron(ish)
|
||||||
|
#define MASK_TYPE 2
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
#define COMPAT_PRECISION mediump
|
||||||
|
precision mediump float;
|
||||||
|
#else
|
||||||
|
#define COMPAT_PRECISION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PARAMETER_UNIFORM
|
||||||
|
uniform COMPAT_PRECISION float CURVATURE_X;
|
||||||
|
uniform COMPAT_PRECISION float CURVATURE_Y;
|
||||||
|
uniform COMPAT_PRECISION float MASK_BRIGHTNESS;
|
||||||
|
uniform COMPAT_PRECISION float SCANLINE_WEIGHT;
|
||||||
|
uniform COMPAT_PRECISION float SCANLINE_GAP_BRIGHTNESS;
|
||||||
|
uniform COMPAT_PRECISION float BLOOM_FACTOR;
|
||||||
|
uniform COMPAT_PRECISION float INPUT_GAMMA;
|
||||||
|
uniform COMPAT_PRECISION float OUTPUT_GAMMA;
|
||||||
|
#else
|
||||||
|
#define CURVATURE_X 0.05
|
||||||
|
#define CURVATURE_Y 0.1
|
||||||
|
#define MASK_BRIGHTNESS 0.80
|
||||||
|
#define SCANLINE_WEIGHT 6.0
|
||||||
|
#define SCANLINE_GAP_BRIGHTNESS 0.12
|
||||||
|
#define BLOOM_FACTOR 3.5
|
||||||
|
#define INPUT_GAMMA 2.4
|
||||||
|
#define OUTPUT_GAMMA 2.2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* COMPATIBILITY
|
||||||
|
- GLSL compilers
|
||||||
|
*/
|
||||||
|
|
||||||
|
//uniform vec2 TextureSize;
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
varying vec2 screenScale;
|
||||||
|
#endif
|
||||||
|
varying vec2 TEX0;
|
||||||
|
varying float filterWidth;
|
||||||
|
|
||||||
|
#if defined(VERTEX)
|
||||||
|
//uniform mat4 MVPMatrix;
|
||||||
|
//attribute vec4 VertexCoord;
|
||||||
|
//attribute vec2 TexCoord;
|
||||||
|
//uniform vec2 InputSize;
|
||||||
|
//uniform vec2 OutputSize;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
screenScale = vec2(1.0, 1.0); //TextureSize / InputSize;
|
||||||
|
#endif
|
||||||
|
filterWidth = (768.0 / 192.0) / 3.0;
|
||||||
|
TEX0 = vec2(gl_MultiTexCoord0.x, 1.0-gl_MultiTexCoord0.y)*1.0001;
|
||||||
|
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||||
|
}
|
||||||
|
#elif defined(FRAGMENT)
|
||||||
|
|
||||||
|
uniform sampler2D Texture;
|
||||||
|
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
vec2 Distort(vec2 coord)
|
||||||
|
{
|
||||||
|
vec2 CURVATURE_DISTORTION = vec2(CURVATURE_X, CURVATURE_Y);
|
||||||
|
// Barrel distortion shrinks the display area a bit, this will allow us to counteract that.
|
||||||
|
vec2 barrelScale = 1.0 - (0.23 * CURVATURE_DISTORTION);
|
||||||
|
coord *= screenScale;
|
||||||
|
coord -= vec2(0.5);
|
||||||
|
float rsq = coord.x * coord.x + coord.y * coord.y;
|
||||||
|
coord += coord * (CURVATURE_DISTORTION * rsq);
|
||||||
|
coord *= barrelScale;
|
||||||
|
if (abs(coord.x) >= 0.5 || abs(coord.y) >= 0.5)
|
||||||
|
coord = vec2(-1.0); // If out of bounds, return an invalid value.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
coord += vec2(0.5);
|
||||||
|
coord /= screenScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
return coord;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float CalcScanLineWeight(float dist)
|
||||||
|
{
|
||||||
|
return max(1.0-dist*dist*SCANLINE_WEIGHT, SCANLINE_GAP_BRIGHTNESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
float CalcScanLine(float dy)
|
||||||
|
{
|
||||||
|
float scanLineWeight = CalcScanLineWeight(dy);
|
||||||
|
#if defined(MULTISAMPLE)
|
||||||
|
scanLineWeight += CalcScanLineWeight(dy-filterWidth);
|
||||||
|
scanLineWeight += CalcScanLineWeight(dy+filterWidth);
|
||||||
|
scanLineWeight *= 0.3333333;
|
||||||
|
#endif
|
||||||
|
return scanLineWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec2 TextureSize = vec2(256.0, 192.0);
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
vec2 texcoord = Distort(TEX0);
|
||||||
|
if (texcoord.x < 0.0)
|
||||||
|
gl_FragColor = vec4(0.0);
|
||||||
|
else
|
||||||
|
#else
|
||||||
|
vec2 texcoord = TEX0;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
vec2 texcoordInPixels = texcoord * TextureSize;
|
||||||
|
#if defined(SHARPER)
|
||||||
|
vec2 tempCoord = floor(texcoordInPixels) + 0.5;
|
||||||
|
vec2 coord = tempCoord / TextureSize;
|
||||||
|
vec2 deltas = texcoordInPixels - tempCoord;
|
||||||
|
float scanLineWeight = CalcScanLine(deltas.y);
|
||||||
|
vec2 signs = sign(deltas);
|
||||||
|
deltas.x *= 2.0;
|
||||||
|
deltas = deltas * deltas;
|
||||||
|
deltas.y = deltas.y * deltas.y;
|
||||||
|
deltas.x *= 0.5;
|
||||||
|
deltas.y *= 8.0;
|
||||||
|
deltas /= TextureSize;
|
||||||
|
deltas *= signs;
|
||||||
|
vec2 tc = coord + deltas;
|
||||||
|
#else
|
||||||
|
float tempY = floor(texcoordInPixels.y) + 0.5;
|
||||||
|
float yCoord = tempY / TextureSize.y;
|
||||||
|
float dy = texcoordInPixels.y - tempY;
|
||||||
|
float scanLineWeight = CalcScanLine(dy);
|
||||||
|
float signY = sign(dy);
|
||||||
|
dy = dy * dy;
|
||||||
|
dy = dy * dy;
|
||||||
|
dy *= 8.0;
|
||||||
|
dy /= TextureSize.y;
|
||||||
|
dy *= signY;
|
||||||
|
vec2 tc = vec2(texcoord.x, yCoord + dy);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
vec3 colour = texture2D(Texture, tc).rgb;
|
||||||
|
|
||||||
|
#if defined(SCANLINES)
|
||||||
|
#if defined(GAMMA)
|
||||||
|
#if defined(FAKE_GAMMA)
|
||||||
|
colour = colour * colour;
|
||||||
|
#else
|
||||||
|
colour = pow(colour, vec3(INPUT_GAMMA));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
scanLineWeight *= BLOOM_FACTOR;
|
||||||
|
colour *= scanLineWeight;
|
||||||
|
|
||||||
|
#if defined(GAMMA)
|
||||||
|
#if defined(FAKE_GAMMA)
|
||||||
|
colour = sqrt(colour);
|
||||||
|
#else
|
||||||
|
colour = pow(colour, vec3(1.0/OUTPUT_GAMMA));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if MASK_TYPE == 0
|
||||||
|
gl_FragColor = vec4(colour, 1.0);
|
||||||
|
#else
|
||||||
|
#if MASK_TYPE == 1
|
||||||
|
float whichMask = fract((gl_FragCoord.x*1.0001) * 0.5);
|
||||||
|
vec3 mask;
|
||||||
|
if (whichMask < 0.5)
|
||||||
|
mask = vec3(MASK_BRIGHTNESS, 1.0, MASK_BRIGHTNESS);
|
||||||
|
else
|
||||||
|
mask = vec3(1.0, MASK_BRIGHTNESS, 1.0);
|
||||||
|
#elif MASK_TYPE == 2
|
||||||
|
float whichMask = fract((gl_FragCoord.x*1.0001) * 0.3333333);
|
||||||
|
vec3 mask = vec3(MASK_BRIGHTNESS, MASK_BRIGHTNESS, MASK_BRIGHTNESS);
|
||||||
|
if (whichMask < 0.3333333)
|
||||||
|
mask.x = 1.0;
|
||||||
|
else if (whichMask < 0.6666666)
|
||||||
|
mask.y = 1.0;
|
||||||
|
else
|
||||||
|
mask.z = 1.0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gl_FragColor = vec4(colour * mask, 1.0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
234
data/shaders/crtpi_240.glsl
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
/*
|
||||||
|
crt-pi - A Raspberry Pi friendly CRT shader.
|
||||||
|
|
||||||
|
Copyright (C) 2015-2016 davej
|
||||||
|
|
||||||
|
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 2 of the License, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
This shader is designed to work well on Raspberry Pi GPUs (i.e. 1080P @ 60Hz on a game with a 4:3 aspect ratio). It pushes the Pi's GPU hard and enabling some features will slow it down so that it is no longer able to match 1080P @ 60Hz. You will need to overclock your Pi to the fastest setting in raspi-config to get the best results from this shader: 'Pi2' for Pi2 and 'Turbo' for original Pi and Pi Zero. Note: Pi2s are slower at running the shader than other Pis, this seems to be down to Pi2s lower maximum memory speed. Pi2s don't quite manage 1080P @ 60Hz - they drop about 1 in 1000 frames. You probably won't notice this, but if you do, try enabling FAKE_GAMMA.
|
||||||
|
|
||||||
|
SCANLINES enables scanlines. You'll almost certainly want to use it with MULTISAMPLE to reduce moire effects. SCANLINE_WEIGHT defines how wide scanlines are (it is an inverse value so a higher number = thinner lines). SCANLINE_GAP_BRIGHTNESS defines how dark the gaps between the scan lines are. Darker gaps between scan lines make moire effects more likely.
|
||||||
|
|
||||||
|
GAMMA enables gamma correction using the values in INPUT_GAMMA and OUTPUT_GAMMA. FAKE_GAMMA causes it to ignore the values in INPUT_GAMMA and OUTPUT_GAMMA and approximate gamma correction in a way which is faster than true gamma whilst still looking better than having none. You must have GAMMA defined to enable FAKE_GAMMA.
|
||||||
|
|
||||||
|
CURVATURE distorts the screen by CURVATURE_X and CURVATURE_Y. Curvature slows things down a lot.
|
||||||
|
|
||||||
|
By default the shader uses linear blending horizontally. If you find this too blury, enable SHARPER.
|
||||||
|
|
||||||
|
BLOOM_FACTOR controls the increase in width for bright scanlines.
|
||||||
|
|
||||||
|
MASK_TYPE defines what, if any, shadow mask to use. MASK_BRIGHTNESS defines how much the mask type darkens the screen.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma parameter CURVATURE_X "Screen curvature - horizontal" 0.10 0.0 1.0 0.01
|
||||||
|
#pragma parameter CURVATURE_Y "Screen curvature - vertical" 0.15 0.0 1.0 0.01
|
||||||
|
#pragma parameter MASK_BRIGHTNESS "Mask brightness" 0.70 0.0 1.0 0.01
|
||||||
|
#pragma parameter SCANLINE_WEIGHT "Scanline weight" 6.0 0.0 15.0 0.1
|
||||||
|
#pragma parameter SCANLINE_GAP_BRIGHTNESS "Scanline gap brightness" 0.12 0.0 1.0 0.01
|
||||||
|
#pragma parameter BLOOM_FACTOR "Bloom factor" 1.5 0.0 5.0 0.01
|
||||||
|
#pragma parameter INPUT_GAMMA "Input gamma" 2.4 0.0 5.0 0.01
|
||||||
|
#pragma parameter OUTPUT_GAMMA "Output gamma" 2.2 0.0 5.0 0.01
|
||||||
|
|
||||||
|
// Haven't put these as parameters as it would slow the code down.
|
||||||
|
#define SCANLINES
|
||||||
|
#define MULTISAMPLE
|
||||||
|
#define GAMMA
|
||||||
|
//#define FAKE_GAMMA
|
||||||
|
//#define CURVATURE
|
||||||
|
//#define SHARPER
|
||||||
|
// MASK_TYPE: 0 = none, 1 = green/magenta, 2 = trinitron(ish)
|
||||||
|
#define MASK_TYPE 2
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
#define COMPAT_PRECISION mediump
|
||||||
|
precision mediump float;
|
||||||
|
#else
|
||||||
|
#define COMPAT_PRECISION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PARAMETER_UNIFORM
|
||||||
|
uniform COMPAT_PRECISION float CURVATURE_X;
|
||||||
|
uniform COMPAT_PRECISION float CURVATURE_Y;
|
||||||
|
uniform COMPAT_PRECISION float MASK_BRIGHTNESS;
|
||||||
|
uniform COMPAT_PRECISION float SCANLINE_WEIGHT;
|
||||||
|
uniform COMPAT_PRECISION float SCANLINE_GAP_BRIGHTNESS;
|
||||||
|
uniform COMPAT_PRECISION float BLOOM_FACTOR;
|
||||||
|
uniform COMPAT_PRECISION float INPUT_GAMMA;
|
||||||
|
uniform COMPAT_PRECISION float OUTPUT_GAMMA;
|
||||||
|
#else
|
||||||
|
#define CURVATURE_X 0.05
|
||||||
|
#define CURVATURE_Y 0.1
|
||||||
|
#define MASK_BRIGHTNESS 0.80
|
||||||
|
#define SCANLINE_WEIGHT 6.0
|
||||||
|
#define SCANLINE_GAP_BRIGHTNESS 0.12
|
||||||
|
#define BLOOM_FACTOR 3.5
|
||||||
|
#define INPUT_GAMMA 2.4
|
||||||
|
#define OUTPUT_GAMMA 2.2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* COMPATIBILITY
|
||||||
|
- GLSL compilers
|
||||||
|
*/
|
||||||
|
|
||||||
|
//uniform vec2 TextureSize;
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
varying vec2 screenScale;
|
||||||
|
#endif
|
||||||
|
varying vec2 TEX0;
|
||||||
|
varying float filterWidth;
|
||||||
|
|
||||||
|
#if defined(VERTEX)
|
||||||
|
//uniform mat4 MVPMatrix;
|
||||||
|
//attribute vec4 VertexCoord;
|
||||||
|
//attribute vec2 TexCoord;
|
||||||
|
//uniform vec2 InputSize;
|
||||||
|
//uniform vec2 OutputSize;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
screenScale = vec2(1.0, 1.0); //TextureSize / InputSize;
|
||||||
|
#endif
|
||||||
|
filterWidth = (768.0 / 240.0) / 3.0;
|
||||||
|
TEX0 = vec2(gl_MultiTexCoord0.x, 1.0-gl_MultiTexCoord0.y)*1.0001;
|
||||||
|
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||||
|
}
|
||||||
|
#elif defined(FRAGMENT)
|
||||||
|
|
||||||
|
uniform sampler2D Texture;
|
||||||
|
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
vec2 Distort(vec2 coord)
|
||||||
|
{
|
||||||
|
vec2 CURVATURE_DISTORTION = vec2(CURVATURE_X, CURVATURE_Y);
|
||||||
|
// Barrel distortion shrinks the display area a bit, this will allow us to counteract that.
|
||||||
|
vec2 barrelScale = 1.0 - (0.23 * CURVATURE_DISTORTION);
|
||||||
|
coord *= screenScale;
|
||||||
|
coord -= vec2(0.5);
|
||||||
|
float rsq = coord.x * coord.x + coord.y * coord.y;
|
||||||
|
coord += coord * (CURVATURE_DISTORTION * rsq);
|
||||||
|
coord *= barrelScale;
|
||||||
|
if (abs(coord.x) >= 0.5 || abs(coord.y) >= 0.5)
|
||||||
|
coord = vec2(-1.0); // If out of bounds, return an invalid value.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
coord += vec2(0.5);
|
||||||
|
coord /= screenScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
return coord;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float CalcScanLineWeight(float dist)
|
||||||
|
{
|
||||||
|
return max(1.0-dist*dist*SCANLINE_WEIGHT, SCANLINE_GAP_BRIGHTNESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
float CalcScanLine(float dy)
|
||||||
|
{
|
||||||
|
float scanLineWeight = CalcScanLineWeight(dy);
|
||||||
|
#if defined(MULTISAMPLE)
|
||||||
|
scanLineWeight += CalcScanLineWeight(dy-filterWidth);
|
||||||
|
scanLineWeight += CalcScanLineWeight(dy+filterWidth);
|
||||||
|
scanLineWeight *= 0.3333333;
|
||||||
|
#endif
|
||||||
|
return scanLineWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec2 TextureSize = vec2(320.0, 240.0);
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
vec2 texcoord = Distort(TEX0);
|
||||||
|
if (texcoord.x < 0.0)
|
||||||
|
gl_FragColor = vec4(0.0);
|
||||||
|
else
|
||||||
|
#else
|
||||||
|
vec2 texcoord = TEX0;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
vec2 texcoordInPixels = texcoord * TextureSize;
|
||||||
|
#if defined(SHARPER)
|
||||||
|
vec2 tempCoord = floor(texcoordInPixels) + 0.5;
|
||||||
|
vec2 coord = tempCoord / TextureSize;
|
||||||
|
vec2 deltas = texcoordInPixels - tempCoord;
|
||||||
|
float scanLineWeight = CalcScanLine(deltas.y);
|
||||||
|
vec2 signs = sign(deltas);
|
||||||
|
deltas.x *= 2.0;
|
||||||
|
deltas = deltas * deltas;
|
||||||
|
deltas.y = deltas.y * deltas.y;
|
||||||
|
deltas.x *= 0.5;
|
||||||
|
deltas.y *= 8.0;
|
||||||
|
deltas /= TextureSize;
|
||||||
|
deltas *= signs;
|
||||||
|
vec2 tc = coord + deltas;
|
||||||
|
#else
|
||||||
|
float tempY = floor(texcoordInPixels.y) + 0.5;
|
||||||
|
float yCoord = tempY / TextureSize.y;
|
||||||
|
float dy = texcoordInPixels.y - tempY;
|
||||||
|
float scanLineWeight = CalcScanLine(dy);
|
||||||
|
float signY = sign(dy);
|
||||||
|
dy = dy * dy;
|
||||||
|
dy = dy * dy;
|
||||||
|
dy *= 8.0;
|
||||||
|
dy /= TextureSize.y;
|
||||||
|
dy *= signY;
|
||||||
|
vec2 tc = vec2(texcoord.x, yCoord + dy);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
vec3 colour = texture2D(Texture, tc).rgb;
|
||||||
|
|
||||||
|
#if defined(SCANLINES)
|
||||||
|
#if defined(GAMMA)
|
||||||
|
#if defined(FAKE_GAMMA)
|
||||||
|
colour = colour * colour;
|
||||||
|
#else
|
||||||
|
colour = pow(colour, vec3(INPUT_GAMMA));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
scanLineWeight *= BLOOM_FACTOR;
|
||||||
|
colour *= scanLineWeight;
|
||||||
|
|
||||||
|
#if defined(GAMMA)
|
||||||
|
#if defined(FAKE_GAMMA)
|
||||||
|
colour = sqrt(colour);
|
||||||
|
#else
|
||||||
|
colour = pow(colour, vec3(1.0/OUTPUT_GAMMA));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if MASK_TYPE == 0
|
||||||
|
gl_FragColor = vec4(colour, 1.0);
|
||||||
|
#else
|
||||||
|
#if MASK_TYPE == 1
|
||||||
|
float whichMask = fract((gl_FragCoord.x*1.0001) * 0.5);
|
||||||
|
vec3 mask;
|
||||||
|
if (whichMask < 0.5)
|
||||||
|
mask = vec3(MASK_BRIGHTNESS, 1.0, MASK_BRIGHTNESS);
|
||||||
|
else
|
||||||
|
mask = vec3(1.0, MASK_BRIGHTNESS, 1.0);
|
||||||
|
#elif MASK_TYPE == 2
|
||||||
|
float whichMask = fract((gl_FragCoord.x*1.0001) * 0.3333333);
|
||||||
|
vec3 mask = vec3(MASK_BRIGHTNESS, MASK_BRIGHTNESS, MASK_BRIGHTNESS);
|
||||||
|
if (whichMask < 0.3333333)
|
||||||
|
mask.x = 1.0;
|
||||||
|
else if (whichMask < 0.6666666)
|
||||||
|
mask.y = 1.0;
|
||||||
|
else
|
||||||
|
mask.z = 1.0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gl_FragColor = vec4(colour * mask, 1.0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
BIN
data/test.gif
Normal file
|
After Width: | Height: | Size: 630 B |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 7.1 KiB |
BIN
data/title/loading_screen_color.gif
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 8.9 KiB |
BIN
data/title/title_logo.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
@@ -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.7</string>
|
<string>1.09</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.0.7</string>
|
<string>1.09</string>
|
||||||
<key>CSResourcesFileMapped</key>
|
<key>CSResourcesFileMapped</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
269
source/animated_sprite.cpp
Normal file
@@ -0,0 +1,269 @@
|
|||||||
|
#include "animated_sprite.h"
|
||||||
|
#include <stddef.h> // Para size_t
|
||||||
|
#include <fstream> // Para basic_ostream, basic_istream, operator<<, basic...
|
||||||
|
#include <iostream> // Para cout, cerr
|
||||||
|
#include <sstream> // Para basic_stringstream
|
||||||
|
#include <stdexcept> // Para runtime_error
|
||||||
|
#include "texture.h" // Para Texture
|
||||||
|
#include "utils.h" // Para printWithDots
|
||||||
|
|
||||||
|
// Carga las animaciones en un vector(Animations) desde un fichero
|
||||||
|
Animations loadAnimationsFromFile(const std::string &file_path)
|
||||||
|
{
|
||||||
|
std::ifstream file(file_path);
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
std::cerr << "Error: Fichero no encontrado " << file_path << std::endl;
|
||||||
|
throw std::runtime_error("Fichero no encontrado: " + file_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
printWithDots("Animation : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]");
|
||||||
|
|
||||||
|
std::vector<std::string> buffer;
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(file, line))
|
||||||
|
{
|
||||||
|
if (!line.empty())
|
||||||
|
buffer.push_back(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
AnimatedSprite::AnimatedSprite(std::shared_ptr<Texture> texture, const std::string &file_path)
|
||||||
|
: MovingSprite(texture)
|
||||||
|
{
|
||||||
|
// Carga las animaciones
|
||||||
|
if (!file_path.empty())
|
||||||
|
{
|
||||||
|
Animations v = loadAnimationsFromFile(file_path);
|
||||||
|
setAnimations(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
AnimatedSprite::AnimatedSprite(std::shared_ptr<Texture> texture, const Animations &animations)
|
||||||
|
: MovingSprite(texture)
|
||||||
|
{
|
||||||
|
if (!animations.empty())
|
||||||
|
{
|
||||||
|
setAnimations(animations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtiene el indice de la animación a partir del nombre
|
||||||
|
int AnimatedSprite::getIndex(const std::string &name)
|
||||||
|
{
|
||||||
|
auto index = -1;
|
||||||
|
|
||||||
|
for (const auto &a : animations_)
|
||||||
|
{
|
||||||
|
index++;
|
||||||
|
if (a.name == name)
|
||||||
|
{
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << "** Warning: could not find \"" << name.c_str() << "\" animation" << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calcula el frame correspondiente a la animación
|
||||||
|
void AnimatedSprite::animate()
|
||||||
|
{
|
||||||
|
if (animations_[current_animation_].speed == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calcula el frame actual a partir del contador
|
||||||
|
animations_[current_animation_].current_frame = animations_[current_animation_].counter / animations_[current_animation_].speed;
|
||||||
|
|
||||||
|
// Si alcanza el final de la animación, reinicia el contador de la animación
|
||||||
|
// en función de la variable loop y coloca el nuevo frame
|
||||||
|
if (animations_[current_animation_].current_frame >= static_cast<int>(animations_[current_animation_].frames.size()))
|
||||||
|
{
|
||||||
|
if (animations_[current_animation_].loop == -1)
|
||||||
|
{ // Si no hay loop, deja el último frame
|
||||||
|
animations_[current_animation_].current_frame = animations_[current_animation_].frames.size();
|
||||||
|
animations_[current_animation_].completed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Si hay loop, vuelve al frame indicado
|
||||||
|
animations_[current_animation_].counter = 0;
|
||||||
|
animations_[current_animation_].current_frame = animations_[current_animation_].loop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// En caso contrario
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Escoge el frame correspondiente de la animación
|
||||||
|
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
||||||
|
|
||||||
|
// Incrementa el contador de la animacion
|
||||||
|
animations_[current_animation_].counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba si ha terminado la animación
|
||||||
|
bool AnimatedSprite::animationIsCompleted()
|
||||||
|
{
|
||||||
|
return animations_[current_animation_].completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece la animacion actual
|
||||||
|
void AnimatedSprite::setCurrentAnimation(const std::string &name)
|
||||||
|
{
|
||||||
|
const auto new_animation = getIndex(name);
|
||||||
|
if (current_animation_ != new_animation)
|
||||||
|
{
|
||||||
|
current_animation_ = new_animation;
|
||||||
|
animations_[current_animation_].current_frame = 0;
|
||||||
|
animations_[current_animation_].counter = 0;
|
||||||
|
animations_[current_animation_].completed = false;
|
||||||
|
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece la animacion actual
|
||||||
|
void AnimatedSprite::setCurrentAnimation(int index)
|
||||||
|
{
|
||||||
|
const auto new_animation = index;
|
||||||
|
if (current_animation_ != new_animation)
|
||||||
|
{
|
||||||
|
current_animation_ = new_animation;
|
||||||
|
animations_[current_animation_].current_frame = 0;
|
||||||
|
animations_[current_animation_].counter = 0;
|
||||||
|
animations_[current_animation_].completed = false;
|
||||||
|
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza las variables del objeto
|
||||||
|
void AnimatedSprite::update()
|
||||||
|
{
|
||||||
|
animate();
|
||||||
|
MovingSprite::update();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reinicia la animación
|
||||||
|
void AnimatedSprite::resetAnimation()
|
||||||
|
{
|
||||||
|
animations_[current_animation_].current_frame = 0;
|
||||||
|
animations_[current_animation_].counter = 0;
|
||||||
|
animations_[current_animation_].completed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carga la animación desde un vector de cadenas
|
||||||
|
void AnimatedSprite::setAnimations(const Animations &animations)
|
||||||
|
{
|
||||||
|
int frame_width = 1;
|
||||||
|
int frame_height = 1;
|
||||||
|
int frames_per_row = 1;
|
||||||
|
int max_tiles = 1;
|
||||||
|
|
||||||
|
size_t index = 0;
|
||||||
|
while (index < animations.size())
|
||||||
|
{
|
||||||
|
std::string line = animations.at(index);
|
||||||
|
|
||||||
|
// Parsea el fichero para buscar variables y valores
|
||||||
|
if (line != "[animation]")
|
||||||
|
{
|
||||||
|
// Encuentra la posición del caracter '='
|
||||||
|
size_t pos = line.find("=");
|
||||||
|
|
||||||
|
// Procesa las dos subcadenas
|
||||||
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
|
std::string key = line.substr(0, pos);
|
||||||
|
int value = std::stoi(line.substr(pos + 1));
|
||||||
|
if (key == "frame_width")
|
||||||
|
frame_width = value;
|
||||||
|
else if (key == "frame_height")
|
||||||
|
frame_height = value;
|
||||||
|
else
|
||||||
|
std::cout << "Warning: unknown parameter " << key << std::endl;
|
||||||
|
|
||||||
|
frames_per_row = texture_->getWidth() / frame_width;
|
||||||
|
const int w = texture_->getWidth() / frame_width;
|
||||||
|
const int h = texture_->getHeight() / frame_height;
|
||||||
|
max_tiles = w * h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si la linea contiene el texto [animation] se realiza el proceso de carga de una animación
|
||||||
|
if (line == "[animation]")
|
||||||
|
{
|
||||||
|
AnimationData animation;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
index++;
|
||||||
|
line = animations.at(index);
|
||||||
|
size_t pos = line.find("=");
|
||||||
|
|
||||||
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
|
std::string key = line.substr(0, pos);
|
||||||
|
std::string value = line.substr(pos + 1);
|
||||||
|
|
||||||
|
if (key == "name")
|
||||||
|
animation.name = value;
|
||||||
|
else if (key == "speed")
|
||||||
|
animation.speed = std::stoi(value);
|
||||||
|
else if (key == "loop")
|
||||||
|
animation.loop = std::stoi(value);
|
||||||
|
else if (key == "frames")
|
||||||
|
{
|
||||||
|
// Se introducen los valores separados por comas en un vector
|
||||||
|
std::stringstream ss(value);
|
||||||
|
std::string tmp;
|
||||||
|
SDL_Rect rect = {0, 0, frame_width, frame_height};
|
||||||
|
while (getline(ss, tmp, ','))
|
||||||
|
{
|
||||||
|
// Comprueba que el tile no sea mayor que el maximo indice permitido
|
||||||
|
const int num_tile = std::stoi(tmp);
|
||||||
|
if (num_tile <= max_tiles)
|
||||||
|
{
|
||||||
|
rect.x = (num_tile % frames_per_row) * frame_width;
|
||||||
|
rect.y = (num_tile / frames_per_row) * frame_height;
|
||||||
|
animation.frames.emplace_back(rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
std::cout << "Warning: unknown parameter " << key << std::endl;
|
||||||
|
}
|
||||||
|
} while (line != "[/animation]");
|
||||||
|
|
||||||
|
// Añade la animación al vector de animaciones
|
||||||
|
animations_.emplace_back(animation);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Una vez procesada la linea, aumenta el indice para pasar a la siguiente
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pone un valor por defecto
|
||||||
|
setWidth(frame_width);
|
||||||
|
setHeight(frame_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece el frame actual de la animación
|
||||||
|
void AnimatedSprite::setCurrentAnimationFrame(int num)
|
||||||
|
{
|
||||||
|
// Descarta valores fuera de rango
|
||||||
|
if (num < 0 || num >= static_cast<int>(animations_[current_animation_].frames.size()))
|
||||||
|
{
|
||||||
|
num = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cambia el valor de la variable
|
||||||
|
animations_[current_animation_].current_frame = num;
|
||||||
|
animations_[current_animation_].counter = 0;
|
||||||
|
|
||||||
|
// Escoge el frame correspondiente de la animación
|
||||||
|
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
||||||
|
}
|
||||||
72
source/animated_sprite.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL2/SDL_rect.h> // Para SDL_Rect
|
||||||
|
#include <memory> // Para shared_ptr
|
||||||
|
#include <string> // Para string
|
||||||
|
#include <vector> // Para vector
|
||||||
|
#include "moving_sprite.h" // Para MovingSprite
|
||||||
|
class Texture; // lines 9-9
|
||||||
|
|
||||||
|
struct AnimationData
|
||||||
|
{
|
||||||
|
std::string name; // Nombre de la animacion
|
||||||
|
std::vector<SDL_Rect> frames; // Cada uno de los frames que componen la animación
|
||||||
|
int speed; // Velocidad de la animación
|
||||||
|
int loop; // Indica a que frame vuelve la animación al terminar. -1 para que no vuelva
|
||||||
|
bool completed; // Indica si ha finalizado la animación
|
||||||
|
int current_frame; // Frame actual
|
||||||
|
int counter; // Contador para las animaciones
|
||||||
|
|
||||||
|
AnimationData() : name(std::string()), speed(5), loop(0), completed(false), current_frame(0), counter(0) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
using Animations = std::vector<std::string>;
|
||||||
|
|
||||||
|
// Carga las animaciones en un vector(Animations) desde un fichero
|
||||||
|
Animations loadAnimationsFromFile(const std::string &file_path);
|
||||||
|
|
||||||
|
class AnimatedSprite : public MovingSprite
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
// Variables
|
||||||
|
std::vector<AnimationData> animations_; // Vector con las diferentes animaciones
|
||||||
|
int current_animation_ = 0; // Animacion activa
|
||||||
|
|
||||||
|
// Calcula el frame correspondiente a la animación actual
|
||||||
|
void animate();
|
||||||
|
|
||||||
|
// Carga la animación desde un vector de cadenas
|
||||||
|
void setAnimations(const Animations &animations);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
AnimatedSprite(std::shared_ptr<Texture> texture, const std::string &file_path);
|
||||||
|
AnimatedSprite(std::shared_ptr<Texture> texture, const Animations &animations);
|
||||||
|
explicit AnimatedSprite(std::shared_ptr<Texture> texture)
|
||||||
|
: MovingSprite(texture) {}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
virtual ~AnimatedSprite() = default;
|
||||||
|
|
||||||
|
// Actualiza las variables del objeto
|
||||||
|
void update() override;
|
||||||
|
|
||||||
|
// Comprueba si ha terminado la animación
|
||||||
|
bool animationIsCompleted();
|
||||||
|
|
||||||
|
// Obtiene el indice de la animación a partir del nombre
|
||||||
|
int getIndex(const std::string &name);
|
||||||
|
|
||||||
|
// Establece la animacion actual
|
||||||
|
void setCurrentAnimation(const std::string &name = "default");
|
||||||
|
void setCurrentAnimation(int index = 0);
|
||||||
|
|
||||||
|
// Reinicia la animación
|
||||||
|
void resetAnimation();
|
||||||
|
|
||||||
|
// Establece el frame actual de la animación
|
||||||
|
void setCurrentAnimationFrame(int num);
|
||||||
|
|
||||||
|
// Obtiene el numero de frames de la animación actual
|
||||||
|
int getCurrentAnimationSize() { return static_cast<int>(animations_[current_animation_].frames.size()); }
|
||||||
|
};
|
||||||
173
source/asset.cpp
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
#include "asset.h"
|
||||||
|
#include <algorithm> // Para find_if, max
|
||||||
|
#include <fstream> // Para basic_ostream, operator<<, basic_ifstream, endl
|
||||||
|
#include <iostream> // Para cout
|
||||||
|
#include <string> // Para allocator, char_traits, string, operator+, oper...
|
||||||
|
#include "utils.h" // Para getFileName, printWithDots
|
||||||
|
|
||||||
|
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||||
|
Asset *Asset::asset_ = nullptr;
|
||||||
|
|
||||||
|
// [SINGLETON] Crearemos el objeto asset con esta función estática
|
||||||
|
void Asset::init(const std::string &executable_path)
|
||||||
|
{
|
||||||
|
Asset::asset_ = new Asset(executable_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// [SINGLETON] Destruiremos el objeto asset con esta función estática
|
||||||
|
void Asset::destroy()
|
||||||
|
{
|
||||||
|
delete Asset::asset_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// [SINGLETON] Con este método obtenemos el objeto asset y podemos trabajar con él
|
||||||
|
Asset *Asset::get()
|
||||||
|
{
|
||||||
|
return Asset::asset_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añade un elemento a la lista
|
||||||
|
void Asset::add(const std::string &file, AssetType type, bool required, bool absolute)
|
||||||
|
{
|
||||||
|
file_list_.emplace_back(absolute ? file : executable_path_ + file, type, required);
|
||||||
|
longest_name_ = std::max(longest_name_, static_cast<int>(file_list_.back().file.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Devuelve la ruta completa a un fichero a partir de una cadena
|
||||||
|
std::string Asset::get(const std::string &text) const
|
||||||
|
{
|
||||||
|
auto it = std::find_if(file_list_.begin(), file_list_.end(),
|
||||||
|
[&text](const auto &f)
|
||||||
|
{
|
||||||
|
return getFileName(f.file) == text;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (it != file_list_.end())
|
||||||
|
{
|
||||||
|
return it->file;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "Warning: file " << text << " not found" << std::endl;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba que existen todos los elementos
|
||||||
|
bool Asset::check() const
|
||||||
|
{
|
||||||
|
bool success = true;
|
||||||
|
|
||||||
|
std::cout << "\n** CHECKING FILES" << std::endl;
|
||||||
|
|
||||||
|
// std::cout << "Executable path is: " << executable_path_ << std::endl;
|
||||||
|
// std::cout << "Sample filepath: " << file_list_.back().file << std::endl;
|
||||||
|
|
||||||
|
// Comprueba la lista de ficheros clasificandolos por tipo
|
||||||
|
for (int type = 0; type < static_cast<int>(AssetType::MAX_ASSET_TYPE); ++type)
|
||||||
|
{
|
||||||
|
// Comprueba si hay ficheros de ese tipo
|
||||||
|
bool any = false;
|
||||||
|
|
||||||
|
for (const auto &f : file_list_)
|
||||||
|
{
|
||||||
|
if (f.required && f.type == static_cast<AssetType>(type))
|
||||||
|
{
|
||||||
|
any = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si hay ficheros de ese tipo, comprueba si existen
|
||||||
|
if (any)
|
||||||
|
{
|
||||||
|
std::cout << "\n>> " << getTypeName(static_cast<AssetType>(type)).c_str() << " FILES" << std::endl;
|
||||||
|
|
||||||
|
for (const auto &f : file_list_)
|
||||||
|
{
|
||||||
|
if (f.required && f.type == static_cast<AssetType>(type))
|
||||||
|
{
|
||||||
|
success &= checkFile(f.file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (success)
|
||||||
|
std::cout << " All files are OK." << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resultado
|
||||||
|
std::cout << (success ? "\n** CHECKING FILES COMPLETED.\n" : "\n** CHECKING FILES FAILED.\n") << std::endl;
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba que existe un fichero
|
||||||
|
bool Asset::checkFile(const std::string &path) const
|
||||||
|
{
|
||||||
|
std::ifstream file(path);
|
||||||
|
bool success = file.good();
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
if (!success)
|
||||||
|
printWithDots("Checking file : ", getFileName(path), "[ ERROR ]");
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Devuelve el nombre del tipo de recurso
|
||||||
|
std::string Asset::getTypeName(AssetType type) const
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case AssetType::DATA:
|
||||||
|
return "DATA";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AssetType::BITMAP:
|
||||||
|
return "BITMAP";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AssetType::ANIMATION:
|
||||||
|
return "ANIMATION";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AssetType::MUSIC:
|
||||||
|
return "MUSIC";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AssetType::SOUND:
|
||||||
|
return "SOUND";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AssetType::FONT:
|
||||||
|
return "FONT";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AssetType::ROOM:
|
||||||
|
return "ROOM";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AssetType::TILEMAP:
|
||||||
|
return "TILEMAP";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "ERROR";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Devuelve la lista de recursos de un tipo
|
||||||
|
std::vector<std::string> Asset::getListByType(AssetType type) const
|
||||||
|
{
|
||||||
|
std::vector<std::string> list;
|
||||||
|
|
||||||
|
for (auto f : file_list_)
|
||||||
|
{
|
||||||
|
if (f.type == type)
|
||||||
|
{
|
||||||
|
list.push_back(f.file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
78
source/asset.h
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string> // para string, basic_string
|
||||||
|
#include <vector> // para vector
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
enum class AssetType : int
|
||||||
|
{
|
||||||
|
DATA,
|
||||||
|
BITMAP,
|
||||||
|
ANIMATION,
|
||||||
|
MUSIC,
|
||||||
|
SOUND,
|
||||||
|
FONT,
|
||||||
|
ROOM,
|
||||||
|
TILEMAP,
|
||||||
|
MAX_ASSET_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
// Clase Asset
|
||||||
|
class Asset
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// [SINGLETON] Objeto asset privado para Don Melitón
|
||||||
|
static Asset *asset_;
|
||||||
|
|
||||||
|
// Estructura para definir un item
|
||||||
|
struct AssetItem
|
||||||
|
{
|
||||||
|
std::string file; // Ruta del fichero desde la raíz del directorio
|
||||||
|
AssetType type; // Indica el tipo de recurso
|
||||||
|
bool required; // Indica si es un fichero que debe de existir
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
AssetItem(const std::string &filePath, AssetType assetType, bool isRequired)
|
||||||
|
: file(filePath), type(assetType), required(isRequired) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
int longest_name_ = 0; // Contiene la longitud del nombre de fichero mas largo
|
||||||
|
std::vector<AssetItem> file_list_; // Listado con todas las rutas a los ficheros
|
||||||
|
std::string executable_path_; // Ruta al ejecutable
|
||||||
|
|
||||||
|
// Comprueba que existe un fichero
|
||||||
|
bool checkFile(const std::string &path) const;
|
||||||
|
|
||||||
|
// Devuelve el nombre del tipo de recurso
|
||||||
|
std::string getTypeName(AssetType type) const;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
explicit Asset(const std::string &executable_path)
|
||||||
|
: executable_path_(getPath(executable_path)) {}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~Asset() = default;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||||
|
static void init(const std::string &executable_path);
|
||||||
|
|
||||||
|
// [SINGLETON] Destruiremos el objeto con esta función estática
|
||||||
|
static void destroy();
|
||||||
|
|
||||||
|
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
||||||
|
static Asset *get();
|
||||||
|
|
||||||
|
// Añade un elemento a la lista
|
||||||
|
void add(const std::string &file, AssetType type, bool required = true, bool absolute = false);
|
||||||
|
|
||||||
|
// Devuelve la ruta completa a un fichero a partir de una cadena
|
||||||
|
std::string get(const std::string &text) const;
|
||||||
|
|
||||||
|
// Comprueba que existen todos los elementos
|
||||||
|
bool check() const;
|
||||||
|
|
||||||
|
// Devuelve la lista de recursos de un tipo
|
||||||
|
std::vector<std::string> getListByType(AssetType type) const;
|
||||||
|
};
|
||||||
@@ -1,13 +1,198 @@
|
|||||||
#include "cheevos.h"
|
#include "cheevos.h"
|
||||||
|
#include <SDL2/SDL_error.h> // for SDL_GetError
|
||||||
|
#include <SDL2/SDL_rwops.h> // for SDL_RWFromFile, SDL_RWclose, SDL_RWwrite
|
||||||
|
#include <stddef.h> // for NULL
|
||||||
|
#include <fstream> // for basic_ostream, operator<<, basic_ofstream
|
||||||
|
#include <iostream> // for cout, cerr
|
||||||
|
#include "notifier.h" // for Notifier
|
||||||
|
#include "options.h" // for Options, options
|
||||||
|
|
||||||
|
// [SINGLETON]
|
||||||
|
Cheevos *Cheevos::cheevos_ = nullptr;
|
||||||
|
|
||||||
|
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||||
|
void Cheevos::init(const std::string &file)
|
||||||
|
{
|
||||||
|
Cheevos::cheevos_ = new Cheevos(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// [SINGLETON] Destruiremos el objeto con esta función estática
|
||||||
|
void Cheevos::destroy()
|
||||||
|
{
|
||||||
|
delete Cheevos::cheevos_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
||||||
|
Cheevos *Cheevos::get()
|
||||||
|
{
|
||||||
|
return Cheevos::cheevos_;
|
||||||
|
}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Cheevos::Cheevos(options_t *options)
|
Cheevos::Cheevos(const std::string &file)
|
||||||
|
: file_(file)
|
||||||
{
|
{
|
||||||
this->options = options;
|
init();
|
||||||
|
loadFromFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
Cheevos::~Cheevos()
|
Cheevos::~Cheevos()
|
||||||
{
|
{
|
||||||
|
saveToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inicializa los logros
|
||||||
|
void Cheevos::init()
|
||||||
|
{
|
||||||
|
cheevos_list_.clear();
|
||||||
|
cheevos_list_.emplace_back(1, "SHINY THINGS", "Get 25% of the items", 2);
|
||||||
|
cheevos_list_.emplace_back(2, "HALF THE WORK", "Get 50% of the items", 2);
|
||||||
|
cheevos_list_.emplace_back(3, "GETTING THERE", "Get 75% of the items", 2);
|
||||||
|
cheevos_list_.emplace_back(4, "THE COLLECTOR", "Get 100% of the items", 2);
|
||||||
|
cheevos_list_.emplace_back(5, "WANDERING AROUND", "Visit 20 rooms", 2);
|
||||||
|
cheevos_list_.emplace_back(6, "I GOT LOST", "Visit 40 rooms", 2);
|
||||||
|
cheevos_list_.emplace_back(7, "I LIKE TO EXPLORE", "Visit all rooms", 2);
|
||||||
|
cheevos_list_.emplace_back(8, "FINISH THE GAME", "Complete the game", 2);
|
||||||
|
cheevos_list_.emplace_back(9, "I WAS SUCKED BY A HOLE", "Complete the game without entering the jail", 2);
|
||||||
|
cheevos_list_.emplace_back(10, "MY LITTLE PROJECTS", "Complete the game with all items", 2);
|
||||||
|
cheevos_list_.emplace_back(11, "I LIKE MY MULTICOLOURED FRIENDS", "Complete the game without dying", 2);
|
||||||
|
cheevos_list_.emplace_back(12, "SHIT PROJECTS DONE FAST", "Complete the game in under 30 minutes", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Busca un logro por id y devuelve el indice
|
||||||
|
int Cheevos::find(int id)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (int)cheevos_list_.size(); ++i)
|
||||||
|
{
|
||||||
|
if (cheevos_list_[i].id == id)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desbloquea un logro
|
||||||
|
void Cheevos::unlock(int id)
|
||||||
|
{
|
||||||
|
const int index = find(id);
|
||||||
|
|
||||||
|
// Si el índice es inválido, el logro no es válido, ya está completado o el sistema de logros no está habilitado, no hacemos nada
|
||||||
|
if (index == -1 || !cheevos_list_.at(index).valid || cheevos_list_.at(index).completed || !enabled_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Marcar el logro como completado
|
||||||
|
cheevos_list_.at(index).completed = true;
|
||||||
|
// Mostrar notificación en la pantalla
|
||||||
|
Notifier::get()->show({"ACHIEVEMENT UNLOCKED!", cheevos_list_.at(index).caption}, NotificationText::LEFT, cheevos_list_.at(index).icon);
|
||||||
|
// Guardar el estado de los logros
|
||||||
|
saveToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invalida un logro
|
||||||
|
void Cheevos::invalidate(int id)
|
||||||
|
{
|
||||||
|
const int index = find(id);
|
||||||
|
|
||||||
|
// Si el índice es válido, se invalida el logro
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
cheevos_list_.at(index).valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carga el estado de los logros desde un fichero
|
||||||
|
void Cheevos::loadFromFile()
|
||||||
|
{
|
||||||
|
std::ifstream file(file_, std::ios::binary);
|
||||||
|
|
||||||
|
// El fichero no existe
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
if (options.console)
|
||||||
|
{
|
||||||
|
std::cout << "Warning: Unable to open " << file_ << "! Creating new file..." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crea el fichero en modo escritura (binario)
|
||||||
|
std::ofstream newFile(file_, std::ios::binary);
|
||||||
|
|
||||||
|
if (newFile)
|
||||||
|
{
|
||||||
|
if (options.console)
|
||||||
|
{
|
||||||
|
std::cout << "New " << file_ << " created!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guarda la información
|
||||||
|
for (const auto &cheevo : cheevos_list_)
|
||||||
|
{
|
||||||
|
newFile.write(reinterpret_cast<const char *>(&cheevo.completed), sizeof(bool));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (options.console)
|
||||||
|
{
|
||||||
|
std::cerr << "Error: Unable to create " << file_ << "!" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// El fichero existe
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (options.console)
|
||||||
|
{
|
||||||
|
std::cout << "Reading " << file_ << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carga los datos
|
||||||
|
for (auto &cheevo : cheevos_list_)
|
||||||
|
{
|
||||||
|
file.read(reinterpret_cast<char *>(&cheevo.completed), sizeof(bool));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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_list_.size(); ++i)
|
||||||
|
{
|
||||||
|
SDL_RWwrite(file, &cheevos_list_[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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Devuelve el número total de logros desbloqueados
|
||||||
|
int Cheevos::unlocked()
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (auto cheevo : cheevos_list_)
|
||||||
|
{
|
||||||
|
if (cheevo.completed)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
@@ -1,27 +1,80 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include "common/utils.h"
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifndef CHEEVOS_H
|
#include <string> // for string
|
||||||
#define CHEEVOS_H
|
#include <vector> // for vector
|
||||||
|
|
||||||
|
// Struct para los logros
|
||||||
|
struct Achievement
|
||||||
|
{
|
||||||
|
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
|
||||||
|
|
||||||
|
// Constructor vacío
|
||||||
|
Achievement() : id(0), icon(0), completed(false), valid(true) {}
|
||||||
|
|
||||||
|
// Constructor parametrizado
|
||||||
|
Achievement(int id, const std::string &caption, const std::string &description, int icon, bool completed = false, bool valid = true)
|
||||||
|
: id(id), caption(caption), description(description), icon(icon), completed(completed), valid(valid) {}
|
||||||
|
};
|
||||||
|
|
||||||
class Cheevos
|
class Cheevos
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Punteros y objetos
|
// [SINGLETON] Objeto privado
|
||||||
options_t *options;
|
static Cheevos *cheevos_;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
|
std::vector<Achievement> cheevos_list_; // Listado de logros
|
||||||
|
bool enabled_ = true; // Indica si los logros se pueden obtener
|
||||||
|
std::string file_; // Fichero donde leer/almacenar el estado de los logros
|
||||||
|
|
||||||
|
// Inicializa los logros
|
||||||
|
void init();
|
||||||
|
|
||||||
|
// Busca un logro por id y devuelve el índice
|
||||||
|
int find(int id);
|
||||||
|
|
||||||
|
// Carga el estado de los logros desde un fichero
|
||||||
|
void loadFromFile();
|
||||||
|
|
||||||
|
// Guarda el estado de los logros en un fichero
|
||||||
|
void saveToFile();
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Cheevos(options_t *options);
|
Cheevos(const std::string &file);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Cheevos();
|
~Cheevos();
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
public:
|
||||||
|
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||||
|
static void init(const std::string &file);
|
||||||
|
|
||||||
|
// [SINGLETON] Destruiremos el objeto con esta función estática
|
||||||
|
static void destroy();
|
||||||
|
|
||||||
|
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
||||||
|
static Cheevos *get();
|
||||||
|
|
||||||
|
// Desbloquea un logro
|
||||||
|
void unlock(int id);
|
||||||
|
|
||||||
|
// Invalida un logro
|
||||||
|
void invalidate(int id);
|
||||||
|
|
||||||
|
// Habilita o deshabilita los logros
|
||||||
|
void enable(bool value) { enabled_ = value; }
|
||||||
|
|
||||||
|
// Lista los logros
|
||||||
|
std::vector<Achievement> list() { return cheevos_list_; }
|
||||||
|
|
||||||
|
// Devuelve el número total de logros desbloqueados
|
||||||
|
int unlocked();
|
||||||
|
|
||||||
|
// Devuelve el número total de logros
|
||||||
|
int count() { return cheevos_list_.size(); }
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,534 +0,0 @@
|
|||||||
#include "animatedsprite.h"
|
|
||||||
|
|
||||||
// Carga la animación desde un fichero
|
|
||||||
animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath, bool verbose)
|
|
||||||
{
|
|
||||||
// Inicializa variables
|
|
||||||
animatedSprite_t as;
|
|
||||||
as.texture = texture;
|
|
||||||
int framesPerRow = 0;
|
|
||||||
int frameWidth = 0;
|
|
||||||
int frameHeight = 0;
|
|
||||||
int maxTiles = 0;
|
|
||||||
|
|
||||||
const std::string filename = filePath.substr(filePath.find_last_of("\\/") + 1);
|
|
||||||
std::ifstream file(filePath);
|
|
||||||
std::string line;
|
|
||||||
|
|
||||||
// El fichero se puede abrir
|
|
||||||
if (file.good())
|
|
||||||
{
|
|
||||||
// Procesa el fichero linea a linea
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
std::cout << "Animation loaded: " << filename << std::endl;
|
|
||||||
}
|
|
||||||
while (std::getline(file, line))
|
|
||||||
{
|
|
||||||
// Si la linea contiene el texto [animation] se realiza el proceso de carga de una animación
|
|
||||||
if (line == "[animation]")
|
|
||||||
{
|
|
||||||
animation_t buffer;
|
|
||||||
buffer.counter = 0;
|
|
||||||
buffer.currentFrame = 0;
|
|
||||||
buffer.completed = false;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
std::getline(file, line);
|
|
||||||
|
|
||||||
// Encuentra la posición del caracter '='
|
|
||||||
int pos = line.find("=");
|
|
||||||
|
|
||||||
// Procesa las dos subcadenas
|
|
||||||
if (pos != (int)line.npos)
|
|
||||||
{
|
|
||||||
if (line.substr(0, pos) == "name")
|
|
||||||
{
|
|
||||||
buffer.name = line.substr(pos + 1, line.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (line.substr(0, pos) == "speed")
|
|
||||||
{
|
|
||||||
buffer.speed = std::stoi(line.substr(pos + 1, line.length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (line.substr(0, pos) == "loop")
|
|
||||||
{
|
|
||||||
buffer.loop = std::stoi(line.substr(pos + 1, line.length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (line.substr(0, pos) == "frames")
|
|
||||||
{
|
|
||||||
// Se introducen los valores separados por comas en un vector
|
|
||||||
std::stringstream ss(line.substr(pos + 1, line.length()));
|
|
||||||
std::string tmp;
|
|
||||||
SDL_Rect rect = {0, 0, frameWidth, frameHeight};
|
|
||||||
while (getline(ss, tmp, ','))
|
|
||||||
{
|
|
||||||
// Comprueba que el tile no sea mayor que el maximo indice permitido
|
|
||||||
const int numTile = std::stoi(tmp) > maxTiles ? 0 : std::stoi(tmp);
|
|
||||||
rect.x = (numTile % framesPerRow) * frameWidth;
|
|
||||||
rect.y = (numTile / framesPerRow) * frameHeight;
|
|
||||||
buffer.frames.push_back(rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (line != "[/animation]");
|
|
||||||
|
|
||||||
// Añade la animación al vector de animaciones
|
|
||||||
as.animations.push_back(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// En caso contrario se parsea el fichero para buscar las variables y los valores
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Encuentra la posición del caracter '='
|
|
||||||
int pos = line.find("=");
|
|
||||||
|
|
||||||
// Procesa las dos subcadenas
|
|
||||||
if (pos != (int)line.npos)
|
|
||||||
{
|
|
||||||
if (line.substr(0, pos) == "framesPerRow")
|
|
||||||
{
|
|
||||||
framesPerRow = std::stoi(line.substr(pos + 1, line.length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (line.substr(0, pos) == "frameWidth")
|
|
||||||
{
|
|
||||||
frameWidth = std::stoi(line.substr(pos + 1, line.length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (line.substr(0, pos) == "frameHeight")
|
|
||||||
{
|
|
||||||
frameHeight = std::stoi(line.substr(pos + 1, line.length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normaliza valores
|
|
||||||
if (framesPerRow == 0 && frameWidth > 0)
|
|
||||||
{
|
|
||||||
framesPerRow = texture->getWidth() / frameWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxTiles == 0 && frameWidth > 0 && frameHeight > 0)
|
|
||||||
{
|
|
||||||
const int w = texture->getWidth() / frameWidth;
|
|
||||||
const int h = texture->getHeight() / frameHeight;
|
|
||||||
maxTiles = w * h;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cierra el fichero
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
// El fichero no se puede abrir
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return as;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, std::string file, std::vector<std::string> *buffer)
|
|
||||||
{
|
|
||||||
// Copia los punteros
|
|
||||||
setTexture(texture);
|
|
||||||
setRenderer(renderer);
|
|
||||||
|
|
||||||
// Carga las animaciones
|
|
||||||
if (file != "")
|
|
||||||
{
|
|
||||||
animatedSprite_t as = loadAnimationFromFile(texture, file);
|
|
||||||
|
|
||||||
// Copia los datos de las animaciones
|
|
||||||
for (auto animation : as.animations)
|
|
||||||
{
|
|
||||||
this->animation.push_back(animation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (buffer)
|
|
||||||
{
|
|
||||||
loadFromVector(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inicializa variables
|
|
||||||
currentAnimation = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
AnimatedSprite::AnimatedSprite(SDL_Renderer *renderer, animatedSprite_t *animation)
|
|
||||||
{
|
|
||||||
// Copia los punteros
|
|
||||||
setTexture(animation->texture);
|
|
||||||
setRenderer(renderer);
|
|
||||||
|
|
||||||
// Inicializa variables
|
|
||||||
currentAnimation = 0;
|
|
||||||
|
|
||||||
// Copia los datos de las animaciones
|
|
||||||
for (auto a : animation->animations)
|
|
||||||
{
|
|
||||||
this->animation.push_back(a);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
AnimatedSprite::~AnimatedSprite()
|
|
||||||
{
|
|
||||||
for (auto &a : animation)
|
|
||||||
{
|
|
||||||
a.frames.clear();
|
|
||||||
}
|
|
||||||
animation.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el indice de la animación a partir del nombre
|
|
||||||
int AnimatedSprite::getIndex(std::string name)
|
|
||||||
{
|
|
||||||
int index = -1;
|
|
||||||
|
|
||||||
for (auto a : animation)
|
|
||||||
{
|
|
||||||
index++;
|
|
||||||
if (a.name == name)
|
|
||||||
{
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "** Warning: could not find \"" << name.c_str() << "\" animation" << std::endl;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calcula el frame correspondiente a la animación
|
|
||||||
void AnimatedSprite::animate()
|
|
||||||
{
|
|
||||||
if (!enabled || animation[currentAnimation].speed == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calcula el frame actual a partir del contador
|
|
||||||
animation[currentAnimation].currentFrame = animation[currentAnimation].counter / animation[currentAnimation].speed;
|
|
||||||
|
|
||||||
// Si alcanza el final de la animación, reinicia el contador de la animación
|
|
||||||
// en función de la variable loop y coloca el nuevo frame
|
|
||||||
if (animation[currentAnimation].currentFrame >= (int)animation[currentAnimation].frames.size())
|
|
||||||
{
|
|
||||||
if (animation[currentAnimation].loop == -1)
|
|
||||||
{ // Si no hay loop, deja el último frame
|
|
||||||
animation[currentAnimation].currentFrame = animation[currentAnimation].frames.size();
|
|
||||||
animation[currentAnimation].completed = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // Si hay loop, vuelve al frame indicado
|
|
||||||
animation[currentAnimation].counter = 0;
|
|
||||||
animation[currentAnimation].currentFrame = animation[currentAnimation].loop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// En caso contrario
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Escoge el frame correspondiente de la animación
|
|
||||||
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
|
|
||||||
|
|
||||||
// Incrementa el contador de la animacion
|
|
||||||
animation[currentAnimation].counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el numero de frames de la animación actual
|
|
||||||
int AnimatedSprite::getNumFrames()
|
|
||||||
{
|
|
||||||
return (int)animation[currentAnimation].frames.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el frame actual de la animación
|
|
||||||
void AnimatedSprite::setCurrentFrame(int num)
|
|
||||||
{
|
|
||||||
// Descarta valores fuera de rango
|
|
||||||
if (num >= (int)animation[currentAnimation].frames.size())
|
|
||||||
{
|
|
||||||
num = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cambia el valor de la variable
|
|
||||||
animation[currentAnimation].currentFrame = num;
|
|
||||||
animation[currentAnimation].counter = 0;
|
|
||||||
|
|
||||||
// Escoge el frame correspondiente de la animación
|
|
||||||
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor del contador
|
|
||||||
void AnimatedSprite::setAnimationCounter(std::string name, int num)
|
|
||||||
{
|
|
||||||
animation[getIndex(name)].counter = num;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece la velocidad de una animación
|
|
||||||
void AnimatedSprite::setAnimationSpeed(std::string name, int speed)
|
|
||||||
{
|
|
||||||
animation[getIndex(name)].counter = speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece la velocidad de una animación
|
|
||||||
void AnimatedSprite::setAnimationSpeed(int index, int speed)
|
|
||||||
{
|
|
||||||
animation[index].counter = speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece si la animación se reproduce en bucle
|
|
||||||
void AnimatedSprite::setAnimationLoop(std::string name, int loop)
|
|
||||||
{
|
|
||||||
animation[getIndex(name)].loop = loop;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece si la animación se reproduce en bucle
|
|
||||||
void AnimatedSprite::setAnimationLoop(int index, int loop)
|
|
||||||
{
|
|
||||||
animation[index].loop = loop;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void AnimatedSprite::setAnimationCompleted(std::string name, bool value)
|
|
||||||
{
|
|
||||||
animation[getIndex(name)].completed = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// OLD - Establece el valor de la variable
|
|
||||||
void AnimatedSprite::setAnimationCompleted(int index, bool value)
|
|
||||||
{
|
|
||||||
animation[index].completed = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba si ha terminado la animación
|
|
||||||
bool AnimatedSprite::animationIsCompleted()
|
|
||||||
{
|
|
||||||
return animation[currentAnimation].completed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Devuelve el rectangulo de una animación y frame concreto
|
|
||||||
SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
|
|
||||||
{
|
|
||||||
return animation[getIndex(name)].frames[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Devuelve el rectangulo de una animación y frame concreto
|
|
||||||
SDL_Rect AnimatedSprite::getAnimationClip(int indexA, Uint8 indexF)
|
|
||||||
{
|
|
||||||
return animation[indexA].frames[indexF];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Carga la animación desde un vector
|
|
||||||
bool AnimatedSprite::loadFromVector(std::vector<std::string> *source)
|
|
||||||
{
|
|
||||||
// Inicializa variables
|
|
||||||
int framesPerRow = 0;
|
|
||||||
int frameWidth = 0;
|
|
||||||
int frameHeight = 0;
|
|
||||||
int maxTiles = 0;
|
|
||||||
|
|
||||||
// Indicador de éxito en el proceso
|
|
||||||
bool success = true;
|
|
||||||
std::string line;
|
|
||||||
|
|
||||||
// Recorre todo el vector
|
|
||||||
int index = 0;
|
|
||||||
while (index < (int)source->size())
|
|
||||||
{
|
|
||||||
// Lee desde el vector
|
|
||||||
line = source->at(index);
|
|
||||||
|
|
||||||
// Si la linea contiene el texto [animation] se realiza el proceso de carga de una animación
|
|
||||||
if (line == "[animation]")
|
|
||||||
{
|
|
||||||
animation_t buffer;
|
|
||||||
buffer.counter = 0;
|
|
||||||
buffer.currentFrame = 0;
|
|
||||||
buffer.completed = false;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
// Aumenta el indice para leer la siguiente linea
|
|
||||||
index++;
|
|
||||||
line = source->at(index);
|
|
||||||
|
|
||||||
// Encuentra la posición del caracter '='
|
|
||||||
int pos = line.find("=");
|
|
||||||
|
|
||||||
// Procesa las dos subcadenas
|
|
||||||
if (pos != (int)line.npos)
|
|
||||||
{
|
|
||||||
if (line.substr(0, pos) == "name")
|
|
||||||
{
|
|
||||||
buffer.name = line.substr(pos + 1, line.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (line.substr(0, pos) == "speed")
|
|
||||||
{
|
|
||||||
buffer.speed = std::stoi(line.substr(pos + 1, line.length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (line.substr(0, pos) == "loop")
|
|
||||||
{
|
|
||||||
buffer.loop = std::stoi(line.substr(pos + 1, line.length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (line.substr(0, pos) == "frames")
|
|
||||||
{
|
|
||||||
// Se introducen los valores separados por comas en un vector
|
|
||||||
std::stringstream ss(line.substr(pos + 1, line.length()));
|
|
||||||
std::string tmp;
|
|
||||||
SDL_Rect rect = {0, 0, frameWidth, frameHeight};
|
|
||||||
while (getline(ss, tmp, ','))
|
|
||||||
{
|
|
||||||
// Comprueba que el tile no sea mayor que el maximo indice permitido
|
|
||||||
const int numTile = std::stoi(tmp) > maxTiles ? 0 : std::stoi(tmp);
|
|
||||||
rect.x = (numTile % framesPerRow) * frameWidth;
|
|
||||||
rect.y = (numTile / framesPerRow) * frameHeight;
|
|
||||||
buffer.frames.push_back(rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "Warning: unknown parameter " << line.substr(0, pos).c_str() << std::endl;
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (line != "[/animation]");
|
|
||||||
|
|
||||||
// Añade la animación al vector de animaciones
|
|
||||||
animation.push_back(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// En caso contrario se parsea el fichero para buscar las variables y los valores
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Encuentra la posición del caracter '='
|
|
||||||
int pos = line.find("=");
|
|
||||||
|
|
||||||
// Procesa las dos subcadenas
|
|
||||||
if (pos != (int)line.npos)
|
|
||||||
{
|
|
||||||
if (line.substr(0, pos) == "framesPerRow")
|
|
||||||
{
|
|
||||||
framesPerRow = std::stoi(line.substr(pos + 1, line.length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (line.substr(0, pos) == "frameWidth")
|
|
||||||
{
|
|
||||||
frameWidth = std::stoi(line.substr(pos + 1, line.length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (line.substr(0, pos) == "frameHeight")
|
|
||||||
{
|
|
||||||
frameHeight = std::stoi(line.substr(pos + 1, line.length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "Warning: unknown parameter " << line.substr(0, pos).c_str() << std::endl;
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normaliza valores
|
|
||||||
if (framesPerRow == 0 && frameWidth > 0)
|
|
||||||
{
|
|
||||||
framesPerRow = texture->getWidth() / frameWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxTiles == 0 && frameWidth > 0 && frameHeight > 0)
|
|
||||||
{
|
|
||||||
const int w = texture->getWidth() / frameWidth;
|
|
||||||
const int h = texture->getHeight() / frameHeight;
|
|
||||||
maxTiles = w * h;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Una vez procesada la linea, aumenta el indice para pasar a la siguiente
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pone un valor por defecto
|
|
||||||
setRect({0, 0, frameWidth, frameHeight});
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece la animacion actual
|
|
||||||
void AnimatedSprite::setCurrentAnimation(std::string name)
|
|
||||||
{
|
|
||||||
const int newAnimation = getIndex(name);
|
|
||||||
if (currentAnimation != newAnimation)
|
|
||||||
{
|
|
||||||
currentAnimation = newAnimation;
|
|
||||||
animation[currentAnimation].currentFrame = 0;
|
|
||||||
animation[currentAnimation].counter = 0;
|
|
||||||
animation[currentAnimation].completed = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece la animacion actual
|
|
||||||
void AnimatedSprite::setCurrentAnimation(int index)
|
|
||||||
{
|
|
||||||
const int newAnimation = index;
|
|
||||||
if (currentAnimation != newAnimation)
|
|
||||||
{
|
|
||||||
currentAnimation = newAnimation;
|
|
||||||
animation[currentAnimation].currentFrame = 0;
|
|
||||||
animation[currentAnimation].counter = 0;
|
|
||||||
animation[currentAnimation].completed = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
|
||||||
void AnimatedSprite::update()
|
|
||||||
{
|
|
||||||
animate();
|
|
||||||
MovingSprite::update();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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)
|
|
||||||
{
|
|
||||||
animation[index_animation].frames.push_back({x, y, w, h});
|
|
||||||
}
|
|
||||||
|
|
||||||
// OLD - Establece el contador para todas las animaciones
|
|
||||||
void AnimatedSprite::setAnimationCounter(int value)
|
|
||||||
{
|
|
||||||
for (auto &a : animation)
|
|
||||||
{
|
|
||||||
a.counter = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reinicia la animación
|
|
||||||
void AnimatedSprite::resetAnimation()
|
|
||||||
{
|
|
||||||
animation[currentAnimation].currentFrame = 0;
|
|
||||||
animation[currentAnimation].counter = 0;
|
|
||||||
animation[currentAnimation].completed = false;
|
|
||||||
}
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include "movingsprite.h"
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifndef ANIMATEDSPRITE_H
|
|
||||||
#define ANIMATEDSPRITE_H
|
|
||||||
|
|
||||||
struct animation_t
|
|
||||||
{
|
|
||||||
std::string name; // Nombre de la animacion
|
|
||||||
std::vector<SDL_Rect> frames; // Cada uno de los frames que componen la animación
|
|
||||||
int speed; // Velocidad de la animación
|
|
||||||
int loop; // Indica a que frame vuelve la animación al terminar. -1 para que no vuelva
|
|
||||||
bool completed; // Indica si ha finalizado la animación
|
|
||||||
int currentFrame; // Frame actual
|
|
||||||
int counter; // Contador para las animaciones
|
|
||||||
};
|
|
||||||
|
|
||||||
struct animatedSprite_t
|
|
||||||
{
|
|
||||||
std::vector<animation_t> animations; // Vector con las diferentes animaciones
|
|
||||||
Texture *texture; // Textura con los graficos para el sprite
|
|
||||||
};
|
|
||||||
|
|
||||||
// Carga la animación desde un fichero
|
|
||||||
animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath, bool verbose = false);
|
|
||||||
|
|
||||||
class AnimatedSprite : public MovingSprite
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
// Variables
|
|
||||||
std::vector<animation_t> animation; // Vector con las diferentes animaciones
|
|
||||||
int currentAnimation; // Animacion activa
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
AnimatedSprite(Texture *texture = nullptr, SDL_Renderer *renderer = nullptr, std::string file = "", std::vector<std::string> *buffer = nullptr);
|
|
||||||
AnimatedSprite(SDL_Renderer *renderer, animatedSprite_t *animation);
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~AnimatedSprite();
|
|
||||||
|
|
||||||
// Calcula el frame correspondiente a la animación actual
|
|
||||||
void animate();
|
|
||||||
|
|
||||||
// Obtiene el numero de frames de la animación actual
|
|
||||||
int getNumFrames();
|
|
||||||
|
|
||||||
// Establece el frame actual de la animación
|
|
||||||
void setCurrentFrame(int num);
|
|
||||||
|
|
||||||
// Establece el valor del contador
|
|
||||||
void setAnimationCounter(std::string name, int num);
|
|
||||||
|
|
||||||
// Establece la velocidad de una animación
|
|
||||||
void setAnimationSpeed(std::string name, int speed);
|
|
||||||
void setAnimationSpeed(int index, int speed);
|
|
||||||
|
|
||||||
// Establece el frame al que vuelve la animación al finalizar
|
|
||||||
void setAnimationLoop(std::string name, int loop);
|
|
||||||
void setAnimationLoop(int index, int loop);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setAnimationCompleted(std::string name, bool value);
|
|
||||||
void setAnimationCompleted(int index, bool value);
|
|
||||||
|
|
||||||
// Comprueba si ha terminado la animación
|
|
||||||
bool animationIsCompleted();
|
|
||||||
|
|
||||||
// Devuelve el rectangulo de una animación y frame concreto
|
|
||||||
SDL_Rect getAnimationClip(std::string name = "default", Uint8 index = 0);
|
|
||||||
SDL_Rect getAnimationClip(int indexA = 0, Uint8 indexF = 0);
|
|
||||||
|
|
||||||
// Obtiene el indice de la animación a partir del nombre
|
|
||||||
int getIndex(std::string name);
|
|
||||||
|
|
||||||
// Carga la animación desde un vector
|
|
||||||
bool loadFromVector(std::vector<std::string> *source);
|
|
||||||
|
|
||||||
// Establece la animacion actual
|
|
||||||
void setCurrentAnimation(std::string name = "default");
|
|
||||||
void setCurrentAnimation(int index = 0);
|
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
|
||||||
void update();
|
|
||||||
|
|
||||||
// OLD - Establece el rectangulo para un frame de una animación
|
|
||||||
void setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h);
|
|
||||||
|
|
||||||
// OLD - Establece el contador para todas las animaciones
|
|
||||||
void setAnimationCounter(int value);
|
|
||||||
|
|
||||||
// Reinicia la animación
|
|
||||||
void resetAnimation();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
#include "asset.h"
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
Asset::Asset(std::string executablePath)
|
|
||||||
{
|
|
||||||
this->executablePath = executablePath.substr(0, executablePath.find_last_of("\\/"));
|
|
||||||
longestName = 0;
|
|
||||||
verbose = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Añade un elemento a la lista
|
|
||||||
void Asset::add(std::string file, enum assetType type, bool required, bool absolute)
|
|
||||||
{
|
|
||||||
item_t temp;
|
|
||||||
temp.file = absolute ? file : executablePath + file;
|
|
||||||
temp.type = type;
|
|
||||||
temp.required = required;
|
|
||||||
fileList.push_back(temp);
|
|
||||||
|
|
||||||
const std::string filename = file.substr(file.find_last_of("\\/") + 1);
|
|
||||||
longestName = SDL_max(longestName, filename.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Devuelve el fichero de un elemento de la lista a partir de una cadena
|
|
||||||
std::string Asset::get(std::string text)
|
|
||||||
{
|
|
||||||
for (auto f : fileList)
|
|
||||||
{
|
|
||||||
const size_t lastIndex = f.file.find_last_of("/") + 1;
|
|
||||||
const std::string file = f.file.substr(lastIndex, std::string::npos);
|
|
||||||
|
|
||||||
if (file == text)
|
|
||||||
{
|
|
||||||
return f.file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
std::cout << "Warning: file " << text.c_str() << " not found" << std::endl;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba que existen todos los elementos
|
|
||||||
bool Asset::check()
|
|
||||||
{
|
|
||||||
bool success = true;
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
std::cout << "\n** Checking files" << std::endl;
|
|
||||||
|
|
||||||
std::cout << "Executable path is: " << executablePath << std::endl;
|
|
||||||
std::cout << "Sample filepath: " << fileList.back().file << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba la lista de ficheros clasificandolos por tipo
|
|
||||||
for (int type = 0; type < t_maxAssetType; ++type)
|
|
||||||
{
|
|
||||||
// Comprueba si hay ficheros de ese tipo
|
|
||||||
bool any = false;
|
|
||||||
|
|
||||||
for (auto f : fileList)
|
|
||||||
{
|
|
||||||
if ((f.required) && (f.type == type))
|
|
||||||
{
|
|
||||||
any = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Si hay ficheros de ese tipo, comprueba si existen
|
|
||||||
if (any)
|
|
||||||
{
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
std::cout << "\n>> " << getTypeName(type).c_str() << " FILES" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto f : fileList)
|
|
||||||
{
|
|
||||||
if ((f.required) && (f.type == type))
|
|
||||||
{
|
|
||||||
success &= checkFile(f.file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resultado
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
std::cout << "\n** All files OK.\n"
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "\n** A file is missing. Exiting.\n"
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba que existe un fichero
|
|
||||||
bool Asset::checkFile(std::string path)
|
|
||||||
{
|
|
||||||
bool success = false;
|
|
||||||
std::string result = "ERROR";
|
|
||||||
|
|
||||||
// Comprueba si existe el fichero
|
|
||||||
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
|
|
||||||
SDL_RWops *file = SDL_RWFromFile(path.c_str(), "rb");
|
|
||||||
|
|
||||||
if (file != nullptr)
|
|
||||||
{
|
|
||||||
result = "OK";
|
|
||||||
success = true;
|
|
||||||
SDL_RWclose(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
std::cout.setf(std::ios::left, std::ios::adjustfield);
|
|
||||||
std::cout << "Checking file: ";
|
|
||||||
std::cout.width(longestName + 2);
|
|
||||||
std::cout.fill('.');
|
|
||||||
std::cout << filename + " ";
|
|
||||||
std::cout << " [" + result + "]" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Devuelve el nombre del tipo de recurso
|
|
||||||
std::string Asset::getTypeName(int type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case t_bitmap:
|
|
||||||
return "BITMAP";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_music:
|
|
||||||
return "MUSIC";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_sound:
|
|
||||||
return "SOUND";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_font:
|
|
||||||
return "FONT";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_lang:
|
|
||||||
return "LANG";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_data:
|
|
||||||
return "DATA";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_room:
|
|
||||||
return "ROOM";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_enemy:
|
|
||||||
return "ENEMY";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_item:
|
|
||||||
return "ITEM";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return "ERROR";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece si ha de mostrar texto por pantalla
|
|
||||||
void Asset::setVerbose(bool value)
|
|
||||||
{
|
|
||||||
verbose = value;
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifndef ASSET_H
|
|
||||||
#define ASSET_H
|
|
||||||
|
|
||||||
enum assetType
|
|
||||||
{
|
|
||||||
t_bitmap,
|
|
||||||
t_music,
|
|
||||||
t_sound,
|
|
||||||
t_font,
|
|
||||||
t_lang,
|
|
||||||
t_data,
|
|
||||||
t_room,
|
|
||||||
t_enemy,
|
|
||||||
t_item,
|
|
||||||
t_maxAssetType
|
|
||||||
};
|
|
||||||
|
|
||||||
// Clase Asset
|
|
||||||
class Asset
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
// Estructura para definir un item
|
|
||||||
struct item_t
|
|
||||||
{
|
|
||||||
std::string file; // Ruta del fichero desde la raiz del directorio
|
|
||||||
enum assetType type; // Indica el tipo de recurso
|
|
||||||
bool required; // Indica si es un fichero que debe de existir
|
|
||||||
//bool absolute; // Indica si la ruta que se ha proporcionado es una ruta absoluta
|
|
||||||
};
|
|
||||||
|
|
||||||
// Variables
|
|
||||||
int longestName; // Contiene la longitud del nombre de fichero mas largo
|
|
||||||
std::vector<item_t> fileList; // Listado con todas las rutas a los ficheros
|
|
||||||
std::string executablePath; // Ruta al ejecutable
|
|
||||||
bool verbose; // Indica si ha de mostrar información por pantalla
|
|
||||||
|
|
||||||
// Comprueba que existe un fichero
|
|
||||||
bool checkFile(std::string executablePath);
|
|
||||||
|
|
||||||
// Devuelve el nombre del tipo de recurso
|
|
||||||
std::string getTypeName(int type);
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
Asset(std::string path);
|
|
||||||
|
|
||||||
// Añade un elemento a la lista
|
|
||||||
void add(std::string file, enum assetType type, bool required = true, bool absolute = false);
|
|
||||||
|
|
||||||
// Devuelve un elemento de la lista a partir de una cadena
|
|
||||||
std::string get(std::string text);
|
|
||||||
|
|
||||||
// Comprueba que existen todos los elementos
|
|
||||||
bool check();
|
|
||||||
|
|
||||||
// Establece si ha de mostrar texto por pantalla
|
|
||||||
void setVerbose(bool value);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
#include "debug.h"
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
Debug::Debug(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
|
||||||
{
|
|
||||||
// Copia la dirección de los objetos
|
|
||||||
this->renderer = renderer;
|
|
||||||
this->screen = screen;
|
|
||||||
this->asset = asset;
|
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
|
||||||
texture = new Texture(renderer, asset->get("debug.png"));
|
|
||||||
text = new Text(asset->get("debug.txt"), texture, renderer);
|
|
||||||
|
|
||||||
// Inicializa variables
|
|
||||||
x = 0;
|
|
||||||
y = 0;
|
|
||||||
enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
Debug::~Debug()
|
|
||||||
{
|
|
||||||
delete texture;
|
|
||||||
delete text;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza las variables
|
|
||||||
void Debug::update()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dibuja en pantalla
|
|
||||||
void Debug::render()
|
|
||||||
{
|
|
||||||
int y = this->y;
|
|
||||||
int w = 0;
|
|
||||||
|
|
||||||
for (auto s : slot)
|
|
||||||
{
|
|
||||||
text->write(x, y, s);
|
|
||||||
w = (std::max(w, (int)s.length()));
|
|
||||||
y += text->getCharacterSize() + 1;
|
|
||||||
if (y > 192 - text->getCharacterSize())
|
|
||||||
{
|
|
||||||
y = this->y;
|
|
||||||
x += w * text->getCharacterSize() + 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
y = 0;
|
|
||||||
for (auto l : log)
|
|
||||||
{
|
|
||||||
text->writeColored(x + 10, y, l, {255, 255, 255});
|
|
||||||
y += text->getCharacterSize() + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece la posición donde se colocará la información de debug
|
|
||||||
void Debug::setPos(SDL_Point p)
|
|
||||||
{
|
|
||||||
x = p.x;
|
|
||||||
y = p.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Añade un texto para mostrar
|
|
||||||
void Debug::add(std::string text)
|
|
||||||
{
|
|
||||||
slot.push_back(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Borra la información de debug
|
|
||||||
void Debug::clear()
|
|
||||||
{
|
|
||||||
slot.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Añade un texto para mostrar en el apartado log
|
|
||||||
void Debug::addToLog(std::string text)
|
|
||||||
{
|
|
||||||
log.push_back(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Borra la información de debug del apartado log
|
|
||||||
void Debug::clearLog()
|
|
||||||
{
|
|
||||||
log.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Debug::setEnabled(bool value)
|
|
||||||
{
|
|
||||||
enabled = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
bool Debug::getEnabled()
|
|
||||||
{
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cambia el valor de la variable
|
|
||||||
void Debug::switchEnabled()
|
|
||||||
{
|
|
||||||
enabled = !enabled;
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include "../const.h"
|
|
||||||
#include "asset.h"
|
|
||||||
#include "screen.h"
|
|
||||||
#include "text.h"
|
|
||||||
#include "texture.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifndef DEBUG_H
|
|
||||||
#define DEBUG_H
|
|
||||||
|
|
||||||
// Clase Debug
|
|
||||||
class Debug
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
// Objetos y punteros
|
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
|
||||||
Text *text; // Objeto encargado de escribir texto en pantalla
|
|
||||||
Texture *texture; // Textura para el texto
|
|
||||||
|
|
||||||
// Variables
|
|
||||||
std::vector<std::string> slot; // Vector con los textos a escribir
|
|
||||||
std::vector<std::string> log; // Vector con los textos a escribir
|
|
||||||
int x; // Posicion donde escribir el texto de debug
|
|
||||||
int y; // Posición donde escribir el texto de debug
|
|
||||||
bool enabled; // Indica si esta activo el modo debug
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
Debug(SDL_Renderer *renderer, Screen *screen, Asset *asset);
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~Debug();
|
|
||||||
|
|
||||||
// Actualiza las variables
|
|
||||||
void update();
|
|
||||||
|
|
||||||
// Dibuja en pantalla
|
|
||||||
void render();
|
|
||||||
|
|
||||||
// Establece la posición donde se colocará la información de debug
|
|
||||||
void setPos(SDL_Point p);
|
|
||||||
|
|
||||||
// Añade un texto para mostrar
|
|
||||||
void add(std::string text);
|
|
||||||
|
|
||||||
// Borra la información de debug
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
// Añade un texto para mostrar en el apartado log
|
|
||||||
void addToLog(std::string text);
|
|
||||||
|
|
||||||
// Borra la información de debug del apartado log
|
|
||||||
void clearLog();
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setEnabled(bool value);
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
bool getEnabled();
|
|
||||||
|
|
||||||
// Cambia el valor de la variable
|
|
||||||
void switchEnabled();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifndef INPUT_H
|
|
||||||
#define INPUT_H
|
|
||||||
|
|
||||||
#define INPUT_NULL 0
|
|
||||||
#define INPUT_UP 1
|
|
||||||
#define INPUT_DOWN 2
|
|
||||||
#define INPUT_LEFT 3
|
|
||||||
#define INPUT_RIGHT 4
|
|
||||||
#define INPUT_ACCEPT 5
|
|
||||||
#define INPUT_CANCEL 6
|
|
||||||
#define INPUT_BUTTON_1 7
|
|
||||||
#define INPUT_BUTTON_2 8
|
|
||||||
#define INPUT_BUTTON_3 9
|
|
||||||
#define INPUT_BUTTON_4 10
|
|
||||||
#define INPUT_BUTTON_5 11
|
|
||||||
#define INPUT_BUTTON_6 12
|
|
||||||
#define INPUT_BUTTON_7 13
|
|
||||||
#define INPUT_BUTTON_8 14
|
|
||||||
#define INPUT_BUTTON_PAUSE 15
|
|
||||||
#define INPUT_BUTTON_ESCAPE 16
|
|
||||||
|
|
||||||
#define REPEAT_TRUE true
|
|
||||||
#define REPEAT_FALSE false
|
|
||||||
|
|
||||||
#define INPUT_USE_KEYBOARD 0
|
|
||||||
#define INPUT_USE_GAMECONTROLLER 1
|
|
||||||
#define INPUT_USE_ANY 2
|
|
||||||
|
|
||||||
enum i_disable_e
|
|
||||||
{
|
|
||||||
d_notDisabled,
|
|
||||||
d_forever,
|
|
||||||
d_keyPressed
|
|
||||||
};
|
|
||||||
|
|
||||||
class Input
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
struct keyBindings_t
|
|
||||||
{
|
|
||||||
Uint8 scancode; // Scancode asociado
|
|
||||||
bool active; // Indica si está activo
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GameControllerBindings_t
|
|
||||||
{
|
|
||||||
SDL_GameControllerButton button; // GameControllerButton asociado
|
|
||||||
bool active; // Indica si está activo
|
|
||||||
};
|
|
||||||
|
|
||||||
// Objetos y punteros
|
|
||||||
std::vector<SDL_GameController *> connectedControllers; // Vector con todos los mandos conectados
|
|
||||||
|
|
||||||
// Variables
|
|
||||||
std::vector<keyBindings_t> keyBindings; // Vector con las teclas asociadas a los inputs predefinidos
|
|
||||||
std::vector<GameControllerBindings_t> gameControllerBindings; // Vector con las teclas asociadas a los inputs predefinidos
|
|
||||||
std::vector<std::string> controllerNames; // Vector con los nombres de los mandos
|
|
||||||
int numGamepads; // Numero de mandos conectados
|
|
||||||
std::string dbPath; // Ruta al archivo gamecontrollerdb.txt
|
|
||||||
bool verbose; // Indica si ha de mostrar mensajes
|
|
||||||
i_disable_e disabledUntil; // Tiempo que esta deshabilitado
|
|
||||||
bool enabled; // Indica si está habilitado
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
Input(std::string file);
|
|
||||||
|
|
||||||
// Actualiza el estado del objeto
|
|
||||||
void update();
|
|
||||||
|
|
||||||
// Asigna inputs a teclas
|
|
||||||
void bindKey(Uint8 input, SDL_Scancode code);
|
|
||||||
|
|
||||||
// Asigna inputs a botones del mando
|
|
||||||
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
|
||||||
|
|
||||||
// Comprueba si un input esta activo
|
|
||||||
bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0);
|
|
||||||
|
|
||||||
// Comprueba si hay almenos un input activo
|
|
||||||
bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0);
|
|
||||||
|
|
||||||
// Busca si hay un mando conectado
|
|
||||||
bool discoverGameController();
|
|
||||||
|
|
||||||
// Comprueba si hay algun mando conectado
|
|
||||||
bool gameControllerFound();
|
|
||||||
|
|
||||||
// Obten el numero de mandos conectados
|
|
||||||
int getNumControllers();
|
|
||||||
|
|
||||||
// Obten el nombre de un mando de juego
|
|
||||||
std::string getControllerName(int index);
|
|
||||||
|
|
||||||
// Establece si ha de mostrar mensajes
|
|
||||||
void setVerbose(bool value);
|
|
||||||
|
|
||||||
// Deshabilita las entradas durante un periodo de tiempo
|
|
||||||
void disableUntil(i_disable_e value);
|
|
||||||
|
|
||||||
// Hablita las entradas
|
|
||||||
void enable();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,251 +0,0 @@
|
|||||||
#ifndef JA_USESDLMIXER
|
|
||||||
#include "jail_audio.h"
|
|
||||||
#include "stb_vorbis.c"
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define JA_MAX_SIMULTANEOUS_CHANNELS 5
|
|
||||||
|
|
||||||
struct JA_Sound_t {
|
|
||||||
Uint32 length {0};
|
|
||||||
Uint8* buffer {NULL};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct JA_Channel_t {
|
|
||||||
JA_Sound_t *sound;
|
|
||||||
int pos {0};
|
|
||||||
int times {0};
|
|
||||||
JA_Channel_state state { JA_CHANNEL_FREE };
|
|
||||||
};
|
|
||||||
|
|
||||||
struct JA_Music_t {
|
|
||||||
int samples {0};
|
|
||||||
int pos {0};
|
|
||||||
int times {0};
|
|
||||||
short* output {NULL};
|
|
||||||
JA_Music_state state {JA_MUSIC_INVALID};
|
|
||||||
};
|
|
||||||
|
|
||||||
JA_Music_t *current_music{NULL};
|
|
||||||
JA_Channel_t channels[JA_MAX_SIMULTANEOUS_CHANNELS];
|
|
||||||
|
|
||||||
int JA_freq {48000};
|
|
||||||
SDL_AudioFormat JA_format {AUDIO_S16};
|
|
||||||
Uint8 JA_channels {2};
|
|
||||||
int JA_volume = 128;
|
|
||||||
SDL_AudioDeviceID sdlAudioDevice = 0;
|
|
||||||
|
|
||||||
void audioCallback(void * userdata, uint8_t * stream, int len) {
|
|
||||||
SDL_memset(stream, 0, len);
|
|
||||||
if (current_music != NULL && current_music->state == JA_MUSIC_PLAYING) {
|
|
||||||
const int size = SDL_min(len, current_music->samples*2-current_music->pos);
|
|
||||||
SDL_MixAudioFormat(stream, (Uint8*)(current_music->output+current_music->pos), AUDIO_S16, size, JA_volume);
|
|
||||||
current_music->pos += size/2;
|
|
||||||
if (size < len) {
|
|
||||||
if (current_music->times != 0) {
|
|
||||||
SDL_MixAudioFormat(stream+size, (Uint8*)current_music->output, AUDIO_S16, len-size, JA_volume);
|
|
||||||
current_music->pos = (len-size)/2;
|
|
||||||
if (current_music->times > 0) current_music->times--;
|
|
||||||
} else {
|
|
||||||
current_music->pos = 0;
|
|
||||||
current_music->state = JA_MUSIC_STOPPED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Mixar els channels mi amol
|
|
||||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
|
||||||
if (channels[i].state == JA_CHANNEL_PLAYING) {
|
|
||||||
const int size = SDL_min(len, channels[i].sound->length - channels[i].pos);
|
|
||||||
SDL_MixAudioFormat(stream, channels[i].sound->buffer + channels[i].pos, AUDIO_S16, size, JA_volume/2);
|
|
||||||
channels[i].pos += size;
|
|
||||||
if (size < len) {
|
|
||||||
if (channels[i].times != 0) {
|
|
||||||
SDL_MixAudioFormat(stream + size, channels[i].sound->buffer, AUDIO_S16, len-size, JA_volume/2);
|
|
||||||
channels[i].pos = len-size;
|
|
||||||
if (channels[i].times > 0) channels[i].times--;
|
|
||||||
} else {
|
|
||||||
JA_StopChannel(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels) {
|
|
||||||
JA_freq = freq;
|
|
||||||
JA_format = format;
|
|
||||||
JA_channels = channels;
|
|
||||||
SDL_AudioSpec audioSpec{JA_freq, JA_format, JA_channels, 0, 1024, 0, 0, audioCallback, NULL};
|
|
||||||
if (sdlAudioDevice != 0) SDL_CloseAudioDevice(sdlAudioDevice);
|
|
||||||
sdlAudioDevice = SDL_OpenAudioDevice(NULL, 0, &audioSpec, NULL, 0);
|
|
||||||
SDL_PauseAudioDevice(sdlAudioDevice, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void JA_Quit() {
|
|
||||||
SDL_PauseAudioDevice(sdlAudioDevice, 1);
|
|
||||||
if (sdlAudioDevice != 0) SDL_CloseAudioDevice(sdlAudioDevice);
|
|
||||||
sdlAudioDevice = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
JA_Music_t *JA_LoadMusic(const char* filename) {
|
|
||||||
int chan, samplerate;
|
|
||||||
|
|
||||||
// [RZC 28/08/22] Carreguem primer el arxiu en memòria i després el descomprimim. Es algo més rapid.
|
|
||||||
FILE *f = fopen(filename, "rb");
|
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
long fsize = ftell(f);
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
Uint8 *buffer = (Uint8*)malloc(fsize + 1);
|
|
||||||
if (fread(buffer, fsize, 1, f)!=1) return NULL;
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
JA_Music_t *music = new JA_Music_t();
|
|
||||||
|
|
||||||
music->samples = stb_vorbis_decode_memory(buffer, fsize, &chan, &samplerate, &music->output);
|
|
||||||
free(buffer);
|
|
||||||
// [RZC 28/08/22] Abans el descomprimiem mentre el teniem obert
|
|
||||||
// music->samples = stb_vorbis_decode_filename(filename, &chan, &samplerate, &music->output);
|
|
||||||
|
|
||||||
SDL_AudioCVT cvt;
|
|
||||||
SDL_BuildAudioCVT(&cvt, AUDIO_S16, chan, samplerate, JA_format, JA_channels, JA_freq);
|
|
||||||
if (cvt.needed) {
|
|
||||||
cvt.len = music->samples * chan * 2;
|
|
||||||
cvt.buf = (Uint8 *) SDL_malloc(cvt.len * cvt.len_mult);
|
|
||||||
SDL_memcpy(cvt.buf, music->output, cvt.len);
|
|
||||||
SDL_ConvertAudio(&cvt);
|
|
||||||
free(music->output);
|
|
||||||
music->output = (short*)cvt.buf;
|
|
||||||
}
|
|
||||||
music->pos = 0;
|
|
||||||
music->state = JA_MUSIC_STOPPED;
|
|
||||||
|
|
||||||
return music;
|
|
||||||
}
|
|
||||||
|
|
||||||
void JA_PlayMusic(JA_Music_t *music, const int loop) {
|
|
||||||
if (current_music != NULL) {
|
|
||||||
current_music->pos = 0;
|
|
||||||
current_music->state = JA_MUSIC_STOPPED;
|
|
||||||
}
|
|
||||||
current_music = music;
|
|
||||||
current_music->pos = 0;
|
|
||||||
current_music->state = JA_MUSIC_PLAYING;
|
|
||||||
current_music->times = loop;
|
|
||||||
}
|
|
||||||
|
|
||||||
void JA_PauseMusic() {
|
|
||||||
if (current_music == NULL || current_music->state == JA_MUSIC_INVALID) return;
|
|
||||||
current_music->state = JA_MUSIC_PAUSED;
|
|
||||||
}
|
|
||||||
|
|
||||||
void JA_ResumeMusic() {
|
|
||||||
if (current_music == NULL || current_music->state == JA_MUSIC_INVALID) return;
|
|
||||||
current_music->state = JA_MUSIC_PLAYING;
|
|
||||||
}
|
|
||||||
|
|
||||||
void JA_StopMusic() {
|
|
||||||
if (current_music == NULL || current_music->state == JA_MUSIC_INVALID) return;
|
|
||||||
current_music->pos = 0;
|
|
||||||
current_music->state = JA_MUSIC_STOPPED;
|
|
||||||
}
|
|
||||||
|
|
||||||
JA_Music_state JA_GetMusicState() {
|
|
||||||
if (current_music == NULL) return JA_MUSIC_INVALID;
|
|
||||||
return current_music->state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void JA_DeleteMusic(JA_Music_t *music) {
|
|
||||||
if (current_music == music) current_music = NULL;
|
|
||||||
free(music->output);
|
|
||||||
delete music;
|
|
||||||
}
|
|
||||||
|
|
||||||
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length) {
|
|
||||||
JA_Sound_t *sound = new JA_Sound_t();
|
|
||||||
sound->buffer = buffer;
|
|
||||||
sound->length = length;
|
|
||||||
return sound;
|
|
||||||
}
|
|
||||||
|
|
||||||
JA_Sound_t *JA_LoadSound(const char* filename) {
|
|
||||||
JA_Sound_t *sound = new JA_Sound_t();
|
|
||||||
SDL_AudioSpec wavSpec;
|
|
||||||
SDL_LoadWAV(filename, &wavSpec, &sound->buffer, &sound->length);
|
|
||||||
|
|
||||||
SDL_AudioCVT cvt;
|
|
||||||
SDL_BuildAudioCVT(&cvt, wavSpec.format, wavSpec.channels, wavSpec.freq, JA_format, JA_channels, JA_freq);
|
|
||||||
cvt.len = sound->length;
|
|
||||||
cvt.buf = (Uint8 *) SDL_malloc(cvt.len * cvt.len_mult);
|
|
||||||
SDL_memcpy(cvt.buf, sound->buffer, sound->length);
|
|
||||||
SDL_ConvertAudio(&cvt);
|
|
||||||
SDL_FreeWAV(sound->buffer);
|
|
||||||
sound->buffer = cvt.buf;
|
|
||||||
sound->length = cvt.len_cvt;
|
|
||||||
|
|
||||||
return sound;
|
|
||||||
}
|
|
||||||
|
|
||||||
int JA_PlaySound(JA_Sound_t *sound, const int loop) {
|
|
||||||
int channel = 0;
|
|
||||||
while (channel < JA_MAX_SIMULTANEOUS_CHANNELS && channels[channel].state != JA_CHANNEL_FREE) { channel++; }
|
|
||||||
if (channel == JA_MAX_SIMULTANEOUS_CHANNELS) channel = 0;
|
|
||||||
|
|
||||||
channels[channel].sound = sound;
|
|
||||||
channels[channel].times = loop;
|
|
||||||
channels[channel].pos = 0;
|
|
||||||
channels[channel].state = JA_CHANNEL_PLAYING;
|
|
||||||
return channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void JA_DeleteSound(JA_Sound_t *sound) {
|
|
||||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
|
||||||
if (channels[i].sound == sound) JA_StopChannel(i);
|
|
||||||
}
|
|
||||||
SDL_free(sound->buffer);
|
|
||||||
delete sound;
|
|
||||||
}
|
|
||||||
|
|
||||||
void JA_PauseChannel(const int channel) {
|
|
||||||
if (channel == -1) {
|
|
||||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
|
||||||
if (channels[i].state == JA_CHANNEL_PLAYING) channels[i].state = JA_CHANNEL_PAUSED;
|
|
||||||
}
|
|
||||||
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) {
|
|
||||||
if (channels[channel].state == JA_CHANNEL_PLAYING) channels[channel].state = JA_CHANNEL_PAUSED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void JA_ResumeChannel(const int channel) {
|
|
||||||
if (channel == -1) {
|
|
||||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
|
||||||
if (channels[i].state == JA_CHANNEL_PAUSED) channels[i].state = JA_CHANNEL_PLAYING;
|
|
||||||
}
|
|
||||||
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) {
|
|
||||||
if (channels[channel].state == JA_CHANNEL_PAUSED) channels[channel].state = JA_CHANNEL_PLAYING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void JA_StopChannel(const int channel) {
|
|
||||||
if (channel == -1) {
|
|
||||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
|
||||||
channels[i].state = JA_CHANNEL_FREE;
|
|
||||||
channels[i].pos = 0;
|
|
||||||
channels[i].sound = NULL;
|
|
||||||
}
|
|
||||||
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) {
|
|
||||||
channels[channel].state = JA_CHANNEL_FREE;
|
|
||||||
channels[channel].pos = 0;
|
|
||||||
channels[channel].sound = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JA_Channel_state JA_GetChannelState(const int channel) {
|
|
||||||
if (channel < 0 || channel >= JA_MAX_SIMULTANEOUS_CHANNELS) return JA_CHANNEL_INVALID;
|
|
||||||
return channels[channel].state;
|
|
||||||
}
|
|
||||||
|
|
||||||
int JA_SetVolume(int volume) {
|
|
||||||
JA_volume = volume > 128 ? 128 : volume < 0 ? 0 : volume;
|
|
||||||
return JA_volume;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
|
|
||||||
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 };
|
|
||||||
|
|
||||||
struct JA_Sound_t;
|
|
||||||
struct JA_Music_t;
|
|
||||||
|
|
||||||
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels);
|
|
||||||
void JA_Quit();
|
|
||||||
|
|
||||||
JA_Music_t *JA_LoadMusic(const char* filename);
|
|
||||||
void JA_PlayMusic(JA_Music_t *music, const int loop = -1);
|
|
||||||
void JA_PauseMusic();
|
|
||||||
void JA_ResumeMusic();
|
|
||||||
void JA_StopMusic();
|
|
||||||
JA_Music_state JA_GetMusicState();
|
|
||||||
void JA_DeleteMusic(JA_Music_t *music);
|
|
||||||
|
|
||||||
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length);
|
|
||||||
JA_Sound_t *JA_LoadSound(const char* filename);
|
|
||||||
int JA_PlaySound(JA_Sound_t *sound, const int loop = 0);
|
|
||||||
void JA_PauseChannel(const int channel);
|
|
||||||
void JA_ResumeChannel(const int channel);
|
|
||||||
void JA_StopChannel(const int channel);
|
|
||||||
JA_Channel_state JA_GetChannelState(const int channel);
|
|
||||||
void JA_DeleteSound(JA_Sound_t *sound);
|
|
||||||
|
|
||||||
int JA_SetVolume(int volume);
|
|
||||||