Direction "buffer".

This commit is contained in:
KikooDX 2020-05-17 12:42:05 +02:00
parent 382626d961
commit 24f06ed70e
3 changed files with 36 additions and 9 deletions

View File

@ -1,4 +1,4 @@
enum Direction;
enum { UP, DOWN, LEFT, RIGHT };
void jump_test(char *jump_pressed, char *jump_buffer, unsigned int *jump_hold,
char enable_up_key);
void set_start_pos(int *start_x, int *start_y, int x, int y);

View File

@ -15,6 +15,13 @@
#define MIN_VSPD -12.0
#define MAX_VSPD 6.0
#define JUMP_SPD -3.99
enum Direction
{
up,
down,
left,
right
};
#define GRAV 0.4
#define JUMP_SCALE 8
#define JUMP_REDUCTION -0.41
@ -59,6 +66,8 @@ int main(void)
char exit_buffer = 0;
char tp_buffer = 0;
int tp_positions[4] = { 0, 0, 0, 0 };
char directions[4] = { 0, 0, 0, 0 };
char last_direction = RIGHT;
set_level(level_id, level);
DRAW_LEVEL();
player_x = start_x;
@ -80,6 +89,32 @@ int main(void)
}
//END DRAW
clearevents();
//direction inputs
if (keydown(KEY_LEFT))
{
if (!directions[LEFT]) last_direction = LEFT;
directions[LEFT] += 1;
}
else directions[LEFT] = 0;
if (keydown(KEY_RIGHT))
{
if (!directions[RIGHT]) last_direction = RIGHT;
directions[RIGHT] += 1;
}
else directions[RIGHT] = 0;
if (keydown(KEY_UP))
{
if (!directions[UP]) last_direction = UP;
directions[UP] += 1;
}
else directions[UP] = 0;
if (keydown(KEY_DOWN))
{
if (!directions[DOWN]) last_direction = DOWN;
directions[DOWN] += 1;
}
else directions[DOWN] = 0;
//direction inputs END
//polarity swap first
if (keydown(KEY_OPTN))
{

View File

@ -1,14 +1,6 @@
#include <gint/keyboard.h>
#include "player.h"
enum Direction
{
up,
down,
left,
right
};
void jump_test(char *jump_pressed, char *jump_buffer, unsigned int *jump_hold,
char enable_up_key)
{