Agrego la vida.

master
Félix Arreola Rodríguez 2018-06-19 15:24:02 -05:00
parent bbcd25ff80
commit 1afce9185d
5 changed files with 92 additions and 5 deletions

View File

@ -125,7 +125,8 @@ nobase_dist_gamedata_DATA = images/background.png \
images/anvil_20.png \ images/anvil_20.png \
images/anvil_21.png \ images/anvil_21.png \
images/anvil_22.png \ images/anvil_22.png \
images/anvil_23.png images/anvil_23.png \
images/oneup.png
# Instalar los archivos .desktop e iconos # Instalar los archivos .desktop e iconos
applicationsdir = $(datadir)/applications applicationsdir = $(datadir)/applications

View File

@ -11,7 +11,8 @@ nobase_dist_collidergamedata_DATA = \
penguin_8.col \ penguin_8.col \
penguin_9.col \ penguin_9.col \
penguin_10.col \ penguin_10.col \
bag_3.col bag_3.col \
oneup.col
noinst_PROGRAMS = penguin-generator collider-generator noinst_PROGRAMS = penguin-generator collider-generator
penguin_generator_SOURCES = generate-penguins.c \ penguin_generator_SOURCES = generate-penguins.c \
@ -56,3 +57,4 @@ colliders: collider-generator penguin-generator
rm penguin_1.png penguin_2.png penguin_3.png penguin_4.png penguin_5.png penguin_6.png penguin_7.png penguin_8.png penguin_9.png penguin_10.png rm penguin_1.png penguin_2.png penguin_3.png penguin_4.png penguin_5.png penguin_6.png penguin_7.png penguin_8.png penguin_9.png penguin_10.png
$(COLLIDER_GENERATOR) $(top_srcdir)/data/images/bag_3.png bag_3.col $(COLLIDER_GENERATOR) $(top_srcdir)/data/images/bag_3.png bag_3.col
$(COLLIDER_GENERATOR) $(top_srcdir)/data/images/oneup.png oneup.col

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -185,6 +185,8 @@ enum {
IMG_ANVIL_22, IMG_ANVIL_22,
IMG_ANVIL_23, IMG_ANVIL_23,
IMG_ONEUP,
NUM_IMAGES NUM_IMAGES
}; };
@ -284,7 +286,9 @@ const char *images_names[NUM_IMAGES] = {
"images/anvil_20.png", "images/anvil_20.png",
"images/anvil_21.png", "images/anvil_21.png",
"images/anvil_22.png", "images/anvil_22.png",
"images/anvil_23.png" "images/anvil_23.png",
"images/oneup.png"
}; };
enum { enum {
@ -435,6 +439,8 @@ enum {
COLLIDER_PENGUIN_9, COLLIDER_PENGUIN_9,
COLLIDER_PENGUIN_10, COLLIDER_PENGUIN_10,
COLLIDER_ONEUP,
NUM_COLLIDERS NUM_COLLIDERS
}; };
@ -450,7 +456,9 @@ const char *collider_names[NUM_COLLIDERS] = {
"collider/penguin_7.col", "collider/penguin_7.col",
"collider/penguin_8.col", "collider/penguin_8.col",
"collider/penguin_9.col", "collider/penguin_9.col",
"collider/penguin_10.col" "collider/penguin_10.col",
"collider/oneup.col"
}; };
const SDL_Color penguin_colors[18] = { const SDL_Color penguin_colors[18] = {
@ -686,6 +694,44 @@ const int anvil_collider_offsets [23][2] = {
{482, 399} {482, 399}
}; };
const int oneup_offsets[35][2] = {
{636, 142},
{624, 130},
{611, 119},
{598, 107},
{586, 96},
{573, 84},
{560, 72},
{547, 70},
{534, 68},
{521, 66},
{507, 64},
{494, 62},
{481, 60},
{468, 58},
{454, 56},
{442, 67},
{431, 80},
{420, 93},
{409, 105},
{398, 118},
{392, 139},
{386, 159},
{380, 180},
{373, 201},
{367, 221},
{361, 242},
{355, 263},
{349, 284},
{343, 304},
{337, 325},
{334, 351},
{330, 378},
{327, 404},
{324, 431},
{321, 458}
};
/* Prototipos de función */ /* Prototipos de función */
int game_intro (void); int game_intro (void);
int game_loop (void); int game_loop (void);
@ -858,6 +904,7 @@ int game_loop (void) {
int airbone = 0, max_airbone = 1; int airbone = 0, max_airbone = 1;
int nivel = 1; int nivel = 1;
int anvil_out = FALSE; int anvil_out = FALSE;
int oneup_toggle = TRUE;
int bag_stack = 0; int bag_stack = 0;
@ -898,6 +945,7 @@ int game_loop (void) {
airbone = 1000; airbone = 1000;
printf ("Next level visible\n"); printf ("Next level visible\n");
oneup_toggle = TRUE;
} else { } else {
/* TODO: Fin del juego */ /* TODO: Fin del juego */
} }
@ -964,6 +1012,10 @@ int game_loop (void) {
add_bag (5); add_bag (5);
airbone++; airbone++;
anvil_out = TRUE; anvil_out = TRUE;
} else if (i == 4 && oneup_toggle == TRUE && nivel >= 3 && nivel % 2 == 1) {
add_bag (4);
oneup_toggle = FALSE;
airbone++;
} }
} }
} }
@ -1045,6 +1097,20 @@ int game_loop (void) {
thisbag = nextbag; thisbag = nextbag;
continue; continue;
} }
} else if (j < 0 && thisbag->bag == 4) {
i = collider_hittest (colliders[COLLIDER_ONEUP], thisbag->object_points[thisbag->frame][0], thisbag->object_points[thisbag->frame][1], colliders[k], penguinx - 120, 251);
if (i == SDL_TRUE) {
vidas++;
/* TODO: Reproducir sonido boing */
/* TODO: Mostrar la notificación de 1 vida */
airbone--;
delete_bag (thisbag);
thisbag = nextbag;
continue;
}
} }
if (thisbag->bag <= 3) { if (thisbag->bag <= 3) {
@ -1059,7 +1125,10 @@ int game_loop (void) {
} }
} }
if (j >= 35) { if (thisbag->bag == 4 && j >= 0) {
/* Eliminar la vida */
delete_bag (thisbag);
} else if (j >= 35) {
/* Eliminar esta bolsa */ /* Eliminar esta bolsa */
delete_bag (thisbag); delete_bag (thisbag);
} }
@ -1163,11 +1232,23 @@ int game_loop (void) {
j = thisbag->frame - thisbag->throw_length; j = thisbag->frame - thisbag->throw_length;
} }
rect.w = images[i]->w;
rect.h = images[i]->h;
if (i == IMG_ANVIL_23 && j > 25) { if (i == IMG_ANVIL_23 && j > 25) {
SDL_gfxBlitRGBAWithAlpha (images[i], NULL, screen, &rect, 255 - SDL_ALPHA_OPAQUE * (j - 25) / 10); SDL_gfxBlitRGBAWithAlpha (images[i], NULL, screen, &rect, 255 - SDL_ALPHA_OPAQUE * (j - 25) / 10);
} else { } else {
SDL_BlitSurface (images[i], NULL, screen, &rect); SDL_BlitSurface (images[i], NULL, screen, &rect);
} }
} else if (thisbag->bag == 4) {
/* Dibujar la vida */
i = IMG_ONEUP;
rect.x = thisbag->object_points[thisbag->frame][0];
rect.y = thisbag->object_points[thisbag->frame][1];
rect.w = images[i]->w;
rect.h = images[i]->h;
SDL_BlitSurface (images[i], NULL, screen, &rect);
} }
thisbag = thisbag->next; thisbag = thisbag->next;
@ -1553,6 +1634,9 @@ void add_bag (int tipo) {
} else if (tipo == 5) { } else if (tipo == 5) {
new->throw_length = 24; new->throw_length = 24;
new->object_points = anvil_offsets; new->object_points = anvil_offsets;
} else if (tipo == 4) {
new->throw_length = 35;
new->object_points = oneup_offsets;
} }
/* Ahora sus campos para lista doble ligada */ /* Ahora sus campos para lista doble ligada */