momento/src/player/draw.c

37 lines
924 B
C
Raw Normal View History

/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Copyright (C) 2021 KikooDX */
#include "conf.h"
2021-04-08 00:38:40 +02:00
#include "filepaths.h"
2021-04-04 17:33:17 +02:00
#include "level.h"
2021-04-21 17:51:59 +02:00
#include "particles.h"
#include "player.h"
2021-04-20 12:49:55 +02:00
#include "zxcolors.h"
#include <gint/display.h>
2021-04-09 15:11:00 +02:00
extern struct Level level;
2021-04-04 17:33:17 +02:00
extern bopti_image_t bimg_burst;
void
player_draw(struct Player player)
{
2021-04-21 17:51:59 +02:00
/* set animation position */
struct Particle anim = player.anim;
anim.x = player.x;
anim.y = player.y;
anim.x -= (anim.frame_width - PLAYER_WIDTH) / 2;
anim.y -= (anim.texture->height - PLAYER_HEIGHT) / 2;
/* draw animation */
particle_draw(anim);
/* draw burst */
if (player.air_state == AirRising && player.jumps_left < AIR_JUMPS)
dimage(player.x, player.y + PLAYER_HEIGHT, &bimg_burst);
2021-04-21 17:51:59 +02:00
2021-04-08 00:38:40 +02:00
/* print level name
* this shouldn't be in player code */
2021-04-20 12:49:55 +02:00
dprint_opt(DWIDTH - 4, DHEIGHT, ZX_WHITE, C_NONE, DTEXT_RIGHT,
2021-04-18 00:44:01 +02:00
DTEXT_BOTTOM, "%s", level_names[level.id]);
}