mirror of https://git.sr.ht/~kikoodx/momento
42 lines
837 B
C
42 lines
837 B
C
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
/* Copyright (C) 2021 KikooDX */
|
|
|
|
#include "trail.h"
|
|
#include <libimg.h>
|
|
|
|
extern struct Trail trail[TRAIL_LIFE];
|
|
extern const img_t img_trail;
|
|
|
|
static void trail_atom_draw(struct Trail atom);
|
|
|
|
void
|
|
trail_draw(void)
|
|
{
|
|
int i = TRAIL_LIFE;
|
|
while (i-- > 0)
|
|
trail_atom_draw(trail[i]);
|
|
}
|
|
|
|
static void
|
|
trail_atom_draw(struct Trail atom)
|
|
{
|
|
if (!atom.life)
|
|
return;
|
|
|
|
/* get frame subimage */
|
|
const img_t frame_simg = img_sub(img_trail, atom.frame * TRAIL_SIZE, 0,
|
|
TRAIL_SIZE, TRAIL_SIZE);
|
|
|
|
/* tint the frame */
|
|
const img_t transformed_img = img_dye_create(frame_simg, atom.color);
|
|
/* check */
|
|
if (img_null(transformed_img))
|
|
return;
|
|
|
|
/* render image */
|
|
img_render_vram(transformed_img, atom.x, atom.y);
|
|
|
|
/* free */
|
|
img_destroy(transformed_img);
|
|
}
|