AST3_C/src/drawlevel.c

97 lines
2.3 KiB
C

#include "drawlevel.h"
#include <gint/std/string.h>
#include <gint/display.h>
#include "define.h"
#define VISIBLE_RECT 35
extern bopti_image_t img_solid_0; //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_keyblock; //block link to the key1
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_key2block; //block link to the key 2
extern bopti_image_t img_damaged; //damaged block
void draw_player(int x, int y)
{
dimage(x,y,&img_player);
}
void draw_level(char level[])
{
dclear(C_WHITE);
unsigned int x = 0;
unsigned int y = 0;
unsigned int i = 0;
while (i!=strlen(level))
{
switch(level[i])
{
case '1': //solid block
dimage(x,y,&img_solid_0);
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
dimage(x,y,&img_keyblock);
break;
case 'k': //key1
dimage(x,y,&img_key1);
break;
case '4': //block link to the key2
dimage(x,y,&img_key2block);
break;
case 'K': //key2
dimage(x,y,&img_key2);
break;
case 'c': //chrono blocks
dimage(x,y,&img_chrono1);
break;
case 'C': //chrono blocks
dimage(x,y,&img_chrono2);
break;
case 'b': //blackout blocks
dimage(x,y,&img_blackout);
break;
case 'B': //damaged block
dimage(x,y,&img_damaged);
break;
}
x+=16;
if(x==16*25)
{
x=0;
y+=16;
}
i++;
}
}
void draw_blackout(int x, int y)
{
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
}
void draw_timer(unsigned int frame)
{
dprint_opt(0, 0, C_WHITE, C_BLACK, DTEXT_LEFT, DTEXT_TOP, "%u.%02u",(frame)/FPS, (frame)%FPS);
}