2020-06-25 23:53:57 +02:00
|
|
|
#include "drawlevel.h"
|
2020-07-02 20:09:23 +02:00
|
|
|
#include "define.h"
|
2020-08-27 00:31:22 +02:00
|
|
|
#include "times.h"
|
2021-03-23 14:21:59 +01:00
|
|
|
#include <gint/display.h>
|
|
|
|
#include <gint/std/string.h>
|
2020-06-25 23:53:57 +02:00
|
|
|
|
2020-07-16 02:06:57 +02:00
|
|
|
#define VISIBLE_RECT 35
|
|
|
|
|
2021-03-23 14:21:59 +01:00
|
|
|
extern bopti_image_t img_solid; // solid block
|
|
|
|
extern bopti_image_t img_coin; // facultative coin
|
|
|
|
extern bopti_image_t img_dead; // dead block
|
|
|
|
extern bopti_image_t img_player; // player
|
|
|
|
extern bopti_image_t img_end; // end of level
|
|
|
|
extern bopti_image_t img_key1; // key 1
|
|
|
|
extern bopti_image_t img_blackout; // blackout
|
|
|
|
extern bopti_image_t img_chrono1; // chronoblock
|
|
|
|
extern bopti_image_t img_chrono2; // chronoblock 2
|
|
|
|
extern bopti_image_t img_key2; // key 2
|
|
|
|
extern bopti_image_t img_damaged; // damaged block
|
|
|
|
extern bopti_image_t img_chock; // chock block
|
|
|
|
extern bopti_image_t img_switch; // switch block
|
|
|
|
extern bopti_image_t img_ice; // switch block
|
|
|
|
extern bopti_image_t img_appear; // appear block
|
2020-08-29 16:40:25 +02:00
|
|
|
|
2020-08-27 00:31:22 +02:00
|
|
|
extern bopti_image_t img_endscreen;
|
2020-08-28 00:36:42 +02:00
|
|
|
extern bopti_image_t img_new;
|
2020-06-25 23:53:57 +02:00
|
|
|
|
2020-08-22 01:24:50 +02:00
|
|
|
void draw_player(int x, int y, char type)
|
2020-06-25 23:53:57 +02:00
|
|
|
{
|
2021-03-23 14:21:59 +01:00
|
|
|
dsubimage(x, y, &img_player, 12 * (type - 1), 0, 12, 12, DIMAGE_NONE);
|
2020-06-25 23:53:57 +02:00
|
|
|
}
|
2020-08-22 01:24:50 +02:00
|
|
|
|
2020-06-25 23:53:57 +02:00
|
|
|
void draw_level(char level[])
|
|
|
|
{
|
2020-07-02 00:05:32 +02:00
|
|
|
dclear(C_WHITE);
|
2020-06-25 23:53:57 +02:00
|
|
|
unsigned int x = 0;
|
|
|
|
unsigned int y = 0;
|
|
|
|
unsigned int i = 0;
|
2021-03-23 14:21:59 +01:00
|
|
|
while (i != strlen(level)) {
|
|
|
|
switch (level[i]) {
|
|
|
|
case '1': // solid block
|
|
|
|
dimage(x, y, &img_solid);
|
|
|
|
break;
|
|
|
|
case 't': // coin (treasure)
|
|
|
|
dimage(x, y, &img_coin);
|
|
|
|
break;
|
|
|
|
case 'd': // dead block
|
|
|
|
dimage(x, y, &img_dead);
|
|
|
|
break;
|
|
|
|
case 'e': // end of level
|
|
|
|
dimage(x, y, &img_end);
|
|
|
|
break;
|
|
|
|
case '3': // block link to the key1
|
|
|
|
dsubimage(x, y, &img_key1, 0, 0, 16, 16, DIMAGE_NONE);
|
|
|
|
break;
|
|
|
|
case 'k': // key1
|
|
|
|
dsubimage(x, y, &img_key1, 16, 0, 16, 16, DIMAGE_NONE);
|
|
|
|
break;
|
|
|
|
case 'a': // block link to the key2 when it's not on
|
|
|
|
dsubimage(x, y, &img_key2, 0, 0, 16, 16, DIMAGE_NONE);
|
|
|
|
break;
|
|
|
|
case '4': // block link to the key2
|
|
|
|
dsubimage(x, y, &img_key2, 16, 0, 16, 16, DIMAGE_NONE);
|
|
|
|
break;
|
|
|
|
case 'K': // key2
|
|
|
|
dsubimage(x, y, &img_key2, 32, 0, 16, 16, DIMAGE_NONE);
|
|
|
|
break;
|
|
|
|
case 'c': // chrono blocks
|
|
|
|
dimage(x, y, &img_chrono1);
|
|
|
|
break;
|
|
|
|
case 'C': // chrono blocks
|
|
|
|
dsubimage(x, y, &img_chrono2, 16, 0, 16, 16,
|
|
|
|
DIMAGE_NONE);
|
|
|
|
break;
|
|
|
|
case 'b': // blackout blocks
|
|
|
|
dimage(x, y, &img_blackout);
|
|
|
|
break;
|
|
|
|
case 'B': // damaged block
|
|
|
|
dimage(x, y, &img_damaged);
|
|
|
|
break;
|
|
|
|
case 'l': // chock blocks
|
|
|
|
dimage(x, y, &img_chock);
|
|
|
|
break;
|
|
|
|
case 'i': // chock blocks
|
|
|
|
dimage(x, y, &img_ice);
|
|
|
|
break;
|
|
|
|
case 'S': // chock blocks
|
|
|
|
dimage(x, y, &img_switch);
|
|
|
|
break;
|
|
|
|
case 'h': // void appear blocks
|
|
|
|
dsubimage(x, y, &img_appear, 0, 0, 16, 16, DIMAGE_NONE);
|
|
|
|
break;
|
|
|
|
case 'H': // appear blocks
|
|
|
|
dsubimage(x, y, &img_appear, 16, 0, 16, 16,
|
|
|
|
DIMAGE_NONE);
|
|
|
|
break;
|
|
|
|
case 'y': // appear blocks
|
|
|
|
dsubimage(x, y, &img_appear, 0, 0, 16, 16, DIMAGE_NONE);
|
|
|
|
break;
|
|
|
|
case 'm': // chronoappear blocks
|
|
|
|
dsubimage(x, y, &img_chrono2, 0, 0, 16, 16,
|
|
|
|
DIMAGE_NONE);
|
|
|
|
break;
|
2020-06-25 23:53:57 +02:00
|
|
|
}
|
2021-03-23 14:21:59 +01:00
|
|
|
x += 16;
|
|
|
|
if (x == 16 * 25) {
|
|
|
|
x = 0;
|
|
|
|
y += 16;
|
2020-06-25 23:53:57 +02:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2020-07-02 20:09:23 +02:00
|
|
|
|
2020-07-16 02:06:57 +02:00
|
|
|
void draw_blackout(int x, int y)
|
|
|
|
{
|
2021-03-23 14:21:59 +01:00
|
|
|
x += 5;
|
|
|
|
y += 5;
|
|
|
|
drect(0, 0, 395, y - VISIBLE_RECT, C_BLACK); // top rect
|
|
|
|
drect(0, y - VISIBLE_RECT, x - VISIBLE_RECT, y + VISIBLE_RECT,
|
|
|
|
C_BLACK); // left rect
|
|
|
|
drect(x + VISIBLE_RECT, y - VISIBLE_RECT, 395, y + VISIBLE_RECT,
|
|
|
|
C_BLACK); // right rect
|
|
|
|
drect(0, y + VISIBLE_RECT, 395, 223, C_BLACK); // bottom rect
|
2020-07-16 02:06:57 +02:00
|
|
|
}
|
|
|
|
|
2020-07-02 20:09:23 +02:00
|
|
|
void draw_timer(unsigned int frame)
|
|
|
|
{
|
2020-08-29 17:19:05 +02:00
|
|
|
float framefloat = frame;
|
2021-03-23 14:21:59 +01:00
|
|
|
dprint_opt(0, 0, C_WHITE, C_BLACK, DTEXT_LEFT, DTEXT_TOP, "%.2j",
|
|
|
|
(int)(framefloat / FPS * 100));
|
2020-07-02 20:09:23 +02:00
|
|
|
}
|
2020-08-27 00:31:22 +02:00
|
|
|
|
2020-08-28 00:36:42 +02:00
|
|
|
void draw_end(int framelevel, int id_level, char record)
|
2020-08-27 00:31:22 +02:00
|
|
|
{
|
|
|
|
float framefloat = framelevel;
|
2021-04-29 21:13:13 +02:00
|
|
|
<<<<<<< HEAD
|
2020-08-27 00:31:22 +02:00
|
|
|
dimage(144,60,&img_endscreen);
|
2020-08-28 00:36:42 +02:00
|
|
|
if(record!=2)
|
|
|
|
{
|
|
|
|
dprint(166, 87, C_RED, "%.2j",(int)(framefloat/FPS*100));
|
2021-04-29 21:13:13 +02:00
|
|
|
=======
|
2021-03-23 14:21:59 +01:00
|
|
|
dimage(144, 60, &img_endscreen);
|
|
|
|
if (record != 2) {
|
|
|
|
dprint_opt(220, 115, C_WHITE, C_BLACK, DTEXT_LEFT, DTEXT_TOP,
|
|
|
|
"%d", framelevel);
|
|
|
|
dprint(166, 87, C_RED, "%.2j", (int)(framefloat / FPS * 100));
|
2021-04-29 21:13:13 +02:00
|
|
|
>>>>>>> dd8e25d259480e2e6761ff105d419e40e2382bda
|
2020-08-28 00:36:42 +02:00
|
|
|
check_medal(framelevel, id_level, 178, 140);
|
2021-03-23 14:21:59 +01:00
|
|
|
if (record == 1)
|
|
|
|
dimage(60, 100, &img_new);
|
|
|
|
} else {
|
2020-08-28 00:36:42 +02:00
|
|
|
dprint(166, 87, C_RED, "GG !");
|
2021-03-23 14:21:59 +01:00
|
|
|
dprint(178, 140, C_RED, "%.2j", (int)(framefloat / FPS * 100));
|
2020-08-28 00:36:42 +02:00
|
|
|
}
|
2020-08-27 00:31:22 +02:00
|
|
|
dupdate();
|
|
|
|
}
|