mirror of https://git.sr.ht/~kikoodx/momento
41 lines
1.0 KiB
C
41 lines
1.0 KiB
C
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
/* Copyright (C) 2021 KikooDX */
|
|
#pragma once
|
|
|
|
#include "level.h"
|
|
|
|
#define PLAYER_WIDTH 12
|
|
#define PLAYER_HEIGHT 12
|
|
|
|
enum AirState { AirRising, AirBreaking, AirNeutral };
|
|
#define AIR_BREAKING_FACTOR 3
|
|
|
|
struct Player {
|
|
int x;
|
|
int y;
|
|
float spd_x;
|
|
float spd_y;
|
|
float rem_x;
|
|
float rem_y;
|
|
/* jump */
|
|
int k_jump_previous;
|
|
int jump_buffer;
|
|
int jump_grace;
|
|
int jumps_left;
|
|
enum AirState air_state;
|
|
};
|
|
|
|
/* used for collisions */
|
|
enum { UP_LEFT, UP_RIGHT, DOWN_LEFT, DOWN_RIGHT };
|
|
#define COLLIDE_POINTS 4
|
|
|
|
struct Player player_init(void);
|
|
void player_draw(struct Player player);
|
|
/* return 1 if exit reached, -1 on death/reset and 0 otherwise */
|
|
int player_update(struct Player *player);
|
|
void player_collide(Tile collisions[COLLIDE_POINTS], int x, int y);
|
|
int player_collide_tile(Tile collisions[COLLIDE_POINTS], int x, int y,
|
|
Tile tile, int update);
|
|
int player_collide_solid(int x, int y);
|
|
int player_collide_sub(int x, int y, Tile sub, Tile rep);
|