Better glue. Fixed ice.

This commit is contained in:
KikooDX 2021-01-09 17:07:05 +01:00
parent 9dcf3c732a
commit fc8eb2b31c
2 changed files with 6 additions and 7 deletions

View File

@ -13,8 +13,8 @@
/* TODO: Determine FRICTION and ACCELERATION from UPS. */
#define MAX_SPD (128 * PXS)
#define FRICTION 0.99
#define ACCELERATION (int)(MAX_SPD * (1 - FRICTION))
#define FRICTION 0.01
#define ACCELERATION (int)(MAX_SPD * FRICTION)
#define GRAVITY PXS
#define FAST_FALL_FACTOR 3
#define JUMP_SPD (-128 * PXS)
@ -130,7 +130,7 @@ void player_step(Player *player, Input *input, const Level *level, uint step) {
/* other keys */
bool k_jump = INPUT_DOWN(K_JUMP);
int xacc = move.x * player->vars.acceleration; /* calculate horizontal acceleration */
player->spd.x *= player->vars.friction; /* apply horizontal friction */
player->spd.x *= 1 - player->vars.friction; /* apply horizontal friction */
player->spd.x += xacc; /* apply horizontal acceleration */
/* apply gravity */
if (player->spd.y < 0 && !player->jump_held) {

View File

@ -2,12 +2,11 @@
#include "player.h"
void player_mod_ice(Player *player) {
player->vars.acceleration *= 2;
float *friction = &player->vars.friction;
*friction = 1 - ((1 - *friction) / 2);
player->vars.acceleration /= 4;
player->vars.friction /= 4;
}
void player_mod_glue(Player *player) {
player->vars.acceleration = 0;
player->vars.friction = 0;
player->vars.friction = 1;
}