mirror of https://git.sr.ht/~kikoodx/momento
Get rid of libimg
I don't need the features of libimg after all, and bopti images are faster.
This commit is contained in:
parent
b845dd850d
commit
be9c9ea800
|
@ -8,7 +8,6 @@ include(GenerateG3A)
|
|||
include(Fxconv)
|
||||
|
||||
find_package(Gint 2.3 REQUIRED)
|
||||
find_package(LibImg 2.2 REQUIRED)
|
||||
|
||||
add_custom_target(filepaths
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
|
@ -66,7 +65,6 @@ add_executable(${PROJECT_NAME} ${SOURCES} ${ASSETS})
|
|||
add_dependencies(${PROJECT_NAME} filepaths)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE ${FLAGS})
|
||||
target_link_libraries(${PROJECT_NAME} Gint::Gint)
|
||||
target_link_libraries(${PROJECT_NAME} LibImg::LibImg)
|
||||
|
||||
generate_g3a(TARGET ${PROJECT_NAME}
|
||||
OUTPUT "${PROJECT_NAME}.g3a"
|
||||
|
|
|
@ -2,23 +2,23 @@ tileset.png:
|
|||
type: bopti-image
|
||||
name: bimg_tileset
|
||||
player.png:
|
||||
type: libimg-image
|
||||
name: img_player
|
||||
type: bopti-image
|
||||
name: bimg_player
|
||||
burst.png:
|
||||
type: bopti-image
|
||||
name: bimg_burst
|
||||
coin-particle.png:
|
||||
type: libimg-image
|
||||
name: img_coin_particle
|
||||
type: bopti-image
|
||||
name: bimg_coin_particle
|
||||
switch-particle.png:
|
||||
type: libimg-image
|
||||
name: img_switch_particle
|
||||
type: bopti-image
|
||||
name: bimg_switch_particle
|
||||
switch-activated-particle.png:
|
||||
type: libimg-image
|
||||
name: img_switch_activated_particle
|
||||
type: bopti-image
|
||||
name: bimg_switch_activated_particle
|
||||
exit-active-particle.png:
|
||||
type: libimg-image
|
||||
name: img_exit_active_particle
|
||||
type: bopti-image
|
||||
name: bimg_exit_active_particle
|
||||
exit-unlock-particle.png:
|
||||
type: libimg-image
|
||||
name: img_exit_unlock_particle
|
||||
type: bopti-image
|
||||
name: bimg_exit_unlock_particle
|
||||
|
|
|
@ -20,4 +20,4 @@
|
|||
#define AIR_JUMPS 3
|
||||
#define BURST_BOOST 0.5
|
||||
#define V_TRANS_SPD (1.0 / 15.0)
|
||||
#define H_TRANS_SPD (1.0 / 30.0)
|
||||
#define H_TRANS_SPD (1.0 / 20.0)
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
/* Copyright (C) 2021 KikooDX */
|
||||
#pragma once
|
||||
|
||||
#include <libimg.h>
|
||||
#include <gint/display.h>
|
||||
|
||||
#define MAX_PARTICLES 64
|
||||
|
||||
struct Particle {
|
||||
img_t *texture;
|
||||
bopti_image_t *texture;
|
||||
int x;
|
||||
int y;
|
||||
int frame_width;
|
||||
|
@ -22,5 +22,6 @@ struct Particle {
|
|||
void particles_init(void);
|
||||
void particles_update(void);
|
||||
void particles_draw(void);
|
||||
void particle_create(img_t *texture, int x, int y, int frame_width,
|
||||
int frame_duration, int particles);
|
||||
void particle_create(bopti_image_t *texture, int x, int y,
|
||||
int frame_width, int frame_duration,
|
||||
int particles);
|
||||
|
|
|
@ -102,13 +102,13 @@ int main(void)
|
|||
transition.mode &&
|
||||
transition_previous_mode !=
|
||||
TransitionNone) {
|
||||
LOAD_LEVEL();
|
||||
switch (transition_previous_mode) {
|
||||
case TransitionNone:
|
||||
break;
|
||||
case TransitionHIn:
|
||||
break;
|
||||
case TransitionHOut:
|
||||
LOAD_LEVEL();
|
||||
transition = transition_init(
|
||||
transition.speed,
|
||||
transition.color,
|
||||
|
@ -117,6 +117,7 @@ int main(void)
|
|||
case TransitionVIn:
|
||||
break;
|
||||
case TransitionVOut:
|
||||
LOAD_LEVEL();
|
||||
transition = transition_init(
|
||||
transition.speed,
|
||||
transition.color,
|
||||
|
@ -129,8 +130,8 @@ int main(void)
|
|||
/* draw */
|
||||
dclear(C_BLACK);
|
||||
level_draw();
|
||||
player_draw(player);
|
||||
particles_draw();
|
||||
player_draw(player);
|
||||
transition_draw(transition);
|
||||
dupdate();
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
/* Copyright (C) 2021 KikooDX */
|
||||
|
||||
#include "particles.h"
|
||||
#include <libimg.h>
|
||||
#include <gint/display.h>
|
||||
|
||||
extern struct Particle particles[MAX_PARTICLES];
|
||||
|
||||
void particle_create(img_t *texture, int x, int y, int frame_width,
|
||||
int frame_duration, int looping)
|
||||
void particle_create(bopti_image_t *texture, int x, int y,
|
||||
int frame_width, int frame_duration, int looping)
|
||||
{
|
||||
/* find unused slot */
|
||||
int i = MAX_PARTICLES;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* Copyright (C) 2021 KikooDX */
|
||||
|
||||
#include "particles.h"
|
||||
#include <libimg.h>
|
||||
#include <gint/display.h>
|
||||
|
||||
extern struct Particle particles[MAX_PARTICLES];
|
||||
|
||||
|
@ -20,9 +20,8 @@ static void particle_draw(struct Particle particle)
|
|||
if (!particle.life)
|
||||
return;
|
||||
|
||||
img_render_vram(img_sub(*particle.texture,
|
||||
particle.frame * particle.frame_width,
|
||||
0, particle.frame_width,
|
||||
particle.frame_height),
|
||||
particle.x, particle.y);
|
||||
dsubimage(particle.x, particle.y, particle.texture,
|
||||
particle.frame * particle.frame_width, 0,
|
||||
particle.frame_width, particle.frame_height,
|
||||
DIMAGE_NOCLIP);
|
||||
}
|
||||
|
|
|
@ -6,15 +6,15 @@
|
|||
#include "particles.h"
|
||||
#include "player.h"
|
||||
#include "tiles.h"
|
||||
#include <libimg.h>
|
||||
#include <gint/display.h>
|
||||
|
||||
extern struct Level level;
|
||||
|
||||
extern img_t img_coin_particle;
|
||||
extern img_t img_switch_particle;
|
||||
extern img_t img_switch_activated_particle;
|
||||
extern img_t img_exit_active_particle;
|
||||
extern img_t img_exit_unlock_particle;
|
||||
extern bopti_image_t bimg_coin_particle;
|
||||
extern bopti_image_t bimg_switch_particle;
|
||||
extern bopti_image_t bimg_switch_activated_particle;
|
||||
extern bopti_image_t bimg_exit_active_particle;
|
||||
extern bopti_image_t bimg_exit_unlock_particle;
|
||||
|
||||
static Tile collide_single(int x, int y);
|
||||
static int collide_sub_single(int x, int y, Tile sub, Tile rep);
|
||||
|
@ -88,15 +88,15 @@ static int collide_sub_single(int x, int y, Tile sub, Tile rep)
|
|||
/* spawn animations */
|
||||
switch (sub) {
|
||||
case TILE_GOLD:
|
||||
particle_create(&img_coin_particle, px, py,
|
||||
particle_create(&bimg_coin_particle, px, py,
|
||||
TILE_WIDTH, 2, 0);
|
||||
break;
|
||||
case TILE_SWITCH:
|
||||
/* still image */
|
||||
particle_create(&img_switch_activated_particle,
|
||||
particle_create(&bimg_switch_activated_particle,
|
||||
px, py, TILE_WIDTH, 1, 1);
|
||||
/* activation animation */
|
||||
particle_create(&img_switch_particle, px, py,
|
||||
particle_create(&bimg_switch_particle, px, py,
|
||||
TILE_WIDTH, 8, 0);
|
||||
/* exit unlock animation */
|
||||
{
|
||||
|
@ -118,10 +118,10 @@ static int collide_sub_single(int x, int y, Tile sub, Tile rep)
|
|||
tx *= TILE_WIDTH;
|
||||
ty *= TILE_HEIGHT;
|
||||
particle_create(
|
||||
&img_exit_active_particle, tx, ty,
|
||||
&bimg_exit_active_particle, tx, ty,
|
||||
TILE_WIDTH, 2, 1);
|
||||
particle_create(
|
||||
&img_exit_unlock_particle, tx, ty,
|
||||
&bimg_exit_unlock_particle, tx, ty,
|
||||
TILE_WIDTH, 4, 0);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -6,16 +6,15 @@
|
|||
#include "level.h"
|
||||
#include "player.h"
|
||||
#include <gint/display.h>
|
||||
#include <libimg.h>
|
||||
|
||||
extern struct Level level;
|
||||
|
||||
extern img_t const img_player;
|
||||
extern bopti_image_t const bimg_burst;
|
||||
extern bopti_image_t bimg_player;
|
||||
extern bopti_image_t bimg_burst;
|
||||
|
||||
void player_draw(struct Player player)
|
||||
{
|
||||
img_render_vram(img_player, player.x, player.y);
|
||||
dimage(player.x, player.y, &bimg_player);
|
||||
if (player.air_state == AirRising &&
|
||||
player.jumps_left < AIR_JUMPS)
|
||||
dimage(player.x, player.y + PLAYER_HEIGHT, &bimg_burst);
|
||||
|
|
Loading…
Reference in New Issue