Plague-fx/src/display_engine.c

128 lines
4.2 KiB
C

#include <gint/display.h>
#include "mutation_engine.h"
#include "display_engine.h"
void display_background(const int background)
{
extern const bopti_image_t img_bground;
dsubimage(0, 0, &img_bground, 0, 65 * (background - 1), 128, 64, DIMAGE_NONE);
}
void display_foreground(const int background, const struct game *current_game)
{
extern const bopti_image_t img_mutations;
extern const bopti_image_t img_planes;
GUNUSED int length;
switch (background)
{
case 1:
for (int i = 0; current_game->planes[i]; i++)
{
dsubimage(current_game->planes[i]->x - 4, current_game->planes[i]->y - 4, &img_planes, 0, 8 * (current_game->planes[i]->direction - 1), 8, 8, DIMAGE_NONE);
}
break;
case 2:
for (int i = 0; current_game->planes[i]; i++)
{
if (current_game->planes[i]->y + 8 < 53) dsubimage(current_game->planes[i]->x - 4, current_game->planes[i]->y - 4, &img_planes, 0, 8 * (current_game->planes[i]->direction - 1), 8, 8, DIMAGE_NONE);
}
int length = 74 * current_game->research / current_game->limit;
dprint(9, 58, C_BLACK, "%d", current_game->dna);
dline(51, 60, 51 + length, 60, C_BLACK);
dline(51, 59, 51 + length, 59, C_BLACK);
break;
case 3:
dprint(102, 37, C_BLACK, "%d", current_game->dna);
length = 67 * current_game->contagion / 26;
dline(57, 48, 57 + length, 48, C_BLACK);
dline(57, 49, 57 + length, 49, C_BLACK);
length = 67 * current_game->severity / 20;
dline(57, 54, 57 + length, 54, C_BLACK);
dline(57, 55, 57 + length, 55, C_BLACK);
length = 67 * current_game->lethality / 33;
dline(57, 60, 57 + length, 60, C_BLACK);
dline(57, 61, 57 + length, 61, C_BLACK);
if (current_game->mutations_selected[0]) dsubimage(5, 15, &img_mutations, 0, 16 * (current_game->mutations_selected[0] - 1), 15, 15, 0);
if (current_game->mutations_selected[1]) dsubimage(35, 15, &img_mutations, 16, 16 * (current_game->mutations_selected[1] - 1), 15, 15, 0);
if (current_game->mutations_selected[2]) dsubimage(65, 15, &img_mutations, 32, 16 * (current_game->mutations_selected[2] - 1), 15, 15, 0);
break;
// case 6: statistics about humans
}
}
void display_mutation(const int table[4][8], const struct cursor c, const int mutation_menu)
{
extern const bopti_image_t img_mutations;
extern bopti_image_t img_cursor;
dclear(C_WHITE);
display_background(5);
for (int i = 0 ; i < 4 ; i++)
{
for (int j = 0 ; j < 8; j++)
{
if (table[i][j]) dsubimage(j*16, i*16, &img_mutations, 16 * (mutation_menu - 1), 16 * (table[i][j] - 1), 15, 15, DIMAGE_NONE);
}
}
dsubimage((16 * c.x) - 1, (16 * c.y) - 1, &img_cursor, 0, 17 * (c.display), 17, 17, DIMAGE_NONE);
dupdate();
}
void display_mutation_buy(const struct cursor c, const int mutation_menu, const int table[4][8], const int button_selected)
{
extern const bopti_image_t img_mutations;
const int id = table[c.y][c.x];
struct mutation *mutation_data = get_mutation_data(mutation_menu, id);
dclear(C_WHITE);
display_background(4);
dsubimage(3, 21, &img_mutations, 16 * (mutation_menu - 1), 16 * (id - 1), 15, 15, DIMAGE_NONE);
dprint(47, 25, C_BLACK, mutation_data->name);
dprint(81, 33, C_BLACK, "%d", mutation_data->dna);
dprint(81, 41, C_BLACK, "%d", mutation_data->contagion);
dprint(81, 49, C_BLACK, "%d", mutation_data->lethality);
dprint(81, 57, C_BLACK, "%d", mutation_data->severity);
if (button_selected) drect(81, 2, 123, 8, C_INVERT);
else drect(81, 12, 123, 18, C_INVERT);
dupdate();
}
void display_message(const char *msg[5])
{
dclear(C_WHITE);
display_background(7);
for (int i = 0; i < 5; i ++) dprint(54, 6 * i + 4, C_BLACK, msg[i]);
dupdate();
}
void display_dna_animation(const int frame)
{
extern bopti_image_t img_dna;
dsubimage(114, 29, &img_dna, 11 * (frame - 1), 0, 11, 32, DIMAGE_NONE);
dupdate();
}