mirror of https://git.sr.ht/~kikoodx/momento
Fix transitions and add horizontal ones
This commit is contained in:
parent
9d9339e921
commit
b845dd850d
|
@ -19,4 +19,5 @@
|
|||
#define JUMP_GRACE 10
|
||||
#define AIR_JUMPS 3
|
||||
#define BURST_BOOST 0.5
|
||||
#define TRANS_SPEED (1.0 / 8.0)
|
||||
#define V_TRANS_SPD (1.0 / 15.0)
|
||||
#define H_TRANS_SPD (1.0 / 30.0)
|
||||
|
|
|
@ -23,5 +23,7 @@ struct Transition transition_init(float speed, color_t color,
|
|||
enum TransitionMode mode);
|
||||
enum TransitionMode transition_update(struct Transition *transition);
|
||||
void transition_draw(struct Transition transition);
|
||||
void hfade_in(float step, color_t color);
|
||||
void hfade_out(float step, color_t color);
|
||||
void vfade_in(float step, color_t color);
|
||||
void vfade_out(float step, color_t color);
|
||||
|
|
|
@ -22,27 +22,26 @@ void level_draw(void)
|
|||
while (x-- > 0) {
|
||||
const int draw_x = x * TILE_WIDTH;
|
||||
const int tile_index = x + y * level.width;
|
||||
const Tile tile =
|
||||
level.data[tile_index];
|
||||
const Tile tile = level.data[tile_index];
|
||||
switch (tile) {
|
||||
case TILE_VOID:
|
||||
break;
|
||||
case TILE_SOLID: {
|
||||
const int autotile =
|
||||
level.autotiling[tile_index];
|
||||
dsubimage(draw_x, draw_y,
|
||||
&bimg_tileset, autotile,
|
||||
TILE_HEIGHT, TILE_WIDTH,
|
||||
TILE_HEIGHT, DIMAGE_NOCLIP);
|
||||
dsubimage(draw_x, draw_y, &bimg_tileset,
|
||||
autotile, TILE_HEIGHT,
|
||||
TILE_WIDTH, TILE_HEIGHT,
|
||||
DIMAGE_NOCLIP);
|
||||
} break;
|
||||
default:
|
||||
dsubimage(draw_x, draw_y,
|
||||
&bimg_tileset,
|
||||
(int)(tile % tileset_width) *
|
||||
TILE_WIDTH,
|
||||
(int)(tile / tileset_width) *
|
||||
TILE_HEIGHT, TILE_WIDTH,
|
||||
TILE_HEIGHT, DIMAGE_NOCLIP);
|
||||
dsubimage(draw_x, draw_y, &bimg_tileset,
|
||||
(int)(tile % tileset_width) *
|
||||
TILE_WIDTH,
|
||||
(int)(tile / tileset_width) *
|
||||
TILE_HEIGHT,
|
||||
TILE_WIDTH, TILE_HEIGHT,
|
||||
DIMAGE_NOCLIP);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
14
src/main.c
14
src/main.c
|
@ -57,7 +57,7 @@ int main(void)
|
|||
particles_init();
|
||||
/* initialize transitions */
|
||||
struct Transition transition =
|
||||
transition_init(TRANS_SPEED, C_WHITE, TransitionVIn);
|
||||
transition_init(0.0, C_BLACK, TransitionNone);
|
||||
/* timer setup */
|
||||
timer = timer_setup(TIMER_ANY, 1000000 / TARGET_UPS, callback,
|
||||
&has_ticked);
|
||||
|
@ -84,12 +84,12 @@ int main(void)
|
|||
case 1:
|
||||
level_id += 1;
|
||||
transition = transition_init(
|
||||
TRANS_SPEED, C_BLUE,
|
||||
TransitionVOut);
|
||||
H_TRANS_SPD, C_BLUE,
|
||||
TransitionHOut);
|
||||
break;
|
||||
case -1:
|
||||
transition = transition_init(
|
||||
TRANS_SPEED, C_RED,
|
||||
V_TRANS_SPD, C_RED,
|
||||
TransitionVOut);
|
||||
break;
|
||||
default:
|
||||
|
@ -109,12 +109,16 @@ int main(void)
|
|||
case TransitionHIn:
|
||||
break;
|
||||
case TransitionHOut:
|
||||
transition = transition_init(
|
||||
transition.speed,
|
||||
transition.color,
|
||||
TransitionHIn);
|
||||
break;
|
||||
case TransitionVIn:
|
||||
break;
|
||||
case TransitionVOut:
|
||||
transition = transition_init(
|
||||
TRANS_SPEED,
|
||||
transition.speed,
|
||||
transition.color,
|
||||
TransitionVIn);
|
||||
break;
|
||||
|
|
|
@ -9,8 +9,10 @@ void transition_draw(struct Transition transition)
|
|||
case TransitionNone:
|
||||
break;
|
||||
case TransitionHIn:
|
||||
hfade_in(transition.step, transition.color);
|
||||
break;
|
||||
case TransitionHOut:
|
||||
hfade_out(transition.step, transition.color);
|
||||
break;
|
||||
case TransitionVIn:
|
||||
vfade_in(transition.step, transition.color);
|
||||
|
|
|
@ -4,9 +4,32 @@
|
|||
#include "transition.h"
|
||||
#include <gint/display.h>
|
||||
|
||||
static float square(float x);
|
||||
static float isquare(float x);
|
||||
|
||||
void hfade_in(float step, color_t color)
|
||||
{
|
||||
int line = isquare(step) * DWIDTH;
|
||||
int x;
|
||||
drect(line, 0, DWIDTH, DHEIGHT, C_BLACK);
|
||||
for (x = line; x < line + 2; x += 1) {
|
||||
dvline(x, color);
|
||||
}
|
||||
}
|
||||
|
||||
void hfade_out(float step, color_t color)
|
||||
{
|
||||
int line = square(step) * DWIDTH;
|
||||
int x;
|
||||
drect(0, 0, line, DHEIGHT, C_BLACK);
|
||||
for (x = line - 2; x < line; x += 1) {
|
||||
dvline(x, color);
|
||||
}
|
||||
}
|
||||
|
||||
void vfade_in(float step, color_t color)
|
||||
{
|
||||
int line = step * DHEIGHT;
|
||||
int line = isquare(step) * DHEIGHT;
|
||||
int y;
|
||||
drect(0, line, DWIDTH, DHEIGHT, C_BLACK);
|
||||
for (y = line; y < line + 2; y += 1) {
|
||||
|
@ -16,10 +39,14 @@ void vfade_in(float step, color_t color)
|
|||
|
||||
void vfade_out(float step, color_t color)
|
||||
{
|
||||
int line = step * DHEIGHT;
|
||||
int line = square(step) * DHEIGHT;
|
||||
int y;
|
||||
drect(0, 0, DWIDTH, line, C_BLACK);
|
||||
for (y = line - 2; y < line; y += 1) {
|
||||
dhline(y, color);
|
||||
}
|
||||
}
|
||||
|
||||
static float square(float x) { return x * x; }
|
||||
|
||||
static float isquare(float x) { return 1.0 - square(1.0 - x); }
|
||||
|
|
Loading…
Reference in New Issue