Compare commits
6 Commits
2024-10-28
...
20c51d0796
| Author | SHA1 | Date | |
|---|---|---|---|
| 20c51d0796 | |||
| b43782786a | |||
| 15554c449f | |||
| ba05eab79e | |||
| d83c05bad4 | |||
| e2abf835f9 |
BIN
data/font/04b_25.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
@@ -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
|
||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
@@ -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
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,194 +0,0 @@
|
||||
# box width
|
||||
16
|
||||
# box height
|
||||
16
|
||||
# 32 espacio ( )
|
||||
16
|
||||
# 33 !
|
||||
16
|
||||
# 34 "
|
||||
16
|
||||
# 35 #
|
||||
16
|
||||
# 36 $
|
||||
16
|
||||
# 37 %
|
||||
16
|
||||
# 38 &
|
||||
16
|
||||
# 39 '
|
||||
16
|
||||
# 40 (
|
||||
16
|
||||
# 41 )
|
||||
16
|
||||
# 42 *
|
||||
16
|
||||
# 43 +
|
||||
16
|
||||
# 44 ,
|
||||
16
|
||||
# 45 -
|
||||
16
|
||||
# 46 .
|
||||
16
|
||||
# 47 /
|
||||
16
|
||||
# 48 0
|
||||
16
|
||||
# 49 1
|
||||
16
|
||||
# 50 2
|
||||
16
|
||||
# 51 3
|
||||
16
|
||||
# 52 4
|
||||
16
|
||||
# 53 5
|
||||
16
|
||||
# 54 6
|
||||
16
|
||||
# 55 7
|
||||
16
|
||||
# 56 8
|
||||
16
|
||||
# 57 9
|
||||
16
|
||||
# 58 :
|
||||
16
|
||||
# 59 ;
|
||||
16
|
||||
# 60 <
|
||||
16
|
||||
# 61 =
|
||||
16
|
||||
# 62 >
|
||||
16
|
||||
# 63 ?
|
||||
16
|
||||
# 64 @
|
||||
16
|
||||
# 65 A
|
||||
16
|
||||
# 66 B
|
||||
16
|
||||
# 67 C
|
||||
16
|
||||
# 68 D
|
||||
16
|
||||
# 69 E
|
||||
16
|
||||
# 70 F
|
||||
16
|
||||
# 71 G
|
||||
16
|
||||
# 72 H
|
||||
16
|
||||
# 73 I
|
||||
16
|
||||
# 74 J
|
||||
16
|
||||
# 75 K
|
||||
16
|
||||
# 76 L
|
||||
16
|
||||
# 77 M
|
||||
16
|
||||
# 78 N
|
||||
16
|
||||
# 79 O
|
||||
16
|
||||
# 80 P
|
||||
16
|
||||
# 81 Q
|
||||
16
|
||||
# 82 R
|
||||
16
|
||||
# 83 S
|
||||
16
|
||||
# 84 T
|
||||
16
|
||||
# 85 U
|
||||
16
|
||||
# 86 V
|
||||
16
|
||||
# 87 W
|
||||
16
|
||||
# 88 X
|
||||
16
|
||||
# 89 Y
|
||||
16
|
||||
# 90 Z
|
||||
16
|
||||
# 91 [
|
||||
16
|
||||
# 92 \
|
||||
16
|
||||
# 93 ]
|
||||
16
|
||||
# 94 ^
|
||||
16
|
||||
# 95 _
|
||||
16
|
||||
# 96 `
|
||||
16
|
||||
# 97 a
|
||||
16
|
||||
# 98 b
|
||||
16
|
||||
# 99 c
|
||||
16
|
||||
# 100 d
|
||||
16
|
||||
# 101 e
|
||||
16
|
||||
# 102 f
|
||||
16
|
||||
# 103 g
|
||||
16
|
||||
# 104 h
|
||||
16
|
||||
# 105 i
|
||||
16
|
||||
# 106 j
|
||||
16
|
||||
# 107 k
|
||||
16
|
||||
# 108 l
|
||||
16
|
||||
# 109 m
|
||||
16
|
||||
# 110 n
|
||||
16
|
||||
# 111 o
|
||||
16
|
||||
# 112 p
|
||||
16
|
||||
# 113 q
|
||||
16
|
||||
# 114 r
|
||||
16
|
||||
# 115 s
|
||||
16
|
||||
# 116 t
|
||||
16
|
||||
# 117 u
|
||||
16
|
||||
# 118 v
|
||||
16
|
||||
# 119 w
|
||||
16
|
||||
# 120 x
|
||||
16
|
||||
# 121 y
|
||||
16
|
||||
# 122 z
|
||||
16
|
||||
# 123 {
|
||||
16
|
||||
# 124 |
|
||||
16
|
||||
# 125 }
|
||||
16
|
||||
# 126 ~
|
||||
16
|
||||
|
Before Width: | Height: | Size: 295 B |
|
Before Width: | Height: | Size: 371 B |
|
Before Width: | Height: | Size: 332 B |
|
Before Width: | Height: | Size: 399 B |
|
Before Width: | Height: | Size: 453 B |
|
Before Width: | Height: | Size: 392 B |
@@ -347,4 +347,13 @@ Per favor
|
||||
espere
|
||||
|
||||
## 116 - NOTIFICACIONES
|
||||
Torna a polsar per apagar el sistema
|
||||
Torna a polsar per apagar el sistema
|
||||
|
||||
## 117 - GAME TEXT
|
||||
SuperPoder!
|
||||
|
||||
## 118 - GAME TEXT
|
||||
+1 Colp
|
||||
|
||||
## 119 - GAME TEXT
|
||||
Temps!
|
||||
@@ -347,4 +347,13 @@ Please
|
||||
wait
|
||||
|
||||
## 116 - NOTIFICACIONES
|
||||
Press again to shutdown system
|
||||
Press again to shutdown system
|
||||
|
||||
## 117 - GAME TEXT
|
||||
PowerUp
|
||||
|
||||
## 118 - GAME TEXT
|
||||
+1 Hit
|
||||
|
||||
## 119 - GAME TEXT
|
||||
Stop!
|
||||
@@ -347,4 +347,13 @@ Por favor
|
||||
espere
|
||||
|
||||
## 94 - NOTIFICACIONES
|
||||
Pulsa otra vez para apagar el sistema
|
||||
Pulsa otra vez para apagar el sistema
|
||||
|
||||
## 117 - GAME TEXT
|
||||
Potenciador
|
||||
|
||||
## 118 - GAME TEXT
|
||||
+1 Golpe
|
||||
|
||||
## 119 - GAME TEXT
|
||||
Tiempo!
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# warning,style,performance
|
||||
#cppcheck --force --enable=warning,style,performance --std=c++20 \
|
||||
# --suppressions-list=/home/sergio/gitea/coffee_crisis_arcade_edition/linux-utils/cppcheck_suppressions \
|
||||
# /home/sergio/gitea/coffee_crisis_arcade_edition/source/ \
|
||||
# 2>/home/sergio/cppcheck-result-warning-style-performance.txt
|
||||
|
||||
# all
|
||||
#cppcheck --force --enable=all -I /usr/include --std=c++20 \
|
||||
#--suppress=missingIncludeSystem \
|
||||
#--suppressions-list=/home/sergio/gitea/coffee_crisis_arcade_edition/linux-utils/cppcheck_suppressions \
|
||||
#/home/sergio/gitea/coffee_crisis_arcade_edition/source/ \
|
||||
#2>/home/sergio/cppcheck-result-all.txt
|
||||
|
||||
# unusedFunction
|
||||
cppcheck --enable=style --std=c++20 \
|
||||
--suppressions-list=./cppcheck_suppressions \
|
||||
../source/ \
|
||||
2>/home/sergio/cppcheck-result-all.txt
|
||||
53
linux_utils/run_cppcheck.sh
Normal 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
|
||||
@@ -28,13 +28,13 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
||||
vy_ = 0;
|
||||
max_vy_ = 3.0f;
|
||||
|
||||
const int size = static_cast<int>(size_);
|
||||
gravity_ = param.balloon.at(size).grav;
|
||||
default_vy_ = param.balloon.at(size).vel;
|
||||
h_ = w_ = BALLOON_SIZE[size];
|
||||
power_ = BALLOON_POWER[size];
|
||||
menace_ = BALLOON_MENACE[size];
|
||||
score_ = BALLOON_SCORE[size];
|
||||
const int index = static_cast<int>(size_);
|
||||
gravity_ = param.balloon.at(index).grav;
|
||||
default_vy_ = param.balloon.at(index).vel;
|
||||
h_ = w_ = BALLOON_SIZE[index];
|
||||
power_ = BALLOON_POWER[index];
|
||||
menace_ = BALLOON_MENACE[index];
|
||||
score_ = BALLOON_SCORE[index];
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -44,25 +44,25 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
||||
default_vy_ = max_vy_ = vy_ = fabs(vx_ * 2.0f);
|
||||
gravity_ = 0.00f;
|
||||
|
||||
const int size = static_cast<int>(size_);
|
||||
h_ = w_ = BALLOON_SIZE[size];
|
||||
power_ = BALLOON_POWER[size];
|
||||
menace_ = BALLOON_MENACE[size];
|
||||
score_ = BALLOON_SCORE[size];
|
||||
const int index = static_cast<int>(size_);
|
||||
h_ = w_ = BALLOON_SIZE[index];
|
||||
power_ = BALLOON_POWER[index];
|
||||
menace_ = BALLOON_MENACE[index];
|
||||
score_ = BALLOON_SCORE[index];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case BalloonType::POWERBALL:
|
||||
{
|
||||
const int size = 3;
|
||||
h_ = w_ = BALLOON_SIZE[size];
|
||||
const int index = 3;
|
||||
h_ = w_ = BALLOON_SIZE[index];
|
||||
power_ = score_ = menace_ = 0;
|
||||
|
||||
vy_ = 0;
|
||||
max_vy_ = 3.0f;
|
||||
gravity_ = param.balloon.at(size).grav;
|
||||
default_vy_ = param.balloon.at(size).vel;
|
||||
gravity_ = param.balloon.at(index).grav;
|
||||
default_vy_ = param.balloon.at(index).vel;
|
||||
|
||||
sprite_->disableRotate();
|
||||
sprite_->setRotateSpeed(0);
|
||||
|
||||
@@ -427,15 +427,6 @@ void Director::setFileList()
|
||||
Asset::get()->add(prefix + "/data/gfx/game/game_sky_colors.png", AssetType::BITMAP);
|
||||
}
|
||||
|
||||
{ // Game Text
|
||||
Asset::get()->add(prefix + "/data/gfx/game_text/game_text_1000_points.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/gfx/game_text/game_text_2500_points.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/gfx/game_text/game_text_5000_points.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/gfx/game_text/game_text_powerup.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/gfx/game_text/game_text_one_hit.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/gfx/game_text/game_text_stop.png", AssetType::BITMAP);
|
||||
}
|
||||
|
||||
{ // Intro
|
||||
Asset::get()->add(prefix + "/data/gfx/intro/intro.png", AssetType::BITMAP);
|
||||
}
|
||||
@@ -495,16 +486,12 @@ void Director::setFileList()
|
||||
Asset::get()->add(prefix + "/data/font/8bithud.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/8bithud.txt", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/nokia.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/nokia_big2.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/nokia.txt", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/nokia2.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/nokia2.txt", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/nokia_big2.txt", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/smb2_big.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/smb2_big.txt", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/smb2.gif", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/smb2_palette1.pal", AssetType::PALETTE);
|
||||
Asset::get()->add(prefix + "/data/font/smb2.txt", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/04b_25.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/04b_25.txt", AssetType::FONT);
|
||||
|
||||
// Textos
|
||||
Asset::get()->add(prefix + "/data/lang/es_ES.txt", AssetType::LANG);
|
||||
|
||||
321
source/game.cpp
@@ -1,39 +1,40 @@
|
||||
#include "game.h"
|
||||
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
|
||||
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_KEYDOWN
|
||||
#include <SDL2/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4
|
||||
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
|
||||
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
|
||||
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
|
||||
#include <stdlib.h> // Para rand, size_t
|
||||
#include <algorithm> // Para find_if, clamp, min, remove_if
|
||||
#include <iterator> // Para distance, size
|
||||
#include <numeric> // Para accumulate
|
||||
#include "asset.h" // Para Asset
|
||||
#include "background.h" // Para Background
|
||||
#include "balloon.h" // Para Balloon, BALLOON_SCORE, BALLOON_VE...
|
||||
#include "balloon_formations.h" // Para BalloonFormations, BalloonFormatio...
|
||||
#include "bullet.h" // Para Bullet, BulletType, BulletMoveStatus
|
||||
#include "explosions.h" // Para Explosions
|
||||
#include "fade.h" // Para Fade, FadeType
|
||||
#include "global_inputs.h" // Para check
|
||||
#include "input.h" // Para InputType, Input, INPUT_DO_NOT_ALL...
|
||||
#include "item.h" // Para Item, ItemType
|
||||
#include "jail_audio.h" // Para JA_PlaySound, JA_GetMusicState
|
||||
#include "lang.h" // Para getText
|
||||
#include "manage_hiscore_table.h" // Para ManageHiScoreTable
|
||||
#include "notifier.h" // Para Notifier
|
||||
#include "param.h" // Para Param, param, ParamGame, ParamFade
|
||||
#include "path_sprite.h" // Para PathSprite, PathType
|
||||
#include "player.h" // Para Player, PlayerStatus
|
||||
#include "resource.h" // Para Resource
|
||||
#include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREB...
|
||||
#include "screen.h" // Para Screen
|
||||
#include "section.h" // Para Name, name, Options, options
|
||||
#include "smart_sprite.h" // Para SmartSprite
|
||||
#include "text.h" // Para Text, TEXT_CENTER
|
||||
#include "texture.h" // Para Texture
|
||||
struct JA_Sound_t; // lines 40-40
|
||||
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
|
||||
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_KEYDOWN
|
||||
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3, SDLK_4
|
||||
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
|
||||
#include <stdlib.h> // for rand, size_t
|
||||
#include <algorithm> // for find_if, clamp, min, remove_if
|
||||
#include <functional> // for function
|
||||
#include <iterator> // for distance, size
|
||||
#include <numeric> // for accumulate
|
||||
#include "asset.h" // for Asset
|
||||
#include "background.h" // for Background
|
||||
#include "balloon.h" // for Balloon, BALLOON_SCORE, BALLOON_VE...
|
||||
#include "balloon_formations.h" // for BalloonFormations, BalloonFormatio...
|
||||
#include "bullet.h" // for Bullet, BulletType, BulletMoveStatus
|
||||
#include "explosions.h" // for Explosions
|
||||
#include "fade.h" // for Fade, FadeType
|
||||
#include "global_inputs.h" // for check
|
||||
#include "input.h" // for InputType, Input, INPUT_DO_NOT_ALL...
|
||||
#include "item.h" // for Item, ItemType
|
||||
#include "jail_audio.h" // for JA_PlaySound, JA_GetMusicState
|
||||
#include "lang.h" // for getText
|
||||
#include "manage_hiscore_table.h" // for ManageHiScoreTable, HiScoreEntry
|
||||
#include "notifier.h" // for Notifier
|
||||
#include "param.h" // for Param, param, ParamGame, ParamFade
|
||||
#include "path_sprite.h" // for Path, PathSprite, createPath, Path...
|
||||
#include "player.h" // for Player, PlayerStatus
|
||||
#include "resource.h" // for Resource
|
||||
#include "scoreboard.h" // for Scoreboard, ScoreboardMode, SCOREB...
|
||||
#include "screen.h" // for Screen
|
||||
#include "section.h" // for Name, name, Options, options
|
||||
#include "smart_sprite.h" // for SmartSprite
|
||||
#include "text.h" // for Text
|
||||
#include "texture.h" // for Texture
|
||||
struct JA_Sound_t; // lines 36-36
|
||||
|
||||
// Constructor
|
||||
Game::Game(int player_id, int current_stage, bool demo)
|
||||
@@ -46,8 +47,7 @@ Game::Game(int player_id, int current_stage, bool demo)
|
||||
balloon_formations_(std::make_unique<BalloonFormations>()),
|
||||
canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.play_area.rect.w, param.game.play_area.rect.h)),
|
||||
fade_(std::make_unique<Fade>()),
|
||||
current_stage_(current_stage),
|
||||
last_stage_reached_(current_stage)
|
||||
current_stage_(current_stage)
|
||||
{
|
||||
// Pasa variables
|
||||
demo_.enabled = demo;
|
||||
@@ -89,6 +89,7 @@ Game::Game(int player_id, int current_stage, bool demo)
|
||||
{
|
||||
createTwoBigBalloons();
|
||||
evaluateAndSetMenace();
|
||||
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("get_ready"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,12 +119,12 @@ void Game::setResources()
|
||||
|
||||
// Texturas - Game_text
|
||||
{
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_1000_points.png"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_2500_points.png"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_5000_points.png"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_powerup.png"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_one_hit.png"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_stop.png"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_1000_points"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_2500_points"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_5000_points"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_powerup"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_one_hit"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_stop"));
|
||||
}
|
||||
|
||||
// Texturas - Globos
|
||||
@@ -201,14 +202,6 @@ void Game::setResources()
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_coffee.ani"));
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_coffee_machine.ani"));
|
||||
}
|
||||
|
||||
// Texto
|
||||
{
|
||||
text_ = std::make_unique<Text>(Resource::get()->getTexture("smb2.gif"), Resource::get()->getTextFile("smb2.txt"));
|
||||
text_big_ = std::make_unique<Text>(Resource::get()->getTexture("smb2_big.png"), Resource::get()->getTextFile("smb2_big.txt"));
|
||||
text_nokia2_ = std::make_unique<Text>(Resource::get()->getTexture("nokia2.png"), Resource::get()->getTextFile("nokia2.txt"));
|
||||
text_nokia2_big_ = std::make_unique<Text>(Resource::get()->getTexture("nokia_big2.png"), Resource::get()->getTextFile("nokia_big2.txt"));
|
||||
}
|
||||
}
|
||||
|
||||
// Crea una formación de enemigos
|
||||
@@ -333,46 +326,50 @@ void Game::updateStage()
|
||||
if (current_power_ >= balloon_formations_->getStage(current_stage_).power_to_complete)
|
||||
{
|
||||
// Cambio de fase
|
||||
current_stage_++;
|
||||
++current_stage_;
|
||||
current_power_ = 0;
|
||||
last_stage_reached_ = current_stage_;
|
||||
|
||||
// Ha llegado al final el juego
|
||||
if (current_stage_ == 10)
|
||||
{ // Ha llegado al final el juego
|
||||
{
|
||||
game_completed_ = true; // Marca el juego como completado
|
||||
current_stage_ = 9; // Deja el valor dentro de los limites
|
||||
destroyAllBalloons(); // Destruye a todos los enemigos
|
||||
current_power_ = 0; // Vuelve a dejar el poder a cero, por lo que hubiera podido subir al destruir todos lo globos
|
||||
menace_current_ = 255; // Sube el nivel de amenaza para que no cree mas globos
|
||||
|
||||
// Añade un millon de puntos a los jugadores que queden vivos
|
||||
for (auto &player : players_)
|
||||
{ // Añade un millon de puntos a los jugadores que queden vivos
|
||||
if (player->isPlaying())
|
||||
{
|
||||
player->addScore(1000000);
|
||||
}
|
||||
}
|
||||
|
||||
updateHiScore();
|
||||
JA_StopMusic();
|
||||
}
|
||||
JA_PlaySound(Resource::get()->getSound("stage_change.wav"));
|
||||
stage_bitmap_counter_ = 0;
|
||||
balloon_speed_ = default_balloon_speed_;
|
||||
setBalloonSpeed(balloon_speed_);
|
||||
screen_->flash(flash_color, 5);
|
||||
screen_->flash(flash_color, 10);
|
||||
screen_->shake();
|
||||
}
|
||||
|
||||
// Incrementa el contador del bitmap que aparece mostrando el cambio de fase
|
||||
if (stage_bitmap_counter_ < STAGE_COUNTER_)
|
||||
{
|
||||
stage_bitmap_counter_++;
|
||||
}
|
||||
|
||||
// Si el juego se ha completado, el bitmap se detiene en el centro de la pantalla
|
||||
if (game_completed_)
|
||||
{
|
||||
if (stage_bitmap_counter_ > 100)
|
||||
// Escribe el texto por pantalla
|
||||
const auto stage_number = balloon_formations_->getStage(current_stage_).number;
|
||||
if (!game_completed_)
|
||||
{
|
||||
stage_bitmap_counter_ = 100;
|
||||
std::vector<Path> paths = {paths_.at(2), paths_.at(3)};
|
||||
if (stage_number == 10)
|
||||
createMessage(paths, Resource::get()->getTexture("last_stage"));
|
||||
else
|
||||
{
|
||||
auto text = std::make_unique<Text>(Resource::get()->getTexture("04b_25.png"), Resource::get()->getTextFile("04b_25.txt"));
|
||||
const std::string caption = std::to_string(10 - current_stage_) + lang::getText(38);
|
||||
createMessage(paths, text->writeToTexture(caption, 2, -2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
createMessage({paths_.at(4), paths_.at(5)}, Resource::get()->getTexture("congratulations"));
|
||||
createMessage({paths_.at(6), paths_.at(7)}, Resource::get()->getTexture("1000000_points"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -385,6 +382,9 @@ void Game::updateGameOver()
|
||||
{
|
||||
if (game_over_counter_ > 0)
|
||||
{
|
||||
if (game_over_counter_ == GAME_OVER_COUNTER_)
|
||||
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_over"));
|
||||
|
||||
game_over_counter_--;
|
||||
|
||||
if ((game_over_counter_ == 250) || (game_over_counter_ == 200) || (game_over_counter_ == 180) || (game_over_counter_ == 120) || (game_over_counter_ == 60))
|
||||
@@ -652,28 +652,28 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
{
|
||||
player->addScore(1000);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_[0]->getWidth()) / 2;
|
||||
createPathSprite(x, game_text_textures_[0]);
|
||||
createItemText(x, game_text_textures_[0]);
|
||||
break;
|
||||
}
|
||||
case ItemType::GAVINA:
|
||||
{
|
||||
player->addScore(2500);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_[1]->getWidth()) / 2;
|
||||
createPathSprite(x, game_text_textures_[1]);
|
||||
createItemText(x, game_text_textures_[1]);
|
||||
break;
|
||||
}
|
||||
case ItemType::PACMAR:
|
||||
{
|
||||
player->addScore(5000);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_[2]->getWidth()) / 2;
|
||||
createPathSprite(x, game_text_textures_[2]);
|
||||
createItemText(x, game_text_textures_[2]);
|
||||
break;
|
||||
}
|
||||
case ItemType::CLOCK:
|
||||
{
|
||||
enableTimeStopItem();
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_[5]->getWidth()) / 2;
|
||||
createPathSprite(x, game_text_textures_[5]);
|
||||
createItemText(x, game_text_textures_[5]);
|
||||
break;
|
||||
}
|
||||
case ItemType::COFFEE:
|
||||
@@ -682,13 +682,13 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
{
|
||||
player->addScore(5000);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_[2]->getWidth()) / 2;
|
||||
createPathSprite(x, game_text_textures_[2]);
|
||||
createItemText(x, game_text_textures_[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
player->giveExtraHit();
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_[4]->getWidth()) / 2;
|
||||
createPathSprite(x, game_text_textures_[4]);
|
||||
createItemText(x, game_text_textures_[4]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -697,7 +697,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
player->setPowerUp();
|
||||
coffee_machine_enabled_ = false;
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_[3]->getWidth()) / 2;
|
||||
createPathSprite(x, game_text_textures_[3]);
|
||||
createItemText(x, game_text_textures_[3]);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -897,7 +897,7 @@ void Game::freeItems()
|
||||
}
|
||||
|
||||
// Crea un objeto PathSprite
|
||||
void Game::createPathSprite(int x, std::shared_ptr<Texture> texture)
|
||||
void Game::createItemText(int x, std::shared_ptr<Texture> texture)
|
||||
{
|
||||
path_sprites_.emplace_back(std::make_unique<PathSprite>(texture));
|
||||
|
||||
@@ -905,7 +905,7 @@ void Game::createPathSprite(int x, std::shared_ptr<Texture> texture)
|
||||
const auto h = texture->getHeight();
|
||||
|
||||
const int y0 = param.game.play_area.rect.h - h;
|
||||
const int y1 = 160;
|
||||
const int y1 = 155;
|
||||
const int y2 = -h;
|
||||
|
||||
// Ajusta para que no se dibuje fuera de pantalla
|
||||
@@ -920,6 +920,17 @@ void Game::createPathSprite(int x, std::shared_ptr<Texture> texture)
|
||||
path_sprites_.back()->enable();
|
||||
}
|
||||
|
||||
// Crea un objeto PathSprite
|
||||
void Game::createMessage(const std::vector<Path> &paths, std::shared_ptr<Texture> texture)
|
||||
{
|
||||
path_sprites_.emplace_back(std::make_unique<PathSprite>(texture));
|
||||
|
||||
// Inicializa
|
||||
for (const auto &path : paths)
|
||||
path_sprites_.back()->addPath(path, true);
|
||||
path_sprites_.back()->enable();
|
||||
}
|
||||
|
||||
// Vacia el vector de smartsprites
|
||||
void Game::freeSmartSprites()
|
||||
{
|
||||
@@ -1202,15 +1213,15 @@ void Game::updateBackground()
|
||||
balloons_popped_ = (balloons_popped_ > 400) ? (balloons_popped_ - 25) : 200;
|
||||
|
||||
// Calcula la velocidad en función de los globos explotados y el total de globos a explotar para acabar el juego
|
||||
constexpr auto clouds_initial_speed = 0.05f;
|
||||
constexpr auto clouds_final_speed = 2.00f - clouds_initial_speed;
|
||||
const float cloudsSpeed = (-clouds_initial_speed) + (-clouds_final_speed * ((float)balloons_popped_ / (float)total_power_to_complete_game_));
|
||||
constexpr float clouds_initial_speed = 0.05f;
|
||||
constexpr float clouds_final_speed = 2.00f - clouds_initial_speed;
|
||||
const float cloudsSpeed = (-clouds_initial_speed) + (-clouds_final_speed * (static_cast<float>(balloons_popped_) / total_power_to_complete_game_));
|
||||
background_->setCloudsSpeed(cloudsSpeed);
|
||||
|
||||
// Calcula la transición de los diferentes fondos
|
||||
const float gradient_number = std::min(((float)balloons_popped_ / 1250.0f), 3.0f);
|
||||
const float percent = gradient_number - (int)gradient_number;
|
||||
background_->setGradientNumber((int)gradient_number);
|
||||
const float gradient_number = std::min(balloons_popped_ / 1250.0f, 3.0f);
|
||||
const float percent = gradient_number - static_cast<int>(gradient_number);
|
||||
background_->setGradientNumber(static_cast<int>(gradient_number));
|
||||
background_->setTransition(percent);
|
||||
|
||||
// Actualiza el objeto
|
||||
@@ -1228,11 +1239,10 @@ void Game::fillCanvas()
|
||||
background_->render();
|
||||
renderItems();
|
||||
renderSmartSprites();
|
||||
renderPathSprites();
|
||||
explosions_->render();
|
||||
renderBalloons();
|
||||
renderBullets();
|
||||
renderMessages();
|
||||
renderPathSprites();
|
||||
renderPlayers();
|
||||
|
||||
// Deja el renderizador apuntando donde estaba
|
||||
@@ -1248,6 +1258,12 @@ void Game::render()
|
||||
// Copia la textura con la zona de juego a la pantalla
|
||||
SDL_RenderCopy(renderer_, canvas_, nullptr, ¶m.game.play_area.rect);
|
||||
|
||||
// SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 255, 255);
|
||||
// const int y = param.game.play_area.center_y;
|
||||
// SDL_RenderDrawLine(Screen::get()->getRenderer(), 0, y, param.game.play_area.rect.w, y);
|
||||
// const int x = param.game.play_area.center_x;
|
||||
// SDL_RenderDrawLine(Screen::get()->getRenderer(), x, 0, x, param.game.play_area.rect.h);
|
||||
|
||||
// Dibuja el marcador
|
||||
scoreboard_->render();
|
||||
|
||||
@@ -1282,45 +1298,6 @@ void Game::updateMenace()
|
||||
}
|
||||
}
|
||||
|
||||
// Pinta diferentes mensajes en la pantalla
|
||||
void Game::renderMessages()
|
||||
{
|
||||
// GetReady
|
||||
if (counter_ < STAGE_COUNTER_ && !demo_.enabled)
|
||||
text_nokia2_big_->write((int)get_ready_bitmap_path_[counter_], param.game.play_area.center_y - 8, lang::getText(75), -2);
|
||||
|
||||
// STAGE NUMBER
|
||||
if (stage_bitmap_counter_ < STAGE_COUNTER_)
|
||||
{
|
||||
const auto stage_number = balloon_formations_->getStage(current_stage_).number;
|
||||
std::string text;
|
||||
|
||||
if (stage_number == 10)
|
||||
{
|
||||
// Ultima fase
|
||||
text = lang::getText(79);
|
||||
}
|
||||
else
|
||||
{
|
||||
// X fases restantes
|
||||
text = std::to_string(11 - stage_number) + lang::getText(38);
|
||||
}
|
||||
|
||||
if (!game_completed_)
|
||||
{
|
||||
// Escribe el número de fases restantes
|
||||
text_nokia2_big_->writeDX(TEXT_CENTER, param.game.play_area.center_x, stage_bitmap_path_[stage_bitmap_counter_], text, -2, no_color, 2, shdw_txt_color);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Escribe el texto de juego completado
|
||||
text = lang::getText(50);
|
||||
text_nokia2_big_->writeDX(TEXT_CENTER, param.game.play_area.center_x, stage_bitmap_path_[stage_bitmap_counter_], text, -2, no_color, 1, shdw_txt_color);
|
||||
text_nokia2_->writeDX(TEXT_CENTER, param.game.play_area.center_x, stage_bitmap_path_[stage_bitmap_counter_] + text_nokia2_big_->getCharacterSize() + 2, lang::getText(76), -1, no_color, 1, shdw_txt_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Habilita el efecto del item de detener el tiempo
|
||||
void Game::enableTimeStopItem()
|
||||
{
|
||||
@@ -1379,57 +1356,54 @@ int Game::calculateScreenPower()
|
||||
// Inicializa las variables que contienen puntos de ruta para mover objetos
|
||||
void Game::initPaths()
|
||||
{
|
||||
// Vector con los valores del seno para 360 grados
|
||||
float sin[360];
|
||||
for (int i = 0; i < 360; ++i)
|
||||
sin[i] = SDL_sinf((float)i * 3.14f / 180.0f);
|
||||
|
||||
// Letrero de STAGE #
|
||||
constexpr auto first_part = STAGE_COUNTER_ / 4; // 50
|
||||
constexpr auto second_part = first_part * 3; // 150
|
||||
const auto center_point = param.game.play_area.center_y - (BLOCK * 2);
|
||||
const auto distance = (param.game.play_area.rect.h) - (param.game.play_area.center_y - 16);
|
||||
|
||||
for (int i = 0; i < first_part; ++i)
|
||||
// Recorrido para el texto de "Get Ready!" (0,1)
|
||||
{
|
||||
int index = static_cast<int>((i * 1.8f) + 90) % 360;
|
||||
stage_bitmap_path_[i] = sin[index] * distance + center_point;
|
||||
const auto &texture = Resource::get()->getTexture("get_ready");
|
||||
const auto w = texture->getWidth();
|
||||
const int x0 = -w;
|
||||
const int x1 = param.game.play_area.center_x - w / 2;
|
||||
const int x2 = param.game.play_area.rect.w;
|
||||
const int y = param.game.play_area.center_y;
|
||||
paths_.emplace_back(Path(createPath(x0, x1, PathType::HORIZONTAL, y, 80, easeOutQuint), 20));
|
||||
paths_.emplace_back(Path(createPath(x1, x2, PathType::HORIZONTAL, y, 80, easeInQuint), 0));
|
||||
}
|
||||
|
||||
for (int i = first_part; i < second_part; ++i)
|
||||
stage_bitmap_path_[i] = center_point;
|
||||
|
||||
for (int i = second_part; i < STAGE_COUNTER_; ++i)
|
||||
// Recorrido para el texto de "Last Stage!" o de "X stages left" o "Game Over" (2,3)
|
||||
{
|
||||
int index = static_cast<int>(((i - 149) * 1.8f) + 90) % 360;
|
||||
stage_bitmap_path_[i] = sin[index] * (center_point + 17) - 17;
|
||||
const auto &texture = Resource::get()->getTexture("last_stage");
|
||||
const auto h = texture->getHeight();
|
||||
const int y0 = param.game.play_area.rect.h - h;
|
||||
const int y1 = param.game.play_area.center_y - h / 2;
|
||||
const int y2 = -h;
|
||||
const int x = param.game.play_area.center_x;
|
||||
paths_.emplace_back(Path(createPath(y0, y1, PathType::VERTICAL, x, 80, easeOutQuint), 20));
|
||||
paths_.emplace_back(Path(createPath(y1, y2, PathType::VERTICAL, x, 80, easeInQuint), 0));
|
||||
}
|
||||
|
||||
// Letrero de GetReady
|
||||
const auto size = text_nokia2_big_->lenght(lang::getText(75), -2);
|
||||
|
||||
const float start1 = param.game.play_area.rect.x - size;
|
||||
const float finish1 = param.game.play_area.center_x - (size / 2);
|
||||
const float finish2 = param.game.play_area.rect.w;
|
||||
|
||||
const float distance1 = finish1 - start1;
|
||||
const float distance2 = finish2 - finish1;
|
||||
|
||||
for (int i = 0; i < first_part; ++i)
|
||||
// Recorrido para el texto de "Congratulations!!" (3,4)
|
||||
{
|
||||
get_ready_bitmap_path_[i] = sin[(int)(i * 1.8f)];
|
||||
get_ready_bitmap_path_[i] *= distance1;
|
||||
get_ready_bitmap_path_[i] -= size;
|
||||
const auto &texture = Resource::get()->getTexture("congratulations");
|
||||
const auto w = texture->getWidth();
|
||||
const auto h = texture->getHeight();
|
||||
const int x0 = -w;
|
||||
const int x1 = param.game.play_area.center_x - w / 2;
|
||||
const int x2 = param.game.play_area.rect.w;
|
||||
const int y = param.game.play_area.center_y - h / 2 - 20;
|
||||
paths_.emplace_back(Path(createPath(x0, x1, PathType::HORIZONTAL, y, 80, easeOutQuint), 400));
|
||||
paths_.emplace_back(Path(createPath(x1, x2, PathType::HORIZONTAL, y, 80, easeInQuint), 0));
|
||||
}
|
||||
|
||||
for (int i = first_part; i < second_part; ++i)
|
||||
get_ready_bitmap_path_[i] = (int)finish1;
|
||||
|
||||
for (int i = second_part; i < STAGE_COUNTER_; ++i)
|
||||
// Recorrido para el texto de "1.000.000 points!" (5,6)
|
||||
{
|
||||
get_ready_bitmap_path_[i] = sin[(int)((i - second_part) * 1.8f)];
|
||||
get_ready_bitmap_path_[i] *= distance2;
|
||||
get_ready_bitmap_path_[i] += finish1;
|
||||
const auto &texture = Resource::get()->getTexture("1000000_points");
|
||||
const auto w = texture->getWidth();
|
||||
const auto h = texture->getHeight();
|
||||
const int x0 = param.game.play_area.rect.w;
|
||||
const int x1 = param.game.play_area.center_x - w / 2;
|
||||
const int x2 = -w;
|
||||
const int y = param.game.play_area.center_y + h / 2 - 20;
|
||||
paths_.emplace_back(Path(createPath(x0, x1, PathType::HORIZONTAL, y, 80, easeOutQuint), 400));
|
||||
paths_.emplace_back(Path(createPath(x1, x2, PathType::HORIZONTAL, y, 80, easeInQuint), 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1565,9 +1539,14 @@ void Game::checkEvents()
|
||||
case SDLK_5: // Crea un PathSprite
|
||||
{
|
||||
const int x = players_.at(0)->getPosX() + (players_.at(0)->getWidth() - game_text_textures_[3]->getWidth()) / 2;
|
||||
createPathSprite(x, game_text_textures_.at(3));
|
||||
createItemText(x, game_text_textures_.at(3));
|
||||
break;
|
||||
}
|
||||
case SDLK_6: // Crea un mensaje
|
||||
{
|
||||
createMessage({paths_.at(4), paths_.at(5)}, Resource::get()->getTexture("congratulations"));
|
||||
createMessage({paths_.at(6), paths_.at(7)}, Resource::get()->getTexture("1000000_points"));
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1619,9 +1598,7 @@ void Game::updateScoreboard()
|
||||
void Game::pause(bool value)
|
||||
{
|
||||
paused_ = value;
|
||||
#ifndef DEBUG
|
||||
screen_->attenuate(paused_);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Añade una puntuación a la tabla de records
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture
|
||||
#include <SDL2/SDL_stdinc.h> // Para Uint32, Uint8
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
#include "balloon.h" // Para Balloon
|
||||
#include "manage_hiscore_table.h" // Para HiScoreEntry
|
||||
#include "options.h" // Para Options, OptionsGame, options
|
||||
#include "player.h" // Para Player
|
||||
#include "utils.h" // Para Demo
|
||||
class Asset; // lines 12-12
|
||||
class Background; // lines 13-13
|
||||
class BalloonFormations; // lines 14-14
|
||||
class Bullet; // lines 15-15
|
||||
class Explosions; // lines 16-16
|
||||
class Fade; // lines 17-17
|
||||
class Input; // lines 18-18
|
||||
class Item; // lines 19-19
|
||||
class PathSprite; // lines 20-20
|
||||
class Scoreboard; // lines 21-21
|
||||
class Screen; // lines 22-22
|
||||
class SmartSprite; // lines 23-23
|
||||
class Text; // lines 24-24
|
||||
class Texture; // lines 25-25
|
||||
enum class BulletType : Uint8; // lines 26-26
|
||||
enum class ItemType; // lines 27-27
|
||||
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
|
||||
#include <SDL2/SDL_stdinc.h> // for Uint32, Uint8
|
||||
#include <memory> // for shared_ptr, unique_ptr
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
#include "balloon.h" // for Balloon
|
||||
#include "manage_hiscore_table.h" // for HiScoreEntry
|
||||
#include "options.h" // for Options, OptionsGame, options
|
||||
#include "player.h" // for Player
|
||||
#include "utils.h" // for Demo
|
||||
class Asset; // lines 14-14
|
||||
class Background; // lines 15-15
|
||||
class BalloonFormations; // lines 16-16
|
||||
class Bullet; // lines 17-17
|
||||
class Explosions; // lines 18-18
|
||||
class Fade; // lines 19-19
|
||||
class Input; // lines 20-20
|
||||
class Item; // lines 21-21
|
||||
class PathSprite; // lines 22-22
|
||||
class Scoreboard; // lines 23-23
|
||||
class Screen; // lines 24-24
|
||||
class SmartSprite; // lines 25-25
|
||||
class Texture; // lines 27-27
|
||||
enum class BulletType : Uint8; // lines 28-28
|
||||
enum class ItemType; // lines 29-29
|
||||
struct Path;
|
||||
|
||||
// Modo demo
|
||||
constexpr bool GAME_MODE_DEMO_OFF = false;
|
||||
@@ -67,7 +67,6 @@ private:
|
||||
// Constantes
|
||||
|
||||
// Contadores
|
||||
static constexpr int STAGE_COUNTER_ = 200;
|
||||
static constexpr int HELP_COUNTER_ = 1000;
|
||||
static constexpr int GAME_COMPLETED_START_FADE_ = 500;
|
||||
static constexpr int GAME_COMPLETED_END_ = 700;
|
||||
@@ -144,12 +143,8 @@ private:
|
||||
std::vector<std::vector<std::string>> balloon_animations_; // Vector con las animaciones de los globos
|
||||
std::vector<std::vector<std::string>> explosions_animations_; // Vector con las animaciones de las explosiones
|
||||
|
||||
std::unique_ptr<Text> text_; // Fuente para los textos del juego
|
||||
std::unique_ptr<Text> text_big_; // Fuente de texto grande
|
||||
std::unique_ptr<Text> text_nokia2_; // Otra fuente de texto para mensajes
|
||||
std::unique_ptr<Text> text_nokia2_big_; // Y la versión en grande
|
||||
|
||||
std::unique_ptr<Fade> fade_; // Objeto para renderizar fades
|
||||
std::vector<Path> paths_; // Vector con los recorridos precalculados almacenados
|
||||
|
||||
// Variables
|
||||
HiScoreEntry hi_score_ = HiScoreEntry(
|
||||
@@ -157,7 +152,6 @@ private:
|
||||
options.game.hi_score_table[0].score); // Máxima puntuación y nombre de quien la ostenta
|
||||
|
||||
int current_stage_; // Indica la fase actual
|
||||
int last_stage_reached_; // Contiene el número de la última pantalla que se ha alcanzado
|
||||
Demo demo_; // Variable con todas las variables relacionadas con el modo demo
|
||||
GameDifficulty difficulty_ = options.game.difficulty; // Dificultad del juego
|
||||
Helper helper_; // Variable para gestionar las ayudas
|
||||
@@ -170,8 +164,6 @@ private:
|
||||
float balloon_speed_; // Velocidad a la que se mueven los enemigos
|
||||
float default_balloon_speed_; // Velocidad base de los enemigos, sin incrementar
|
||||
float difficulty_score_multiplier_; // Multiplicador de puntos en función de la dificultad
|
||||
float get_ready_bitmap_path_[STAGE_COUNTER_]; // Vector con los puntos X por donde se desplaza el texto
|
||||
int stage_bitmap_path_[STAGE_COUNTER_]; // Vector con los puntos Y por donde se desplaza el texto
|
||||
int balloon_deploy_counter_ = 0; // Cuando se lanza una formación, se le da un valor y no sale otra hasta que llegue a cero
|
||||
int balloons_popped_ = 0; // Lleva la cuenta de los globos explotados
|
||||
int counter_ = 0; // Contador para el juego
|
||||
@@ -182,7 +174,6 @@ private:
|
||||
int menace_current_ = 0; // Nivel de amenaza actual
|
||||
int menace_threshold_ = 0; // Umbral del nivel de amenaza. Si el nivel de amenaza cae por debajo del umbral, se generan más globos. Si el umbral aumenta, aumenta el número de globos
|
||||
int power_ball_counter_ = 0; // Contador de formaciones enemigas entre la aparicion de una PowerBall y otra
|
||||
int stage_bitmap_counter_ = STAGE_COUNTER_; // Contador para el tiempo visible del texto de Stage
|
||||
int time_stopped_counter_ = 0; // Temporizador para llevar la cuenta del tiempo detenido
|
||||
int total_power_to_complete_game_; // La suma del poder necesario para completar todas las fases
|
||||
#ifdef DEBUG
|
||||
@@ -304,7 +295,10 @@ private:
|
||||
void freeItems();
|
||||
|
||||
// Crea un objeto PathSprite
|
||||
void createPathSprite(int x, std::shared_ptr<Texture> texture);
|
||||
void createItemText(int x, std::shared_ptr<Texture> texture);
|
||||
|
||||
// Crea un objeto PathSprite
|
||||
void createMessage(const std::vector<Path> &paths, std::shared_ptr<Texture> texture);
|
||||
|
||||
// Vacia el vector de smartsprites
|
||||
void freeSmartSprites();
|
||||
|
||||
@@ -139,9 +139,7 @@ Intro::Intro()
|
||||
texts_[8]->setSpeed(16);
|
||||
|
||||
for (auto &text : texts_)
|
||||
{
|
||||
text->center(param.game.game_area.center_x);
|
||||
}
|
||||
}
|
||||
|
||||
// Recarga todas las texturas
|
||||
@@ -171,9 +169,7 @@ void Intro::checkEvents()
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
|
||||
{
|
||||
reloadTextures();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,19 +63,23 @@ struct ParamNotification
|
||||
};
|
||||
|
||||
// Estructura para almacenar todos los parámetros del juego
|
||||
struct Param
|
||||
{
|
||||
ParamGame game; // Parametros relacionados con el juego
|
||||
ParamFade fade; // Parametros para ajustar el fade
|
||||
SDL_Rect scoreboard; // Posición y tamaño del marcador
|
||||
ParamTitle title; // Parametros con ajustes para la sección Title
|
||||
ParamBackground background; // Parametros que afectan a la clase Background
|
||||
std::vector<ParamBalloon> balloon; // Parametros de velocidad y gravedad de cada tipo de globo
|
||||
ParamNotification notification; // Opciones para las notificaciones
|
||||
struct Param {
|
||||
ParamGame game;
|
||||
ParamFade fade;
|
||||
SDL_Rect scoreboard;
|
||||
ParamTitle title;
|
||||
ParamBackground background;
|
||||
std::vector<ParamBalloon> balloon;
|
||||
ParamNotification notification;
|
||||
|
||||
Param() { balloon.reserve(4); }
|
||||
Param() : game(), fade(), scoreboard(), title(), background(), notification() {
|
||||
balloon.reserve(4);
|
||||
}
|
||||
};
|
||||
|
||||
extern Param param;
|
||||
|
||||
|
||||
extern Param param;
|
||||
|
||||
// Establece valores para los parametros a partir de un fichero de texto
|
||||
|
||||
@@ -1,40 +1,11 @@
|
||||
#include "path_sprite.h"
|
||||
#include <bits/std_abs.h> // Para abs
|
||||
#include <stdlib.h> // Para abs
|
||||
#include <utility> // Para move
|
||||
#include "moving_sprite.h" // Para MovingSprite
|
||||
#include "utils.h" // Para easeOutQuint
|
||||
#include <functional>
|
||||
class Texture; // lines 3-3
|
||||
|
||||
// Constructor
|
||||
PathSprite::PathSprite(std::shared_ptr<Texture> texture)
|
||||
: AnimatedSprite(texture) {}
|
||||
|
||||
// Actualiza la posición y comprueba si ha llegado a su destino
|
||||
void PathSprite::update()
|
||||
{
|
||||
if (enabled_)
|
||||
{
|
||||
moveThroughCurrentPath();
|
||||
goToNextPathOrDie();
|
||||
}
|
||||
}
|
||||
|
||||
// Añade un recorrido
|
||||
void PathSprite::addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction, int waiting_counter)
|
||||
{
|
||||
paths_.emplace_back(createPath(start, end, type, fixed_pos, steps, easingFunction), waiting_counter);
|
||||
}
|
||||
|
||||
// Añade un recorrido
|
||||
void PathSprite::addPath(std::vector<SDL_Point> spots, int waiting_counter)
|
||||
{
|
||||
paths_.emplace_back(std::move(spots), waiting_counter);
|
||||
}
|
||||
#include <bits/std_abs.h> // for abs
|
||||
#include <stdlib.h> // for abs
|
||||
#include <functional> // for function
|
||||
#include <utility> // for move
|
||||
|
||||
// Devuelve un vector con los puntos que conforman la ruta
|
||||
std::vector<SDL_Point> PathSprite::createPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction)
|
||||
std::vector<SDL_Point> createPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction)
|
||||
{
|
||||
std::vector<SDL_Point> v;
|
||||
v.reserve(steps);
|
||||
@@ -69,6 +40,59 @@ std::vector<SDL_Point> PathSprite::createPath(int start, int end, PathType type,
|
||||
return v;
|
||||
}
|
||||
|
||||
// Actualiza la posición y comprueba si ha llegado a su destino
|
||||
void PathSprite::update()
|
||||
{
|
||||
if (enabled_)
|
||||
{
|
||||
moveThroughCurrentPath();
|
||||
goToNextPathOrDie();
|
||||
}
|
||||
}
|
||||
|
||||
// Añade un recorrido
|
||||
void PathSprite::addPath(Path path, bool centered)
|
||||
{
|
||||
PathCentered path_centered = PathCentered::NONE;
|
||||
if (centered)
|
||||
path_centered = (path.spots.back().x == path.spots.front().x) ? PathCentered::ON_X : PathCentered::ON_Y;
|
||||
|
||||
switch (path_centered)
|
||||
{
|
||||
case PathCentered::ON_X:
|
||||
{
|
||||
const int x = path.spots.back().x - pos_.w / 2;
|
||||
for (auto &spot : path.spots)
|
||||
spot.x = x;
|
||||
paths_.emplace_back(path);
|
||||
break;
|
||||
}
|
||||
case PathCentered::ON_Y:
|
||||
{
|
||||
const int y = path.spots.back().y - pos_.h / 2;
|
||||
for (auto &spot : path.spots)
|
||||
spot.y = y;
|
||||
paths_.emplace_back(path);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
paths_.emplace_back(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Añade un recorrido
|
||||
void PathSprite::addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction, int waiting_counter)
|
||||
{
|
||||
paths_.emplace_back(createPath(start, end, type, fixed_pos, steps, easingFunction), waiting_counter);
|
||||
}
|
||||
|
||||
// Añade un recorrido
|
||||
void PathSprite::addPath(std::vector<SDL_Point> spots, int waiting_counter)
|
||||
{
|
||||
paths_.emplace_back(std::move(spots), waiting_counter);
|
||||
}
|
||||
|
||||
// Habilita el objeto
|
||||
void PathSprite::enable()
|
||||
{
|
||||
@@ -82,7 +106,7 @@ void PathSprite::moveThroughCurrentPath()
|
||||
|
||||
// Establece la posición
|
||||
const auto &p = path.spots.at(path.counter);
|
||||
MovingSprite::setPos(p.x, p.y);
|
||||
setPosition(p);
|
||||
|
||||
// Comprobar si ha terminado el recorrido
|
||||
if (!path.on_destination)
|
||||
@@ -101,7 +125,7 @@ void PathSprite::moveThroughCurrentPath()
|
||||
if (path.waiting_counter == 0)
|
||||
path.finished = true;
|
||||
else
|
||||
--path.waiting_counter;
|
||||
--path.waiting_counter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_rect.h> // Para SDL_Point
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <functional>
|
||||
#include <vector> // Para vector
|
||||
#include "animated_sprite.h" // Para AnimatedSprite
|
||||
class Texture; // lines 5-5
|
||||
#include <SDL2/SDL_rect.h> // for SDL_Point
|
||||
#include <functional> // for function
|
||||
#include <memory> // for shared_ptr
|
||||
#include <vector> // for vector
|
||||
#include "sprite.h" // for Sprite
|
||||
class Texture; // lines 8-8
|
||||
|
||||
enum class PathType
|
||||
{
|
||||
@@ -13,26 +13,35 @@ enum class PathType
|
||||
HORIZONTAL,
|
||||
};
|
||||
|
||||
enum class PathCentered
|
||||
{
|
||||
ON_X,
|
||||
ON_Y,
|
||||
NONE,
|
||||
};
|
||||
|
||||
// Estructuras
|
||||
struct Path
|
||||
{
|
||||
std::vector<SDL_Point> spots; // Puntos por los que se desplazará el sprite
|
||||
int waiting_counter; // Tiempo de espera una vez en el destino
|
||||
bool on_destination = false; // Indica si ha llegado al destino
|
||||
bool finished = false; // Indica si ha terminado de esperarse
|
||||
int counter = 0; // Contador interno
|
||||
|
||||
// Constructor
|
||||
Path(const std::vector<SDL_Point> &spots_init, int waiting_counter_init)
|
||||
: spots(spots_init), waiting_counter(waiting_counter_init) {}
|
||||
};
|
||||
|
||||
// Devuelve un vector con los puntos que conforman la ruta
|
||||
std::vector<SDL_Point> createPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction);
|
||||
|
||||
// Clase PathSprite
|
||||
class PathSprite : public AnimatedSprite
|
||||
class PathSprite : public Sprite
|
||||
{
|
||||
private:
|
||||
// Estructuras
|
||||
struct Path
|
||||
{
|
||||
std::vector<SDL_Point> spots; // Puntos por los que se desplazará el sprite
|
||||
int waiting_counter; // Tiempo de espera una vez en el destino
|
||||
bool on_destination = false; // Indica si ha llegado al destino
|
||||
bool finished = false; // Indica si ha terminado de esperarse
|
||||
int counter = 0; // Contador interno
|
||||
|
||||
// Constructor
|
||||
Path(const std::vector<SDL_Point> &spots_init, int waiting_counter_init)
|
||||
: spots(spots_init), waiting_counter(waiting_counter_init) {}
|
||||
};
|
||||
|
||||
// Variables
|
||||
bool finished_ = false; // Indica si ya ha terminado
|
||||
bool enabled_ = false; // Indica si el objeto está habilitado
|
||||
int current_path_ = 0; // Path que se está recorriendo actualmente
|
||||
std::vector<Path> paths_; // Caminos a recorrer por el sprite
|
||||
@@ -45,21 +54,20 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
explicit PathSprite(std::shared_ptr<Texture> texture);
|
||||
explicit PathSprite(std::shared_ptr<Texture> texture)
|
||||
: Sprite(texture) {}
|
||||
|
||||
// Destructor
|
||||
~PathSprite() = default;
|
||||
|
||||
// Actualiza la posición del sprite
|
||||
void update() override;
|
||||
void update();
|
||||
|
||||
// Añade un recorrido
|
||||
void addPath(Path path, bool centered = false);
|
||||
void addPath(std::vector<SDL_Point> spots, int waiting_counter);
|
||||
void addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction, int waiting_counter);
|
||||
|
||||
// Devuelve un vector con los puntos que conforman la ruta
|
||||
std::vector<SDL_Point> createPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction);
|
||||
|
||||
// Habilita el objeto
|
||||
void enable();
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
#include <iostream> // Para basic_ostream, operator<<, endl, cout, cerr
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include "asset.h" // Para Asset, AssetType
|
||||
#include "lang.h" // Para lang
|
||||
#include "jail_audio.h" // Para JA_LoadMusic, JA_LoadSound
|
||||
#include "screen.h" // Para Screen
|
||||
#include "text.h" // Para Text
|
||||
struct JA_Music_t;
|
||||
struct JA_Sound_t;
|
||||
|
||||
@@ -40,19 +42,10 @@ Resource::Resource()
|
||||
loadAnimations();
|
||||
loadDemoData();
|
||||
addPalettes();
|
||||
createTextures();
|
||||
std::cout << "\n** RESOURCES LOADED" << std::endl;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Resource::~Resource()
|
||||
{
|
||||
sounds_.clear();
|
||||
musics_.clear();
|
||||
textures_.clear();
|
||||
text_files_.clear();
|
||||
animations_.clear();
|
||||
}
|
||||
|
||||
// Obtiene el sonido a partir de un nombre
|
||||
JA_Sound_t *Resource::getSound(const std::string &name)
|
||||
{
|
||||
@@ -230,4 +223,50 @@ void Resource::addPalettes()
|
||||
|
||||
// Fuentes
|
||||
getTexture("smb2.gif")->addPaletteFromFile(Asset::get()->get("smb2_palette1.pal"));
|
||||
}
|
||||
}
|
||||
|
||||
// Crea texturas
|
||||
void Resource::createTextures()
|
||||
{
|
||||
struct NameAndText
|
||||
{
|
||||
std::string name;
|
||||
std::string text;
|
||||
|
||||
// Constructor
|
||||
NameAndText(const std::string &name_init, const std::string &text_init)
|
||||
: name(name_init), text(text_init) {}
|
||||
};
|
||||
|
||||
std::cout << "\n>> CREATING TEXTURES" << std::endl;
|
||||
auto text = std::make_unique<Text>(getTexture("04b_25.png"), getTextFile("04b_25.txt"));
|
||||
|
||||
// Tamaño normal
|
||||
std::vector<NameAndText> strings = {
|
||||
NameAndText("game_text_1000_points", "1.000"),
|
||||
NameAndText("game_text_2500_points", "2.500"),
|
||||
NameAndText("game_text_5000_points", "5.000"),
|
||||
NameAndText("game_text_powerup", lang::getText(117)),
|
||||
NameAndText("game_text_one_hit", lang::getText(118)),
|
||||
NameAndText("game_text_stop", lang::getText(119)),
|
||||
NameAndText("1000000_points", lang::getText(76))};
|
||||
|
||||
for (const auto &s : strings)
|
||||
{
|
||||
textures_.emplace_back(ResourceTexture(s.name, text->writeToTexture(s.text, 1, -2)));
|
||||
printWithDots("Texture : ", s.name, "[ DONE ]");
|
||||
}
|
||||
|
||||
// Tamaño doble
|
||||
std::vector<NameAndText> strings2X = {
|
||||
NameAndText("get_ready", lang::getText(75)),
|
||||
NameAndText("last_stage", lang::getText(79)),
|
||||
NameAndText("congratulations", lang::getText(50)),
|
||||
NameAndText("game_over", "Game Over")};
|
||||
|
||||
for (const auto &s : strings2X)
|
||||
{
|
||||
textures_.emplace_back(ResourceTexture(s.name, text->writeToTexture(s.text, 2, -2)));
|
||||
printWithDots("Texture : ", s.name, "[ DONE ]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,13 +99,16 @@ private:
|
||||
// Añade paletas a las texturas
|
||||
void addPalettes();
|
||||
|
||||
// Crea texturas
|
||||
void createTextures();
|
||||
|
||||
// [SINGLETON] Ahora el constructor y el destructor son privados, para no poder crear objetos resource desde fuera
|
||||
|
||||
// Constructor
|
||||
Resource();
|
||||
|
||||
// Destructor
|
||||
~Resource();
|
||||
~Resource() = default;
|
||||
|
||||
public:
|
||||
// [SINGLETON] Crearemos el objeto resource con esta función estática
|
||||
|
||||
@@ -141,7 +141,7 @@ void Screen::blit()
|
||||
|
||||
// Copia la textura de juego en el renderizador en la posición adecuada
|
||||
if (shake_effect_.enabled)
|
||||
SDL_RenderCopy(renderer_, game_canvas_, nullptr, nullptr);
|
||||
SDL_RenderCopy(renderer_, game_canvas_, nullptr, nullptr); // Esta copia es para evitar que se vea negro por los laterales
|
||||
SDL_RenderCopy(renderer_, game_canvas_, &src_rect_, &dst_rect_);
|
||||
|
||||
// Muestra por pantalla el renderizador
|
||||
@@ -375,10 +375,7 @@ void Screen::updateShakeEffect()
|
||||
// Pone la pantalla de color
|
||||
void Screen::flash(Color color, int lenght)
|
||||
{
|
||||
flash_effect_.enabled = true;
|
||||
flash_effect_.counter = 0;
|
||||
flash_effect_.lenght = lenght;
|
||||
flash_effect_.color = color;
|
||||
flash_effect_ = FlashEffect(true, lenght, color);
|
||||
}
|
||||
|
||||
// Actualiza y dibuja el efecto de flash en la pantalla
|
||||
@@ -387,14 +384,14 @@ void Screen::doFlash()
|
||||
if (flash_effect_.enabled)
|
||||
{
|
||||
// Dibuja el color del flash en la textura
|
||||
SDL_Texture *temp = SDL_GetRenderTarget(renderer_);
|
||||
SDL_SetRenderTarget(renderer_, game_canvas_);
|
||||
//auto temp = SDL_GetRenderTarget(renderer_);
|
||||
//SDL_SetRenderTarget(renderer_, game_canvas_);
|
||||
SDL_SetRenderDrawColor(renderer_, flash_effect_.color.r, flash_effect_.color.g, flash_effect_.color.b, 0xFF);
|
||||
SDL_RenderClear(renderer_);
|
||||
SDL_SetRenderTarget(renderer_, temp);
|
||||
//SDL_SetRenderTarget(renderer_, temp);
|
||||
|
||||
// Actualiza la lógica del efecto
|
||||
flash_effect_.counter < flash_effect_.lenght ? flash_effect_.counter++ : flash_effect_.enabled = false;
|
||||
flash_effect_.counter > 0 ? flash_effect_.counter-- : flash_effect_.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,11 +400,11 @@ void Screen::doAttenuate()
|
||||
{
|
||||
if (attenuate_effect_)
|
||||
{
|
||||
SDL_Texture *temp = SDL_GetRenderTarget(renderer_);
|
||||
SDL_SetRenderTarget(renderer_, game_canvas_);
|
||||
//auto temp = SDL_GetRenderTarget(renderer_);
|
||||
//SDL_SetRenderTarget(renderer_, game_canvas_);
|
||||
SDL_SetRenderDrawColor(renderer_, 0, 0, 0, 64);
|
||||
SDL_RenderFillRect(renderer_, nullptr);
|
||||
SDL_SetRenderTarget(renderer_, temp);
|
||||
//SDL_SetRenderTarget(renderer_, temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
int fps_ = 0; // Frames calculados en el último segundo
|
||||
std::string info_resolution_; // Texto con la informacion de la pantalla
|
||||
#ifdef DEBUG
|
||||
bool show_info_ = true; // Indica si ha de mostrar/ocultar la información de la pantalla
|
||||
bool show_info_ = false; // Indica si ha de mostrar/ocultar la información de la pantalla
|
||||
#else
|
||||
bool show_info_ = false; // Indica si ha de mostrar/ocultar la información de la pantalla
|
||||
#endif
|
||||
@@ -52,12 +52,11 @@ private:
|
||||
{
|
||||
bool enabled; // Indica si el efecto está activo
|
||||
int counter; // Contador para el efecto
|
||||
int lenght; // Duración del efecto
|
||||
Color color; // Color del efecto
|
||||
|
||||
// Constructor
|
||||
explicit FlashEffect(bool en = false, int cnt = 0, int len = 0, Color col = Color(0xFF, 0xFF, 0xFF))
|
||||
: enabled(en), counter(cnt), lenght(len), color(col) {}
|
||||
explicit FlashEffect(bool en = false, int cnt = 0, Color col = Color(0xFF, 0xFF, 0xFF))
|
||||
: enabled(en), counter(cnt), color(col) {}
|
||||
};
|
||||
|
||||
struct ShakeEffect
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
#include "text.h"
|
||||
#include <SDL2/SDL_rect.h> // Para SDL_Rect
|
||||
#include <fstream> // Para basic_ifstream, basic_istream, basic_ostream
|
||||
#include <iostream> // Para cerr
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include "sprite.h" // Para Sprite
|
||||
#include "texture.h" // Para Texture
|
||||
#include "utils.h" // Para Color, getFileName, printWithDots
|
||||
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
|
||||
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
||||
#include <SDL2/SDL_rect.h> // for SDL_Rect
|
||||
#include <SDL2/SDL_render.h> // for SDL_TEXTUREACCESS_TARGET
|
||||
#include <stddef.h> // for size_t
|
||||
#include <fstream> // for basic_ifstream, basic_istream, basic...
|
||||
#include <iostream> // for cerr
|
||||
#include <stdexcept> // for runtime_error
|
||||
#include "screen.h" // for Screen
|
||||
#include "sprite.h" // for Sprite
|
||||
#include "texture.h" // for Texture
|
||||
#include "utils.h" // for Color, getFileName, printWithDots
|
||||
|
||||
// Llena una estructuta TextFile desde un fichero
|
||||
std::shared_ptr<TextFile> loadTextFile(const std::string &file_path)
|
||||
@@ -45,9 +50,7 @@ std::shared_ptr<TextFile> loadTextFile(const std::string &file_path)
|
||||
{
|
||||
// Almacena solo las lineas impares
|
||||
if (line_read % 2 == 1)
|
||||
{
|
||||
tf->offset[index++].w = std::stoi(buffer);
|
||||
}
|
||||
|
||||
// Limpia el buffer
|
||||
buffer.clear();
|
||||
@@ -122,26 +125,50 @@ Text::Text(std::shared_ptr<Texture> texture, std::shared_ptr<TextFile> text_file
|
||||
// Escribe texto en pantalla
|
||||
void Text::write(int x, int y, const std::string &text, int kerning, int lenght)
|
||||
{
|
||||
auto shift = 0;
|
||||
int shift = 0;
|
||||
|
||||
if (lenght == -1)
|
||||
{
|
||||
lenght = text.length();
|
||||
}
|
||||
|
||||
sprite_->setY(y);
|
||||
const auto width = sprite_->getWidth();
|
||||
const auto height = sprite_->getHeight();
|
||||
for (int i = 0; i < lenght; ++i)
|
||||
{
|
||||
const auto index = static_cast<int>(text[i]);
|
||||
sprite_->setSpriteClip(offset_[index].x, offset_[index].y, width, height);
|
||||
auto index = static_cast<int>(text[i]);
|
||||
sprite_->setSpriteClip(offset_[index].x, offset_[index].y, box_width_, box_height_);
|
||||
sprite_->setX(x + shift);
|
||||
sprite_->render();
|
||||
shift += fixed_width_ ? box_width_ : (offset_[int(text[i])].w + kerning);
|
||||
shift += offset_[static_cast<int>(text[i])].w + kerning;
|
||||
}
|
||||
}
|
||||
|
||||
// Escribe texto en pantalla
|
||||
void Text::write2X(int x, int y, const std::string &text, int kerning)
|
||||
{
|
||||
int shift = 0;
|
||||
for (size_t i = 0; i < text.length(); ++i)
|
||||
{
|
||||
auto index = static_cast<size_t>(text[i]);
|
||||
SDL_Rect rect = {offset_[index].x, offset_[index].y, box_width_, box_height_};
|
||||
sprite_->getTexture()->render(x + shift, y, &rect, 2.0f, 2.0f);
|
||||
shift += (offset_[index].w + kerning) * 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Escribe el texto en una textura
|
||||
std::shared_ptr<Texture> Text::writeToTexture(const std::string &text, int zoom, int kerning)
|
||||
{
|
||||
auto renderer = Screen::get()->getRenderer();
|
||||
auto texture = std::make_shared<Texture>(renderer);
|
||||
auto width = lenght(text, kerning) * zoom;
|
||||
auto height = box_height_ * zoom;
|
||||
texture->createBlank(width, height, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET);
|
||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
texture->setAsRenderTarget(renderer);
|
||||
zoom == 1 ? write(0, 0, text, kerning) : write2X(0, 0, text, kerning);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
// Escribe el texto con colores
|
||||
void Text::writeColored(int x, int y, const std::string &text, Color color, int kerning, int lenght)
|
||||
{
|
||||
@@ -211,12 +238,9 @@ void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerni
|
||||
// Obtiene la longitud en pixels de una cadena
|
||||
int Text::lenght(const std::string &text, int kerning) const
|
||||
{
|
||||
auto shift = 0;
|
||||
|
||||
for (int i = 0; i < (int)text.length(); ++i)
|
||||
{
|
||||
shift += (offset_[int(text[i])].w + kerning);
|
||||
}
|
||||
int shift = 0;
|
||||
for (size_t i = 0; i < text.length(); ++i)
|
||||
shift += (offset_[static_cast<int>(text[i])].w + kerning);
|
||||
|
||||
// Descuenta el kerning del último caracter
|
||||
return shift - kerning;
|
||||
|
||||
@@ -50,6 +50,10 @@ public:
|
||||
|
||||
// Escribe el texto en pantalla
|
||||
void write(int x, int y, const std::string &text, int kerning = 1, int lenght = -1);
|
||||
void write2X(int x, int y, const std::string &text, int kerning = 1);
|
||||
|
||||
// Escribe el texto en una textura
|
||||
std::shared_ptr<Texture> writeToTexture(const std::string &text, int zoom = 1, int kerning = 1);
|
||||
|
||||
// Escribe el texto con colores
|
||||
void writeColored(int x, int y, const std::string &text, Color color, int kerning = 1, int lenght = -1);
|
||||
|
||||
@@ -60,6 +60,9 @@ Texture::~Texture()
|
||||
// Carga una imagen desde un fichero
|
||||
bool Texture::loadFromFile(const std::string &file_path)
|
||||
{
|
||||
if (file_path.empty())
|
||||
return false;
|
||||
|
||||
int req_format = STBI_rgb_alpha;
|
||||
int width, height, orig_format;
|
||||
unsigned char *data = stbi_load(file_path.c_str(), &width, &height, &orig_format, req_format);
|
||||
|
||||