Compare commits

220 Commits

Author SHA1 Message Date
8941072357 Els items reboten al tocar el piso 2024-11-20 21:55:55 +01:00
77bf1d73b3 Afegits els grafics de caure derrotat per al segon jugador 2024-11-19 19:30:30 +01:00
700d3846fb Afegits rebots en la animació de morir 2024-11-19 18:59:35 +01:00
185a1b47d1 Afegida llengua fora i ulls en X a la animació de derrotat 2024-11-19 18:59:22 +01:00
121774e460 Nova animació de jugador derrotat 2024-11-19 18:33:52 +01:00
47e468034f Nova animació per a la mort del personatge
Nova lògica al morir
2024-11-17 08:43:24 +01:00
da74b8dfce La powerball ja no mata
La powerball no pillava la rotació si es creava amb el rellotge actiu
2024-11-16 12:45:58 +01:00
065336c310 Els globos fills ja no ixen centrats al pare, si no al final havia varios apilats 2024-11-16 12:24:20 +01:00
79d25fb812 Nous grafics per a la powerball
Nou comportament per a la powerball
2024-11-16 12:13:00 +01:00
6262b5814d Arreglos varios relacionats amb el nom al obtenir la màxima puntuació:
No canviava al marcador, ni el nom del que tenia la maxima puntuació en calent ni al posar nom
retallat el nom de 8 a 6 caracters, i tots en majuscula pa que capia en el marcador
ja actualitza be la cadena amb el nom al posar nom per segona vegada en la mateixa partida
2024-11-08 20:49:07 +01:00
f9520185a2 Acabat BalloonManager 2024-11-08 18:29:08 +01:00
2fb7e88e4b Continue amb BalloonManager 2024-11-07 20:56:56 +01:00
0e527ff9d9 Au, a dormir que tinc son 2024-11-06 22:22:35 +01:00
d902bb9088 canvi de pc 2024-11-06 17:22:16 +01:00
caf04e3a7e Treballant en BalloonManager 2024-11-05 22:06:15 +01:00
12213a3dab Toooooornem a commitaaaar, aci vinga jugar al ping pong entre windows i macos i el puto copilot. Apanye aci i trenque allà 2024-11-05 17:54:23 +01:00
1f2a8ae38d Canvis en CMakeLists.txt 2024-11-05 17:38:26 +01:00
aa8d3502e2 Actualitzat make i cmake 2024-11-05 16:51:41 +01:00
e445a0b218 CMakeLists.txt crea el executable en la arrel del projecte 2024-11-05 13:13:43 +01:00
3f9c4b887f Apareixia brossa en la textura al crear un text i no netejarla primer (en el windows de la faena) 2024-11-05 13:06:32 +01:00
27ccae6132 Refet CMakeLists.txt 2024-11-05 13:05:52 +01:00
443f0f3254 Añadido CMakeLists.txt 2024-11-05 07:15:54 +01:00
2e62214a4b Canviat un #include <bits/chrono.h> per #include <chrono> 2024-11-04 22:26:31 +01:00
7b1c2a6005 Nova font de text per al text gran amb el doble de definició 2024-11-04 20:28:19 +01:00
2256ee46eb Modificada la paleta verda del primer jugador per a fer la mes pareguda a la del coffee crisis original 2024-11-04 19:39:27 +01:00
087fd3377c fix: els globos verds, al popparlos, uno tirava cap avall el molt cabró 2024-11-04 19:16:44 +01:00
30735f00e8 Els objectes de Text es precarreguen al inici 2024-11-04 19:08:18 +01:00
e0e82ee273 Retocs en Texture::loadPaletteFromFile 2024-11-03 20:43:52 +01:00
371c477d0d Varios arreglos 2024-11-03 20:28:01 +01:00
f29eb2f411 Les notificacions ara accepten un vector de cadenes en lloc de una o dos cadenes 2024-11-03 18:12:46 +01:00
69a92cba66 Apanyats alguns bugs que quedaven respecte a lo del teclat 2024-11-03 17:25:31 +01:00
86cd7b0f16 Ja es pot gastar el teclat com a control independent del primer mando
Ja pot jugar un jugador amb teclat i altre amb mando
Es pot asignar el teclat a qualsevol dels dos jugadors
Continua podentse gastar mando i teclat a l'hora per al mateix jugador
2024-11-03 11:07:58 +01:00
a1ccb6102a Abans de clavar-li ma a Input 2024-11-01 20:01:17 +01:00
2dd8bbbbf7 Moguts els checkInputs de Screen a GlobalInputs 2024-11-01 19:07:19 +01:00
c66cc965f1 define_buttons ja acaba be de definir els buttons 2024-11-01 18:39:10 +01:00
0757f63b73 Eliminat checkModInput 2024-11-01 18:20:18 +01:00
80a110e1d7 Abans de llevar checkInputMod 2024-11-01 16:48:03 +01:00
cd68c5ffea Al redefinir botons, ja no pots repetir botó. Util per als qui tenim la ma tremolosa i apretem dos voltes sense voler 2024-11-01 14:32:27 +01:00
f786cb7776 Implementat el final del joc 2024-11-01 13:05:11 +01:00
2e0d27a95c Modificats parámetres 2024-11-01 12:56:09 +01:00
861a9411d3 Nous textos 2024-11-01 12:55:37 +01:00
da27fde366 Millores en la gestió del "mute" en el joc 2024-11-01 07:55:37 +01:00
c6e2368e82 Noves animacions per a deixar de disparar 2024-10-31 23:32:11 +01:00
30dfa4c545 Treballant en el final del joc 2024-10-31 11:58:01 +01:00
7e2691e33e Finalitzat el Attract Mode 2024-10-30 21:29:23 +01:00
7e918e99f7 Arreglat un include 2024-10-30 13:15:30 +01:00
2aa3f827cb Arreglada la animació de morir, que s'updatava dos voltes per frame 2024-10-30 10:15:53 +01:00
06899d95a8 Arreglat el efecte de flash. Estava passant-li un valor massa xicotet 2024-10-30 09:45:57 +01:00
20c51d0796 Acabat el nou motor per a textos en pantalla 2024-10-30 09:25:28 +01:00
b43782786a Modificades les linux_utils 2024-10-30 09:25:12 +01:00
15554c449f Nuevos textos para el game_text 2024-10-30 08:19:32 +01:00
ba05eab79e Reduida la dependencia de PathSprite a Sprite
Treballant en els missatges de text que ixen durant la partida
2024-10-29 20:05:05 +01:00
d83c05bad4 El game_text dels items ja son textures generades i precarregades 2024-10-29 16:04:14 +01:00
e2abf835f9 Afegida nova tipografia 04b_25
Eliminades tipografies que no s'utilitzaven
La classe Text ara pot tornar una textura amb el text
2024-10-29 15:22:19 +01:00
59e2865a4a El game_text ara gasta PathSprites en lloc d'SmartSprites
fix: la paleta dels jugadors no s'iniciava correctament
2024-10-28 22:09:28 +01:00
787cb6366f Pasaeta de include-what-you-use
Acabada de perfilar la classe PathSprite
Menjeades declaracions de utils.h als fitxers que toca
2024-10-28 20:45:24 +01:00
0fe371653a commit de me ane cap a casa 2024-10-28 13:51:26 +01:00
2cffe8dfc9 Merge branch 'main' of https://gitea.sustancia.synology.me/JailDesigner/coffee_crisis_arcade_edition 2024-10-27 22:28:47 +01:00
1dd96cfaff Completada la classe PathSprite 2024-10-27 22:28:44 +01:00
d054e188b6 fix: alguns minibugs tontos 2024-10-27 19:04:05 +01:00
ca6ff71a46 Actualitzat README.MD 2024-10-27 18:46:42 +01:00
b90ac65cfc Eliminats warnings que nomes es veuen al compilar en macos/linux 2024-10-27 17:45:49 +01:00
759adbf6fd Actualitzat README.MD 2024-10-27 17:09:40 +01:00
71f76fda05 Redissenyat el time stopper 2024-10-27 13:36:00 +01:00
ddfb3672ea Afegida la funció createTwoBigBalloons() per a que la partida sempre comence igual 2024-10-26 18:16:23 +02:00
6235d0b684 Revisada la classe Balloon 2024-10-26 18:08:04 +02:00
f750997b34 Revisant la classe Balloon 2024-10-26 14:13:08 +02:00
de2a29b669 Ajustado el game_text para que se dibuje siempre en pantalla, sin clipping 2024-10-26 12:23:04 +02:00
f99f908c11 Revisant la classe Balloon 2024-10-26 11:38:08 +02:00
d44bfd51de Balloon: inicialitzades variables en la declaració 2024-10-26 09:09:19 +02:00
4f095ab018 Repasada la classe Bullet 2024-10-26 09:01:32 +02:00
bffd2bdace . 2024-10-26 08:11:30 +02:00
24d09a2e3c Millorada la aparició dels game_text 2024-10-24 22:16:57 +02:00
caf191672e Posat ordre en el constructor de Game 2024-10-24 22:08:53 +02:00
43e7b83403 Continue arreglant cosetes amb cppcheck 2024-10-24 20:36:30 +02:00
a5c72a0f65 Collons, que m'havien stagejat no se que.. ara si, arreglada la carrega d'animacions 2024-10-24 19:58:45 +02:00
ca464b2e81 Arreglada la cárrega d'animacions 2024-10-24 19:58:25 +02:00
f26ecbd969 Canviat el final de linea als scripts de linux 2024-10-24 18:14:33 +02:00
018bb68f9a Canviat el nom de la carpeta a linux_utils 2024-10-24 17:59:50 +02:00
f36ff3d7fe Actualitzats scripts de linux_utils 2024-10-24 17:53:24 +02:00
8f33308f8d . 2024-10-24 14:03:12 +02:00
8c98430b68 . 2024-10-23 22:18:46 +02:00
6e2f80d8ce . 2024-10-23 18:29:52 +02:00
95478134dd Merdetes en la faena, básicament arreglar uns quants iniciadors de variables en les clases 2024-10-23 14:00:19 +02:00
528533fd9b Au, a casa 2024-10-22 13:56:50 +02:00
5df85e1b1a Pasaeta de cppcheck, ale 2024-10-22 09:24:19 +02:00
1d0c2e01a5 Varios arreglos d'estil en el codi i llevar metodes que ja no servien 2024-10-21 22:47:00 +02:00
236d6f58b6 Nous gràfics per al game_text 2024-10-21 19:29:54 +02:00
898b551e06 Paletes noves per al primer café dels jugadors 2024-10-21 18:09:34 +02:00
84238032e0 Afegits uns overrides pa agafar parametres per linea de comandos 2024-10-21 17:46:05 +02:00
2cb22ed013 fix: els globos tenien un parell de setters mal asignats per culpa de buscar y reemplazar
fix: els globos verds s'inicialitzaven amb vy = 0 per gastar abs en lloc de fabs
fix: corregit un bug milenari que de sempre havia creat els balloons verds al popar al pare amb la meitat de velocitat en y. Lo que jo no se es com anava res. Supose que ara el joc serà un poc mes xungo. Quan rebotaven en el piso ja se'ls posava la velocitat bona (crec)
2024-10-20 22:58:15 +02:00
a3a583deb7 Precàrrega dels fitxers amb dades per al mode demostració 2024-10-20 21:23:04 +02:00
b263e0c4be Modificada la estructura on es guarden els datos de la demo 2024-10-20 20:43:03 +02:00
3bf61fc758 fix: no guardar el fitxer de puntuacions en el modo demo 2024-10-20 19:40:09 +02:00
2377815c02 Amb les textures en memoria i compartides ja no puc fer el trick de canvi de paleta per a la flama del segon jugador tal i com està plantejat el codi. Arreglat creant una segona textura 2024-10-20 19:38:28 +02:00
7434869894 Corregit un fallo amagat baix un ifdef ARCADE. Ja he posat que estiga definit per defecte pa que no torne a passar 2024-10-20 15:43:10 +02:00
848d61b5c0 He fet un "manolete" i he pasat a c++ i smartpointers la cárrega de surfaces desde gif. Sembla que no ha petat res
Precárrega i asignació de paletes a les textures
Ara si algú toca una paleta, que siga conscient que la textura es compartida durant tot el joc
2024-10-20 15:36:04 +02:00
cbc9b3f071 Eliminats els últimes defines i passats a enum class 2024-10-20 12:07:55 +02:00
8bca5095da Modificats, estructurats i ben formatats alguns missatges de consola
Canvis en els codis d'eixida del programa
2024-10-20 11:37:26 +02:00
a4b4e188cd Precàrrega de tots els recursos al inici del joc
8.000.000 de cherrypickings que he anat fent pel codi
2024-10-20 11:06:10 +02:00
f23dcae5b6 Creada la classe Resource
Afegida la musica i els sons a Resource
2024-10-19 10:07:14 +02:00
b879673bc2 Mes merdes que faltaven del merge 2024-10-18 17:10:06 +02:00
a8701dbebc Merge branch 'main' of https://gitea.sustancia.synology.me/JailDesigner/coffee_crisis_arcade_edition 2024-10-18 16:53:53 +02:00
afe835914e Revisada la carrega de recursos en game.cpp 2024-10-18 14:07:25 +02:00
808f1595e9 Treballant en la càrrega de animacions desde fitxers 2024-10-17 21:02:28 +02:00
8e8346b2ab Li he demanat a la IA que revente Game::checkInput() que aixo si que era un monstruo amb sombreret i pajarita 2024-10-17 20:05:26 +02:00
1da8f33a5e Llevats tots els ifdef VERBOSE i redirigit cout a null_stream 2024-10-17 19:31:44 +02:00
50a376e582 Comença a estar tot mes o menos be el desaguisao de les classes Sprite. Encara algunes animacions sembla que van massa ràpides 2024-10-17 19:26:39 +02:00
59de566c5b commit de acabar la jornada laboral 2024-10-17 13:57:41 +02:00
db884cb422 Commit de vesprà tirada a la brossa 2024-10-16 22:35:19 +02:00
5585f996cb A vore si el helper ja funciona com toca 2024-10-16 13:29:16 +02:00
24556eeaa8 Implementat contador per a posar el nom al acabar la partida 2024-10-16 09:18:22 +02:00
dbffda491f Retocat l'aspecte visual de les notificacions 2024-10-15 22:56:24 +02:00
53f5f3f8b0 Ja comprova la notificació d'eixir per diferenciarla de la resta
En ARCADE la notificació diferencia si vas a eixir o a apagar el sistema
2024-10-15 20:40:45 +02:00
e0faa0890e Afegides noves cadenes de text 2024-10-15 20:12:16 +02:00
de6508c37c Don Melitonitzada la classe Notifier e independitzada de la classe Screen
Ara es poden afegir codis a les notificacions per identificarles
2024-10-15 20:09:09 +02:00
e99c2c5265 fix: faltava el nom de la classe en shutdownSystem() 2024-10-15 18:58:10 +02:00
942924c65c Afegit codi per apagar el sistema al eixir del joc 2024-10-15 18:24:19 +02:00
089da99b5b Afegida la funció getNewPosition a la classe Screen per a respectar la posició de la finestra al canviarla de tamany 2024-10-15 18:12:16 +02:00
3fdd60c9e2 Treballant en els game_texts 2024-10-15 14:02:37 +02:00
3b9885ab03 Commit de Boromir 2024-10-14 22:33:45 +02:00
39a8c992e1 Ja duplica la ultima lletra al posar el nom 2024-10-14 17:12:07 +02:00
9825c7fb9b Pasaeta de include-what-you-use 2024-10-13 21:58:36 +02:00
d0a6e4c572 Afegits destructors virtuals en les classes Sprite 2024-10-13 21:23:15 +02:00
7c876e1d4d Acabat amb cppcheck
Arreglades les herencies de les classes Sprite
2024-10-13 21:00:33 +02:00
809c10048e Commit pa poder tornar a passar el cppcheck 2024-10-13 19:39:43 +02:00
babf02226c Mes recomanacions de cppcheck 2024-10-13 19:26:27 +02:00
46540ad7c3 Optimitzat el tema de comparacions i asignacions de strings buits. Mes que optimitzat, ara està mes mono 2024-10-13 14:25:05 +02:00
ba7c44ad06 Actualitzat Makefile 2024-10-13 14:24:15 +02:00
46b19ee82f Mes recomanacions de cppcheck aplicades
Abans de tocar unes cosetes de strings buits
2024-10-13 13:49:00 +02:00
b2122ac239 Eliminats fitxers que s'havien colat 2024-10-13 11:04:50 +02:00
c11a868289 Afegides recomanacions de cppcheck
Optimitzada la funció updateBalloonSpeed() i eliminades funcions sobrants o redundants
2024-10-13 11:03:50 +02:00
22d457285d Modificat .gitignore 2024-10-13 11:03:00 +02:00
b060f21696 Arreglades les herencies de Sprite
Abans de llevar mil coses que sobren i replantejar-se estes 4 classes
2024-10-13 10:01:07 +02:00
33ea8d90ca Acabat de renamar, encara que he descobert cosetes i tindré que fer altra pasaeta
Actualitzat stb_image.h a la última versió
2024-10-12 22:25:43 +02:00
cce14dba4d Mes renames. Mes ordre. 2024-10-12 12:03:19 +02:00
101e375fd3 Variables renombrades en input.cpp 2024-10-12 11:01:42 +02:00
4ef759772a game.cpp renombrat 2024-10-12 09:15:20 +02:00
07714aabc3 Abans de renombrar game.cpp 2024-10-12 07:26:41 +02:00
d50cf23721 Abans de renombrar player.cpp 2024-10-11 21:58:59 +02:00
3a6950f3a4 Menudo puto lio de renamar coses, a vore si tot va quedant al lloc que els structs i els enums estan revolant i duplicats per tots llocs 2024-10-11 20:12:50 +02:00
a9ca23138d Continuem estandaritzant noms 2024-10-11 13:54:43 +02:00
e1fa1d2102 Canviades certes opcions a parametres i afegides noves opcions 2024-10-11 09:03:57 +02:00
117b80bdfc idem 2024-10-10 20:59:39 +02:00
d6c3c89872 Estandaritzant noms segons convencions 2024-10-10 20:27:31 +02:00
9e5f41644e Açò ja no hi ha Cristo que ho pete 2024-10-10 13:48:53 +02:00
fc8fdc5fe5 Llevats uns punterets que sobraven en director.cpp 2024-10-10 09:23:16 +02:00
6fe294c59d Pos ja compila pero no es veu una puta merda ... 2024-10-10 08:06:36 +02:00
3fa5b227ae commit de anar a dormir 2024-10-09 23:01:44 +02:00
f2fa216b0d Commit pa que Mon arregle el codi mentre em dutxe 2024-10-09 21:48:01 +02:00
3c1dcad3ab Commit de anar al llit amb el portatil 2024-10-08 23:15:55 +02:00
bd3aa0bb06 Arreglos varios al codi 2024-10-08 22:38:58 +02:00
3e3d764b25 Commitet pa gastar el Cppcheck 2024-10-08 20:32:24 +02:00
c00f4326ae Commit de "guardar partida" 2024-10-08 18:07:54 +02:00
9ce0f16d33 Arreglats els constructors de Text 2024-10-08 18:07:44 +02:00
06a4f439c1 Posant make_uniques, s'ha quedat tot enmerdat per culpa d'un struct 2024-10-08 13:53:24 +02:00
9d41d14d68 Actualitzats els scripts de valgrind 2024-10-07 20:11:08 +02:00
0d0e49316f Afegit scripts a linux-utils 2024-10-07 18:44:18 +02:00
bf945ef14b Corregits 8.000.000 de segmentation faults en intro.cpp 2024-10-07 18:37:08 +02:00
0330fe6b74 Make uniques en intro.cpp 2024-10-07 17:28:34 +02:00
6305a67c84 Actualitzat .gitignore 2024-10-07 17:28:22 +02:00
5f18189269 Actualizado Makefile 2024-10-07 12:32:53 +02:00
7ebefd7b54 Les enum class passen a estar totes amb la inicial en majuscula 2024-10-07 12:30:46 +02:00
cffa4c3c92 Commitet pa valgrind, he aprofitat i posat mes make_unique i enum class 2024-10-07 10:49:29 +02:00
4f0ea9dcf2 Make_unique en title.cpp 2024-10-07 08:22:51 +02:00
b1f936a791 Pasaeta de include-what-you-use abans que es desmadre tot 2024-10-06 22:43:28 +02:00
1c0554d4df Actualitzat script check-includes.sh 2024-10-06 22:43:00 +02:00
8ba77d7d5d Demanada ajuda a la IA pa que m'arregle un poc la meua merda: Para optimizar este código y evitar duplicar la lógica para cada jugador, podemos extraer el código común en una función reutilizable. Así, reducimos la repetición y mejoramos la legibilidad. 2024-10-06 21:07:26 +02:00
6515ec6c7b Els panels dels marcadors ja passen a game over sense pasar per waiting un frame gracies a una parafernalia que he montat 2024-10-06 21:02:49 +02:00
b979c0f2b8 Mes textos 2024-10-06 21:02:12 +02:00
a95e5077e3 Els panels del marcador ara canvien de mode a petició i no a cada frame 2024-10-06 20:19:43 +02:00
6ea6f85e3e Nous textos 2024-10-06 20:14:37 +02:00
fe6e63e39f fix: la classe Screen ja ha recuperat un poc del lustro que tenia
shake effect ja no està fet "the torerous menner"
shake effect ja va amb shaders
2024-10-06 18:57:47 +02:00
afe092c742 Muntat a c++14 per a make_unique
Mes autos, const i constexpr perl codi
Ara la classe Screen es un poc pitjor
2024-10-06 14:58:00 +02:00
25a2753b13 Canviats defines per constexpr i enum class
Canviats punters a unique_ptr
Afegit const a alguns metodes de classse
fix: el segon jugador no podia unirse a la partida
new: Quan els dos jugadors han decidit no continuar, ja no poden continuar i el marcador així ho reflectix
fix: al posar el nom per segona vegada en la mateixa partida, no es reseteja la posició del selector
fix: el fade venetian no netejava la textura i de vegades eixien gràfics corruptes
fix: ara grava a disco cada vegada que es posa nom al morir
2024-10-05 23:53:42 +02:00
ee721ff573 debug 2024-10-03 19:35:58 +02:00
c07fd62037 Corregit bug en el text a l'hora d'intercanviar els mandos. Apareixia el nom del mando que te guardat a la configuració pero no estava connectat 2024-10-03 19:26:32 +02:00
fb74733f2c Correcció de textos 2024-10-03 18:16:20 +02:00
468bd0950c Modificat controllers.png 2024-10-03 18:13:48 +02:00
938e4ad011 La targeta d'ajuda ja ix amb els mandos i s'ha de deixar apretat el botó 2024-10-03 17:37:33 +02:00
71bd3bed52 Eliminades variables sobrants en director.cpp 2024-10-03 17:02:40 +02:00
5ebc58dd01 La tarjeta d'ajuda ja entra i ix amb animacions suavitzades 2024-10-02 18:03:20 +02:00
9b3e549876 Añadidas funciones de suavizado a utils.cpp 2024-10-02 18:00:21 +02:00
abc8a0b632 La tarjeta d'ajuda ix pero no s'amaga 2024-10-02 13:56:43 +02:00
3a84ea792c Ja dibuixa la tarjeta amb la ajuda per als botons de servei 2024-10-01 20:58:05 +02:00
3cabd5c675 Nous textos 2024-10-01 19:07:25 +02:00
2ec242b2c9 Afegit esqueleto per a la classe OnScreenHelp 2024-10-01 18:34:26 +02:00
d993a6def4 Afegit formato Allman a bullet.cpp 2024-10-01 18:16:08 +02:00
5913d7548a Modificat el temps posterior d'aparició de la Powerball 2024-10-01 18:15:42 +02:00
84f3952232 Afegit controllers.png 2024-10-01 18:15:11 +02:00
7dbddd5524 Afegides utilitats per a linux
Arreglats alguns includes
2024-10-01 17:24:38 +02:00
dee5bcb4e4 Canviada la classe bullet per la de chatGPT, aixina demà ho mire amb calma 2024-09-30 23:06:16 +02:00
af1c1051e6 Afegides implementacions (fora del codi) que ha fet chatGPT de la classe bullet 2024-09-30 20:28:20 +02:00
aaf6dc29a1 El joc ja no comença al pulsar la combinació de botons per eixir 2024-09-30 19:45:04 +02:00
0af441b5df Finalitzada la part de entrar nom. Falta posar un temporitzador i una animació 2024-09-30 19:35:41 +02:00
6acf0b7efc Modificada la posició de PULSA PER JUGAR al titol 2024-09-30 19:35:00 +02:00
e033fc8015 Canviat el missatge d'eixida del joc 2024-09-30 18:47:12 +02:00
2d5859b1c4 Ja es pot "enner llour neim". Falta decidir quin de tots els dissenys m'agrada mes 2024-09-29 22:25:31 +02:00
edc45b6cec Afegides funcions per oscurir o aclarir colors 2024-09-29 19:35:33 +02:00
fad6cddfb6 Nous textos 2024-09-29 17:06:26 +02:00
8ce09d1355 Acomodats els estats del jugador
El compte enrrere per a continuar ara ix al acabar la animació de morir
Afegit el estat "entering_name"
2024-09-29 10:40:35 +02:00
945eaa68e7 Actualizado Makefile 2024-09-29 08:01:47 +02:00
28df97ea94 Pasaeta de "include-what-you-use" per arreglar els includes
Renombrats alguns fitxers per consistencia
2024-09-29 06:24:11 +02:00
ac3340c39f Eliminat tots els options.console 2024-09-28 18:02:09 +02:00
4febe8b7c0 Afegit global_inputs.c
El audio no es podía mutejar amb el teclat, soles amb els mandos
2024-09-28 17:08:09 +02:00
289d01b0fa fix: no estava comprobantse el reset amb el teclat 2024-09-28 14:23:51 +02:00
2767696a3f Singletonejada la classe Input 2024-09-28 14:19:00 +02:00
fa82758ce1 Don melitonada la classe Asset 2024-09-28 13:49:00 +02:00
878518babe Eliminades les icones de les notificacions (herencia del CC original) 2024-09-28 12:46:53 +02:00
3f24f38a0c Reestructurada la carpeta gfx 2024-09-28 12:37:52 +02:00
1f6dfe5d92 Faltava un pixel d'altura en logo_jailgames_mini.png 2024-09-28 12:25:26 +02:00
92f7f540c0 Classe Screen melitonada 2024-09-28 11:11:11 +02:00
f2cc0dc352 Eliminat "const.h" 2024-09-28 10:16:35 +02:00
8d263931b2 Eliminat el punter a "section" 2024-09-28 09:28:22 +02:00
0a8d0479a0 Estandaritzats els accessos a fitxers 2024-09-27 19:41:45 +02:00
20de9e4b72 Un altre punteret a pendre per cul: options 2024-09-27 19:00:09 +02:00
0de9188547 Reballats tots els .h i .cpp en la mateixa carpeta 2024-09-27 17:57:00 +02:00
9d7e975952 Actualitzat Makefile 2024-09-27 17:56:45 +02:00
46b41757b2 Convertit "param" a variable global en lloc de anar marejant amb punterets i passant 8.000.000 de paràmetres 2024-09-27 17:42:25 +02:00
c1bf0b8aed Estandarizados los colores en hexadecimal 2024-09-27 16:52:26 +02:00
228 changed files with 18631 additions and 18724 deletions

2
.gitignore vendored
View File

@@ -14,3 +14,5 @@ thumbs.db
*config.bin
*score.bin
coffee_crisis*
debug.txt
cppcheck-result*

85
CMakeLists.txt Normal file
View File

@@ -0,0 +1,85 @@
# CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(coffee_crisis_arcade_edition VERSION 0.01)
# 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()

102
Makefile
View File

@@ -24,18 +24,18 @@ INCLUDES:= -I$(DIR_SOURCES)
# Variables según el sistema operativo
ifeq ($(OS),Windows_NT)
FixPath = $(subst /,\,$1)
SOURCES := source/*.cpp source/common/*.cpp
CXXFLAGS:= -std=c++11 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows
CXXFLAGS_DEBUG:= -std=c++11 -Wall
SOURCES := source/*.cpp
CXXFLAGS:= -std=c++20 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows
CXXFLAGS_DEBUG:= -std=c++20 -Wall -g
LDFLAGS := -lmingw32 -lws2_32 -lSDL2main -lSDL2 -lopengl32
RM = del /Q
MKD:= mkdir
else
FixPath = $1
SOURCES := $(shell find $(DIR_SOURCES) -name '*.cpp')
SOURCES := source/*.cpp source/common/*.cpp
CXXFLAGS:= -std=c++11 -Wall -Os -ffunction-sections -fdata-sections
CXXFLAGS_DEBUG:= -std=c++11 -Wall
SOURCES := source/*.cpp
CXXFLAGS:= -std=c++20 -Wall -Os -ffunction-sections -fdata-sections
CXXFLAGS_DEBUG:= -std=c++20 -Wall -g
LDFLAGS := -lSDL2
RM = rm -f
MKD:= mkdir -p
@@ -50,84 +50,7 @@ else
endif
endif
OBJECTS := $(subst $(DIR_SOURCES), $(DIR_BUILD), $(SOURCES))
OBJECTS := $(OBJECTS:.cpp=.o)
DEPENDENCIES:= $(OBJECTS:.o=.d)
###############################################################################
# #
# RULES #
# #
###############################################################################
.PHONY: all a1
all: a1
a1: $(TARGET_FILE)
$(TARGET_FILE): $(OBJECTS)
$(MKD) $(@D)
$(CXX) $(OBJECTS) $(LDFLAGS) -o $(TARGET_FILE)
$(DIR_BUILD)%.o: $(DIR_SOURCES)%.cpp
$(MKD) $(@D)
$(CXX) -c $< $(CXXFLAGS) $(INCLUDES) -o $@
-include $(DEPENDENCIES)
###############################################################################
# #
# CLEAN #
# #
###############################################################################
.PHONY: clean
clean:
$(RM) $(call FixPath,$(DIR_BUILD))
###############################################################################
# #
# PRINT-VARIABLES #
# #
###############################################################################
.PHONY: print-variables
print-variables:
@echo MAKEFILE_LIST: $(MAKEFILE_LIST)
@echo "DIR_ROOT :" $(DIR_ROOT)
@echo "DIR_SOURCES:" $(DIR_SOURCES)
@echo "DIR_BIN :" $(DIR_BIN)
@echo "DIR_BUILD :" $(DIR_BUILD)
@echo "DIR_IMGUI :" $(DIR_IMGUI)
@echo "DIR_IMGUI_SFML:" $(DIR_IMGUI_SFML)
@echo "INCLUDES :" $(INCLUDES)
@echo CXX: $(CXX)
@echo CXXFLAGS: $(CXXFLAGS)
@echo LDFLAGS: $(LDFLAGS)
@echo SOURCES: $(SOURCES)
@echo OBJECTS: $(OBJECTS)
@echo DEPENDENCIES: $(DEPENDENCIES)
@echo TARGET_NAME: $(TARGET_NAME)
@echo TARGET_FILE: $(TARGET_FILE)
@echo RM: $(RM)
raspi:
$(CXX) $(SOURCES) -D ARCADE -D VERBOSE $(CXXFLAGS) $(LDFLAGS) -o $(TARGET_FILE)
strip -s -R .comment -R .gnu.version $(TARGET_FILE) --strip-unneeded
raspi_debug:
$(CXX) $(SOURCES) -D ARCADE -D VERBOSE -D DEBUG $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
# Rules
windows:
@echo off
$(CXX) $(SOURCES) $(CXXFLAGS) $(LDFLAGS) -o "$(TARGET_FILE).exe"
@@ -249,6 +172,13 @@ linux_release:
# Elimina la carpeta temporal
$(RM) "$(RELEASE_FOLDER)"
raspi:
$(CXX) $(SOURCES) -D ARCADE -D VERBOSE $(CXXFLAGS) $(LDFLAGS) -o $(TARGET_FILE)
strip -s -R .comment -R .gnu.version $(TARGET_FILE) --strip-unneeded
raspi_debug:
$(CXX) $(SOURCES) -D ARCADE -D VERBOSE -D DEBUG $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
anbernic:
# Elimina carpetas previas
$(RM) "$(RELEASE_FOLDER)"_anbernic
@@ -259,5 +189,5 @@ anbernic:
# Copia ficheros
cp -R data "$(RELEASE_FOLDER)"_anbernic
# Complia
$(CXX) $(SOURCES) -D ANBERNIC -D NO_SHADERS -D ARCADE -D VERBOSE $(CXXFLAGS) $(LDFLAGS) -o $(RELEASE_FOLDER)_anbernic/$(TARGET_NAME).game
# Compila
$(CXX) $(SOURCES) -D ANBERNIC -D NO_SHADERS -D ARCADE -D VERBOSE $(CXXFLAGS) $(LDFLAGS) -o $(RELEASE_FOLDER)_anbernic/$(TARGET_NAME)

View File

@@ -1,67 +1,39 @@
# Coffee Crisis
# Coffee Crisis Arcade Edition
Coffee Crisis es un juego arcade que pondrá a prueba tus reflejos. Empezado durante el verano de 2020 y terminado un año despues, en el verano de 2021. Intenta conseguir todos los puntos que puedas con una sola vida a traves de los 10 niveles de juego y ayuda a Bal1 a defender la UPV de la invasión de la cafeína esférica y saltarina.
Coffee Crisis Arcade Edition es la versió ampliada i millorada del aclamat Coffee Crisis. Preparat per a jugar sense parar amn dos jugadors, nous gràfics i moltes sorpreses mes.
![alt text](https://php.sustancia.synology.me/images/cc1.png)
<p align="center">
<img src="https://php.sustancia.synology.me/images/ccae_title.png" alt="Titol"
</p>
## Teclado
El juego se maneja con teclado, aunque tambien se puede conectar un mando de control.
Las teclas son las siguientes:
## Controls
El joc està optimitzat per a ser jugat amb un mando de jocs, encara que un dels jugadors pot utilitzar el teclat.
Les tecles son les següents:
* **Cursores**: Mover al personaje, moverse por los menus
* **Q, W, E**: Disparar a la izquierda, al centro y a la derecha respectivamente
* **ESCAPE**: Pone en pausa el juego durante la partida. Sale de los menus. Cierra el juego
* **ENTER**: Acepta las opciones en los menus
* **Fletxes**: Mou al personatge
* **Q, W, E**: Disparar a la esquerra, al centre i a la dreta respectivament
![alt text](https://php.sustancia.synology.me/images/cc2.png)
<p align="center">
<img src="https://php.sustancia.synology.me/images/ccae1.png" alt="Joc"
</p>
## Compilar
## Altres tecles
- **Tecla ESC**: Tancar el joc
Para compilar el código se necesitan tener las librerías SDL instaladas en el sistema y el compilador g++.
- **Tecla F1**: Fa la finestra mes xicoteta
En Linux:
```bash
sudo apt install libsdl2-dev g++
```
- **Tecla F2**: Fa la finestra mes gran
En macOS se pueden instalar fácilmente con [brew](https://brew.sh):
```bash
brew install sdl2 g++
```
- **Tecla F3**: Alterna entre el mode de pantalla completa i el de finestra
Una vez instaladas las librerías SDL, se puede compilar utilizando el fichero Makefile suministrado.
- **Tecla F4**: Activa o desactiva els shaders
En Linux:
```bash
make linux
```
- **Tecla F10**: Reset
En macOS:
```bash
make macos
```
![alt text](https://php.sustancia.synology.me/images/cc3.png)
<p align="center">
<img src="https://php.sustancia.synology.me/images/ccae2.png" alt="Joc"
</p>
## Como ejecutar
Para ejecutar el juego hay que escribir en la terminal la orden que se muestra a continuación.
En Linux:
```bash
./coffee_crisis_linux
```
En macOS:
```bash
./coffee_crisis_macos
```
En macOS tambien puedes hacer doble click sobre el archivo coffee_crisis_macos
## Agradecimientos
A los jailers y a la jail. Y entre ellos, a JailDoctor por estar siempre ahí apoyándonos/obligándonos a sacar un Jailgame más.
Y por supuesto a ti por estar aquí.
## Licencia
Usa el código para lo que quieras: aprender, reirte, curiosear... excepto para sacar beneficio económico. Si lo consigues, por favor avísame y vamos a medias.
## Agraiments
A chatGPT i sobretot a Copilot. Gracies per estar sempre quan vos he necesitat.

View File

@@ -1,19 +1,20 @@
## GAME
game.itemSize 20
game.width 320
game.height 240
game.playArea.rect.x 0
game.playArea.rect.y 0
game.playArea.rect.w 320
game.playArea.rect.h 200
game.item_size 20 # Tamaño de los items del juego
game.width 320 # Ancho de la resolucion nativa del juego
game.height 240 # Alto de la resolucion nativa del juego
game.play_area.rect.x 0 # Rectangulo con la posición de la zona de juego
game.play_area.rect.y 0 # Rectangulo con la posición de la zona de juego
game.play_area.rect.w 320 # Rectangulo con la posición de la zona de juego
game.play_area.rect.h 200 # Rectangulo con la posición de la zona de juego
game.enter_name_seconds 60 # Duración en segundos para introducir el nombre al finalizar la partida
## FADE
fade.numSquaresWidth 160
fade.numSquaresHeight 120
fade.randomSquaresDelay 1
fade.randomSquaresMult 500
fade.postDuration 80
fade.venetianSize 16
fade.num_squares_width 160
fade.num_squares_height 120
fade.random_squares_delay 1
fade.random_squares_mult 500
fade.post_duration 80
fade.venetian_size 16
## SCOREBOARD
scoreboard.x 0
@@ -22,23 +23,31 @@ scoreboard.w 320
scoreboard.h 40
## TITLE
title.pressStartPosition 170
title.titleDuration 800
title.arcadeEditionPosition 123
title.titleCCPosition 80
title.press_start_position 170
title.title_duration 800
title.arcade_edition_position 123
title.title_c_c_position 80
## BACKGROUND
background.attenuateColor.r 255
background.attenuateColor.g 255
background.attenuateColor.b 255
background.attenuateAlpha 0
background.attenuate_color.r 255
background.attenuate_color.g 255
background.attenuate_color.b 255
background.attenuate_alpha 0
## BALLOONS
balloon1.vel 2.75f
balloon1.grav 0.09f
balloon2.vel 3.70f
balloon2.grav 0.10f
balloon3.vel 4.70f
balloon3.grav 0.10f
balloon4.vel 5.45f
balloon4.grav 0.10f
balloon_1.vel 2.75f
balloon_1.grav 0.09f
balloon_2.vel 3.70f
balloon_2.grav 0.10f
balloon_3.vel 4.70f
balloon_3.grav 0.10f
balloon_4.vel 5.45f
balloon_4.grav 0.10f
## NOTIFICATION
notification.pos_v TOP
notification.pos_h LEFT
notification.sound false
notification.color.r 48
notification.color.g 48
notification.color.b 48

View File

@@ -1,19 +1,20 @@
## GAME
game.itemSize 20
game.width 320
game.height 256
game.playArea.rect.x 0
game.playArea.rect.y 0
game.playArea.rect.w 320
game.playArea.rect.h 216
game.item_size 20 # Tamaño de los items del juego
game.width 320 # Ancho de la resolucion nativa del juego
game.height 256 # Alto de la resolucion nativa del juego
game.play_area.rect.x 0 # Rectangulo con la posición de la zona de juego
game.play_area.rect.y 0 # Rectangulo con la posición de la zona de juego
game.play_area.rect.w 320 # Rectangulo con la posición de la zona de juego
game.play_area.rect.h 216 # Rectangulo con la posición de la zona de juego
game.enter_name_seconds 60 # Duración en segundos para introducir el nombre al finalizar la partida
## FADE
fade.numSquaresWidth 160
fade.numSquaresHeight 128
fade.randomSquaresDelay 1
fade.randomSquaresMult 500
fade.postDuration 80
fade.venetianSize 16
fade.num_squares_width 160
fade.num_squares_height 128
fade.random_squares_delay 1
fade.random_squares_mult 500
fade.post_duration 80
fade.venetian_size 16
## SCOREBOARD
scoreboard.x 0
@@ -22,23 +23,31 @@ scoreboard.w 320
scoreboard.h 40
## TITLE
title.pressStartPosition 170
title.titleDuration 800
title.arcadeEditionPosition 123
title.titleCCPosition 80
title.press_start_position 180
title.title_duration 800
title.arcade_edition_position 123
title.title_c_c_position 80
## BACKGROUND
background.attenuateColor.r 255
background.attenuateColor.g 255
background.attenuateColor.b 255
background.attenuateAlpha 0
background.attenuate_color.r 255
background.attenuate_color.g 255
background.attenuate_color.b 255
background.attenuate_alpha 0
## BALLOONS
balloon1.vel 2.75f
balloon1.grav 0.09f
balloon2.vel 3.70f
balloon2.grav 0.10f
balloon3.vel 4.70f
balloon3.grav 0.10f
balloon4.vel 5.45f
balloon4.grav 0.10f
balloon_1.vel 2.75f
balloon_1.grav 0.09f
balloon_2.vel 3.70f
balloon_2.grav 0.10f
balloon_3.vel 4.70f
balloon_3.grav 0.10f
balloon_4.vel 5.45f
balloon_4.grav 0.10f
## NOTIFICATION
notification.pos_v TOP
notification.pos_h LEFT
notification.sound false
notification.color.r 48
notification.color.g 48
notification.color.b 48

BIN
data/font/04b_25.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

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

BIN
data/font/04b_25_2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

@@ -1,43 +1,43 @@
# box width
16
28
# box height
16
28
# 32 espacio ( )
16
# 33 !
16
10
# 34 "
16
# 35 #
16
# 35
20
# 36 $
16
20
# 37 %
16
18
# 38 &
16
22
# 39 '
16
10
# 40 (
16
14
# 41 )
16
14
# 42 *
16
14
# 43 +
16
18
# 44 ,
16
10
# 45 -
16
18
# 46 .
16
10
# 47 /
16
24
# 48 0
16
# 49 1
16
12
# 50 2
16
# 51 3
@@ -55,9 +55,9 @@
# 57 9
16
# 58 :
16
10
# 59 ;
16
10
# 60 <
16
# 61 =
@@ -67,7 +67,7 @@
# 63 ?
16
# 64 @
16
22
# 65 A
16
# 66 B
@@ -85,7 +85,7 @@
# 72 H
16
# 73 I
16
10
# 74 J
16
# 75 K
@@ -93,7 +93,7 @@
# 76 L
16
# 77 M
16
22
# 78 N
16
# 79 O
@@ -107,13 +107,13 @@
# 83 S
16
# 84 T
16
18
# 85 U
16
# 86 V
16
# 87 W
16
22
# 88 X
16
# 89 Y
@@ -121,17 +121,17 @@
# 90 Z
16
# 91 [
16
14
# 92 \
16
22
# 93 ]
16
14
# 94 ^
16
12
# 95 _
16
14
# 96 `
16
12
# 97 a
16
# 98 b
@@ -149,7 +149,7 @@
# 104 h
16
# 105 i
16
10
# 106 j
16
# 107 k
@@ -157,7 +157,7 @@
# 108 l
16
# 109 m
16
22
# 110 n
16
# 111 o
@@ -171,13 +171,13 @@
# 115 s
16
# 116 t
16
18
# 117 u
16
# 118 v
16
# 119 w
16
22
# 120 x
16
# 121 y
@@ -185,10 +185,10 @@
# 122 z
16
# 123 {
16
2
# 124 |
16
2
# 125 }
16
2
# 126 ~
16
2

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 84 B

After

Width:  |  Height:  |  Size: 84 B

View File

@@ -1,5 +1,5 @@
frameWidth=10
frameHeight=10
frame_width=10
frame_height=10
[animation]
name=orange

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -1,5 +1,5 @@
frameWidth=16
frameHeight=16
frame_width=16
frame_height=16
[animation]
name=orange

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -1,5 +1,5 @@
frameWidth=26
frameHeight=26
frame_width=26
frame_height=26
[animation]
name=orange

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@@ -1,5 +1,5 @@
frameWidth=48
frameHeight=48
frame_width=48
frame_height=48
[animation]
name=orange

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -1,5 +1,5 @@
frameWidth=10
frameHeight=10
frame_width=10
frame_height=10
[animation]
name=default

View File

Before

Width:  |  Height:  |  Size: 760 B

After

Width:  |  Height:  |  Size: 760 B

View File

@@ -1,5 +1,5 @@
frameWidth=16
frameHeight=16
frame_width=16
frame_height=16
[animation]
name=default

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -1,5 +1,5 @@
frameWidth=26
frameHeight=26
frame_width=26
frame_height=26
[animation]
name=default

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -1,5 +1,5 @@
frameWidth=46
frameHeight=46
frame_width=46
frame_height=46
[animation]
name=default

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@@ -1,5 +1,5 @@
frameWidth=46
frameHeight=46
frame_width=46
frame_height=46
[animation]
name=powerball

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 858 B

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 799 B

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 270 B

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 935 B

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,5 +1,5 @@
frameWidth=20
frameHeight=20
frame_width=20
frame_height=20
[animation]
name=default

View File

Before

Width:  |  Height:  |  Size: 400 B

After

Width:  |  Height:  |  Size: 400 B

View File

@@ -1,5 +1,5 @@
frameWidth=20
frameHeight=20
frame_width=20
frame_height=20
[animation]
name=default

View File

Before

Width:  |  Height:  |  Size: 623 B

After

Width:  |  Height:  |  Size: 623 B

View File

@@ -1,5 +1,5 @@
frameWidth=28
frameHeight=37
frame_width=28
frame_height=37
[animation]
name=default

View File

Before

Width:  |  Height:  |  Size: 835 B

After

Width:  |  Height:  |  Size: 835 B

View File

@@ -1,5 +1,5 @@
frameWidth=20
frameHeight=20
frame_width=20
frame_height=20
[animation]
name=default

View File

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 336 B

View File

@@ -1,5 +1,5 @@
frameWidth=20
frameHeight=20
frame_width=20
frame_height=20
[animation]
name=default

View File

Before

Width:  |  Height:  |  Size: 506 B

After

Width:  |  Height:  |  Size: 506 B

View File

@@ -1,5 +1,5 @@
frameWidth=20
frameHeight=20
frame_width=20
frame_height=20
[animation]
name=default

View File

Before

Width:  |  Height:  |  Size: 492 B

After

Width:  |  Height:  |  Size: 492 B

View File

Before

Width:  |  Height:  |  Size: 717 B

After

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

View File

Before

Width:  |  Height:  |  Size: 561 B

After

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 716 B

View File

@@ -1,51 +0,0 @@
frameWidth=30
frameHeight=30
[animation]
name=walk
speed=5
loop=0
frames=0,1,2,3
[/animation]
[animation]
name=stand
speed=10
loop=0
frames=4,5,6,7
[/animation]
[animation]
name=walk-sideshoot
speed=5
loop=0
frames=8,9,10,11
[/animation]
[animation]
name=stand-sideshoot
speed=5
loop=0
frames=12,13,14,15
[/animation]
[animation]
name=walk-centershoot
speed=5
loop=0
frames=16,17,18,19
[/animation]
[animation]
name=stand-centershoot
speed=5
loop=0
frames=20,21,22,23
[/animation]
[animation]
name=death
speed=15
loop=0
frames=24,25,26,27
[/animation]

View File

@@ -0,0 +1,93 @@
frame_width=30
frame_height=30
[animation]
name=walk
speed=5
loop=0
frames=0,1,2,3
[/animation]
[animation]
name=stand
speed=10
loop=0
frames=4,5,6,7
[/animation]
[animation]
name=walk-sideshoot
speed=5
loop=0
frames=8,9,10,11
[/animation]
[animation]
name=walk-sideshoot-cooldown
speed=5
loop=0
frames=12,13,14,15
[/animation]
[animation]
name=stand-sideshoot
speed=5
loop=0
frames=16,17,18,19
[/animation]
[animation]
name=stand-sideshoot-cooldown
speed=5
loop=0
frames=15
[/animation]
[animation]
name=walk-centershoot
speed=5
loop=0
frames=20,21,22,23
[/animation]
[animation]
name=walk-centershoot-cooldown
speed=5
loop=0
frames=24,25,26,27
[/animation]
[animation]
name=stand-centershoot
speed=5
loop=0
frames=28,29,30,31
[/animation]
[animation]
name=stand-centershoot-cooldown
speed=5
loop=0
frames=27
[/animation]
[animation]
name=dying
speed=10
loop=0
frames=32,33,34,35
[/animation]
[animation]
name=dead
speed=3
loop=0
frames=44,45,46,47,48,49,50
[/animation]
[animation]
name=celebration
speed=10
loop=-1
frames=36,36,36,36,36,36,37,38,39,40,40,40,40,40,40,39,39,39,40,40,40,39,39,39,38,37,36,36,36
[/animation]

BIN
data/gfx/player/player1.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

Before

Width:  |  Height:  |  Size: 173 B

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 B

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 929 B

View File

Before

Width:  |  Height:  |  Size: 173 B

After

Width:  |  Height:  |  Size: 173 B

BIN
data/gfx/player/player2.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

Before

Width:  |  Height:  |  Size: 172 B

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 B

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 B

View File

Before

Width:  |  Height:  |  Size: 172 B

After

Width:  |  Height:  |  Size: 172 B

View File

@@ -1,5 +1,5 @@
frameWidth=39
frameHeight=44
frame_width=39
frame_height=44
[animation]
name=default

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 944 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -1,5 +1,5 @@
frameWidth=16
frameHeight=16
frame_width=16
frame_height=16
[animation]
name=default

View File

Before

Width:  |  Height:  |  Size: 212 B

After

Width:  |  Height:  |  Size: 212 B

View File

@@ -158,19 +158,19 @@ Felicitats!!
2 JUGADORS
## 53 MARCADOR
jugador 1
Jugador 1
## 54 MARCADOR
jugador 2
Jugador 2
## 55 MARCADOR
mult
Multiplicador
## 56 MARCADOR
max. puntuacio
Max. puntuacio
## 57 MARCADOR
fase
Fase
## 58 - MENU DE OPCIONES
MODE DE VISUALITZACIO
@@ -206,7 +206,7 @@ NORMAL
DIFICIL
## 69 - MENU DE OPCIONES
TECLAT
Teclat
## 70 - MENU DE OPCIONES
MANDO
@@ -281,7 +281,7 @@ MODE FORA DE LINEA
TAULER DE PUNTS
## 94 - NOTIFICACIONES
Torna a polsar per eixir ...
Torna a polsar per eixir
## 95 - DEFINE BUTTONS
Disparar cap a l'esquerra
@@ -314,4 +314,49 @@ Pulsa START
per jugar
## 105 - MARCADOR
Continuar?
Continuar?
## 106 - MARCADOR
Posa el nom
## 107 - AJUDA
Intercanviar mandos
## 108 - AJUDA
Configuracio
## 109 - AJUDA
Alternar el audio
## 110 - AJUDA
Filtres
## 111 - AJUDA
Reiniciar
## 112 - AJUDA
Pausar
## 113 - AJUDA
Eixir
## 114 - MARCADOR
Per favor
## 115 - MARCADOR
espere
## 116 - NOTIFICACIONES
Torna a polsar per apagar el sistema
## 117 - GAME TEXT
SuperPoder!
## 118 - GAME TEXT
+1 Colp
## 119 - GAME TEXT
Temps!
## 120 - SCOREBOARD
Puntuacio

View File

@@ -158,19 +158,19 @@ Congratulations!!
2 PLAYERS
## 53 - MARCADOR
player 1
Player 1
## 54 - MARCADOR
player 2
Player 2
## 55 - MARCADOR
mult
Multiplier
## 56 - MARCADOR
high score
High Score
## 57 - MARCADOR
stage
Stage
## 58 - MENU DE OPCIONES
DISPLAY MODE
@@ -206,7 +206,7 @@ NORMAL
HARD
## 69 - MENU DE OPCIONES
KEYBOARD
Keyboard
## 70 - MENU DE OPCIONES
GAME CONTROLLER
@@ -314,4 +314,49 @@ Press START
to play
## 105 - MARCADOR
Continue?
Continue?
## 106 - MARCADOR
Enter name
## 107 - AJUDA
Swap Controllers
## 108 - AJUDA
Configuration
## 109 - AJUDA
Toggle audio
## 110 - AJUDA
Shaders
## 111 - AJUDA
Reset
## 112 - AJUDA
Pause
## 113 - AJUDA
Exit
## 114 - MARCADOR
Please
## 115 - MARCADOR
wait
## 116 - NOTIFICACIONES
Press again to shutdown system
## 117 - GAME TEXT
PowerUp
## 118 - GAME TEXT
+1 Hit
## 119 - GAME TEXT
Stop!
## 120 - SCOREBOARD
Score

View File

@@ -158,19 +158,19 @@ Felicidades!!
2 JUGADORES
## 53 - MARCADOR
jugador 1
Jugador 1
## 54 - MARCADOR
jugador 2
Jugador 2
## 55 - MARCADOR
mult
Multiplicador
## 56 - MARCADOR
max. puntuacion
Max. puntuacion
## 57 - MARCADOR
FASE
Fase
## 58 - MENU DE OPCIONES
MODO DE VISUALIZACION
@@ -206,7 +206,7 @@ NORMAL
DIFICIL
## 69 - MENU DE OPCIONES
TECLADO
Teclado
## 70 - MENU DE OPCIONES
MANDO
@@ -314,4 +314,49 @@ Pulsa START
para jugar
## 105 - MARCADOR
Continuar?
Continuar?
## 106 - MARCADOR
Pon tu nombre
## 107 - AJUDA
Intercambiar mandos
## 108 - AJUDA
Configuracion
## 109 - AJUDA
Alternar el audio
## 110 - AJUDA
Filtros
## 111 - AJUDA
Reiniciar
## 112 - AJUDA
Pausar
## 113 - AJUDA
Salir
## 114 - MARCADOR
Por favor
## 115 - MARCADOR
espere
## 94 - NOTIFICACIONES
Pulsa otra vez para apagar el sistema
## 117 - GAME TEXT
Potenciador
## 118 - GAME TEXT
+1 Golpe
## 119 - GAME TEXT
Tiempo!
## 120 - SCOREBOARD
Puntuacion

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
SECONDS=0
make linux_debug
duration=$SECONDS
echo "$((duration / 60)) minutes and $((duration % 60)) seconds elapsed."

View File

@@ -0,0 +1,8 @@
#!/bin/bash
SOURCEPATH=../source/
for i in "$SOURCEPATH"/*.cpp
do
include-what-you-use -D DEBUG -D VERBOSE -std=c++20 -Wall "$i"
done

View File

@@ -0,0 +1,10 @@
#!/bin/bash
SOURCEPATH=../source/
for i in "$SOURCEPATH"/*.cpp
do
include-what-you-use -D DEBUG -D VERBOSE -std=c++20 -Wall "$i"
read -r -p "Presiona cualquier tecla para continuar..."
clear
done

View File

@@ -0,0 +1,8 @@
*:/home/sergio/gitea/coffee_crisis_arcade_edition/source/stb*
*:/home/sergio/gitea/coffee_crisis_arcade_edition/source/gif.c
*:/home/sergio/gitea/coffee_crisis_arcade_edition/source/jail*
*:/usr/include/*
*:../source/stb*
*:../source/gif.c
*:../source/jail*
*:/usr/include/*

Binary file not shown.

View File

@@ -0,0 +1,53 @@
#!/bin/bash
# Función para mostrar el uso del script
mostrar_uso() {
echo "Uso: $0 [-o opción]"
echo "Opciones:"
echo " w Ejecutar cppcheck con warning, style, performance"
echo " a Ejecutar cppcheck con todas las opciones habilitadas"
echo " u Ejecutar cppcheck para unusedFunction"
}
# Inicializar las variables
opcion=""
# Procesar las opciones
while getopts "o:" opt; do
case $opt in
o)
opcion=$OPTARG
;;
*)
mostrar_uso
exit 1
;;
esac
done
# Ejecutar según la opción seleccionada
case $opcion in
w)
cppcheck --force --enable=warning,style,performance --std=c++20 \
--suppressions-list=./cppcheck_suppressions \
../source/ \
2>./cppcheck-result-warning-style-performance.txt
;;
a)
cppcheck --force --enable=all -I /usr/include --std=c++20 \
--suppress=missingIncludeSystem \
--suppressions-list=./cppcheck_suppressions \
../source/ \
2>./cppcheck-result-all.txt
;;
u)
cppcheck --enable=style --std=c++20 \
--suppressions-list=./cppcheck_suppressions \
../source/ \
2>./cppcheck-result-unusedFunction.txt
;;
*)
mostrar_uso
exit 1
;;
esac

View File

@@ -0,0 +1,6 @@
#!/bin/bash
valgrind --suppressions=valgrind_exceptions \
--leak-check=full \
~/coffee_crisis_arcade_edition/coffee_crisis_arcade_edition_debug \
> ~/coffee_crisis_arcade_edition/debug.txt 2>&1

View File

@@ -0,0 +1,12 @@
{
ignore_unversioned_libs
Memcheck:Leak
...
obj:*/lib*/lib*.so
}
{
ignore_versioned_libs
Memcheck:Leak
...
obj:*/lib*/lib*.so.*
}

250
source/animated_sprite.cpp Normal file
View File

@@ -0,0 +1,250 @@
#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
AnimationsFileBuffer 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())
{
AnimationsFileBuffer v = loadAnimationsFromFile(file_path);
loadFromAnimationsFileBuffer(v);
}
}
// Constructor
AnimatedSprite::AnimatedSprite(std::shared_ptr<Texture> texture, const AnimationsFileBuffer &animations)
: MovingSprite(texture)
{
if (!animations.empty())
{
loadFromAnimationsFileBuffer(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 >= (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
setSpriteClip(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;
}
}
// 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;
}
}
// 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::loadFromAnimationsFileBuffer(const AnimationsFileBuffer &source)
{
int frame_width = 1;
int frame_height = 1;
int frames_per_row = 1;
int max_tiles = 1;
size_t index = 0;
while (index < source.size())
{
std::string line = source.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]")
{
Animation animation;
do
{
index++;
line = source.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);
}

66
source/animated_sprite.h Normal file
View File

@@ -0,0 +1,66 @@
#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 Animation
{
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
Animation() : name(std::string()), speed(5), loop(0), completed(false), current_frame(0), counter(0) {}
};
using AnimationsFileBuffer = std::vector<std::string>;
// Carga las animaciones en un vector(Animations) desde un fichero
AnimationsFileBuffer loadAnimationsFromFile(const std::string &file_path);
class AnimatedSprite : public MovingSprite
{
protected:
// Variables
std::vector<Animation> 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 loadFromAnimationsFileBuffer(const AnimationsFileBuffer &source);
public:
// Constructor
AnimatedSprite(std::shared_ptr<Texture> texture, const std::string &file_path);
AnimatedSprite(std::shared_ptr<Texture> texture, const AnimationsFileBuffer &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();
};

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