This commit is contained in:
KikooDX 2021-11-12 17:49:16 +01:00
parent 2a35702b4c
commit 7b7876cea7
9 changed files with 55 additions and 1 deletions

View File

@ -22,6 +22,7 @@ set(SOURCES
src/shatter.c
src/particles.c
src/stars.c
src/results.c
)
set(LEVELS
@ -39,6 +40,7 @@ set(ASSETS
res/shatter.png
res/player.png
res/title.png
res/font.png
${LEVELS}
)

1
README Normal file
View File

@ -0,0 +1 @@
ridmi

3
inc/results.h Normal file
View File

@ -0,0 +1,3 @@
#pragma once
void results_draw(void);

BIN
res/font.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -11,3 +11,9 @@ title.png:
type: bopti-image
name: bimg_title
profile: p4
font.png:
type: font
name: font_georgia
charset: print
grid.size: 22x28
proportional: true

View File

@ -16,6 +16,7 @@ static const struct LevelBin *levels[] = {&lvl_0, &lvl_1, &lvl_2, &lvl_3,
void
level_load(int id)
{
extern int end;
const struct LevelBin *s = levels[id];
int i = s->width * s->height;
self.width = s->width;
@ -27,6 +28,8 @@ level_load(int id)
self.data[i] = s->data[i];
player_init(level_find(TILE_PLAYER));
particles_init();
if (levels[self.id + 1] == NULL)
end = 1;
}
void

View File

@ -4,6 +4,7 @@
#include "level.h"
#include "particles.h"
#include "player.h"
#include "results.h"
#include "stars.h"
#include "vec.h"
#include <gint/cpu.h>
@ -16,6 +17,10 @@ static void update(void);
static void draw(void);
static int callback(volatile int *);
int time = 0;
int deaths = 0;
int end = 0;
int
main(void)
{
@ -23,6 +28,7 @@ main(void)
int frameskip = 1;
volatile int has_ticked = 0;
extern bopti_image_t bimg_title;
extern font_t font_georgia;
srand(1337);
timer = timer_configure(TIMER_ANY, 1000000 / TARGET_FPS,
@ -32,6 +38,7 @@ main(void)
stars_init();
level_load(0);
camera_init(player_pos());
dfont(&font_georgia);
dimage(0, 0, &bimg_title);
dupdate();
@ -50,8 +57,10 @@ main(void)
}
while (!has_ticked)
sleep();
while (has_ticked)
while (has_ticked) {
time += has_ticked;
has_ticked = 0;
}
update();
}
}
@ -79,6 +88,8 @@ draw(void)
level_draw();
player_draw();
particles_draw();
if (end)
results_draw();
dupdate();
}

View File

@ -144,6 +144,8 @@ walljump(void)
static void
death(void)
{
extern int deaths;
deaths++;
level_reload();
}

26
src/results.c Normal file
View File

@ -0,0 +1,26 @@
#include "results.h"
#include "conf.h"
#include <gint/display.h>
void
results_draw(void)
{
extern int time, deaths;
static int disp_time = -1;
static int disp_deaths = -1;
if (disp_time == -1) {
disp_time = time;
if (disp_time >= TARGET_FPS * 60 * 100)
disp_time = TARGET_FPS * 60 * 100 - 1;
}
if (disp_deaths == -1) {
disp_deaths = deaths;
if (disp_deaths > 99)
disp_deaths = 99;
}
drect(DWIDTH / 4, 24, DWIDTH * 3 / 4, 120, C_BLACK);
dprint_opt(DWIDTH / 2, 56, C_WHITE, C_BLACK, DTEXT_CENTER, DTEXT_MIDDLE,
"time %02d:%02d", disp_time / 3600, disp_time / 60);
dprint_opt(DWIDTH / 2, 88, C_WHITE, C_BLACK, DTEXT_CENTER, DTEXT_MIDDLE,
"%d deaths", disp_deaths);
}