Display level name

This commit is contained in:
KikooDX 2021-04-08 00:38:40 +02:00
parent 85dc08d013
commit c89a04a27b
6 changed files with 24 additions and 14 deletions

View File

@ -12,13 +12,14 @@ for PACK in *; do
cd "$PACK"
for LEVEL in *; do
LEVEL_NAME="$(basename $LEVEL | cut -c2- |
awk -F '.' '{print $1}')"
awk -F '.' '{print $1}' |
tr '[:lower:]' '[:upper:]')"
[ -z "$LEVEL_NAMES" ] &&
LEVEL_NAMES="
\"$LEVEL_NAME\"" ||
LEVEL_NAMES="$LEVEL_NAMES,
\"$LEVEL_NAME\""
printf 'u"\\\\\\\\fls0\\\\mtem\\\\%s\\\\' "$PACK_NAME"
printf '\tu"\\\\\\\\fls0\\\\mtem\\\\%s\\\\' "$PACK_NAME"
printf '%s",\n' "$LEVEL"
done
cd ..

View File

@ -15,17 +15,21 @@ void level_draw(void)
const int tileset_width = img_tileset.width / TILE_WIDTH;
y = level.height;
while (y --> 0) {
while (y-- > 0) {
x = level.width;
while (x --> 0) {
while (x-- > 0) {
const int draw_x = x * TILE_WIDTH;
const int draw_y = y * TILE_HEIGHT;
const Tile tile =
level.data[x + y * level.width];
img_render_vram(img_sub(img_tileset,
(int)(tile % tileset_width) * TILE_WIDTH,
(int)(tile / tileset_width) * TILE_HEIGHT,
TILE_WIDTH, TILE_HEIGHT), draw_x, draw_y);
img_render_vram(
img_sub(img_tileset,
(int)(tile % tileset_width) *
TILE_WIDTH,
(int)(tile / tileset_width) *
TILE_HEIGHT,
TILE_WIDTH, TILE_HEIGHT),
draw_x, draw_y);
}
}
}

View File

@ -1,9 +1,9 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Copyright (C) 2021 KikooDX */
#include "filepaths.h"
#include "level.h"
#include "tiles.h"
#include "filepaths.h"
#include <gint/bfile.h>
#include <gint/std/stdlib.h>
#include <stdint.h>

View File

@ -31,7 +31,7 @@ int player_collide_tile(Tile collisions[COLLIDE_POINTS], int x, int y,
player_collide(collisions, x, y, margin);
int i = COLLIDE_POINTS;
while (i --> 0)
while (i-- > 0)
if (collisions[i] == tile)
return 1;
return 0;

View File

@ -2,12 +2,13 @@
/* Copyright (C) 2021 KikooDX */
#include "conf.h"
#include "filepaths.h"
#include "level.h"
#include "player.h"
#include <gint/display.h>
#include <libimg.h>
extern struct Level level;
extern int level_id;
extern img_t const img_player;
extern bopti_image_t const bimg_burst;
@ -18,5 +19,9 @@ void player_draw(struct Player player)
if (player.air_state == AirRising &&
player.jumps_left < AIR_JUMPS)
dimage(player.x, player.y + PLAYER_HEIGHT, &bimg_burst);
dprint(2, 2, C_WHITE, "%d", level.gold);
/* print level name
* this shouldn't be in player code */
dprint_opt(DWIDTH - 4, DHEIGHT, C_WHITE, C_NONE,
DTEXT_RIGHT, DTEXT_BOTTOM, "%s",
level_names[level_id]);
}

View File

@ -26,9 +26,9 @@ struct Player player_init(void)
/* find spawn position in level */
x = level.width;
while (x --> 0) {
while (x-- > 0) {
y = level.height;
while (y --> 0) {
while (y-- > 0) {
if (level.data[x + y * level.width] ==
TILE_START) {
player.x =