bounce on walls
This commit is contained in:
parent
066760bd7a
commit
4d17f417eb
BIN
res/font.png
BIN
res/font.png
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 68 B |
BIN
res/tset.png
BIN
res/tset.png
Binary file not shown.
Before Width: | Height: | Size: 500 B After Width: | Height: | Size: 68 B |
|
@ -5,13 +5,14 @@
|
|||
#include "cfg.h"
|
||||
#include "input.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
static void
|
||||
player_update(Entity *this, Game *g)
|
||||
{
|
||||
const int on_ground = entity_collide(this, g, 0, 1);
|
||||
|
||||
this->vel[0] = 2.0;
|
||||
this->vel[0] = 2.0 * this->player.dirx;
|
||||
this->vel[1] *= 0.99;
|
||||
this->vel[1] += 0.2;
|
||||
this->player.scale_x += 0.1 * (1.0 - this->player.scale_x);
|
||||
|
@ -42,6 +43,8 @@ player_update(Entity *this, Game *g)
|
|||
}
|
||||
|
||||
entity_move(this, g);
|
||||
if (this->vel[0] == 0.0)
|
||||
this->player.dirx *= -1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -74,4 +77,5 @@ player_init(Entity *this)
|
|||
this->height = 12;
|
||||
this->player.scale_x = 1.0;
|
||||
this->player.scale_y = 1.0;
|
||||
this->player.dirx = 1;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
typedef struct {
|
||||
float scale_x;
|
||||
float scale_y;
|
||||
double scale_x;
|
||||
double scale_y;
|
||||
int dirx;
|
||||
} Player;
|
||||
|
||||
struct Entity;
|
||||
|
|
Loading…
Reference in New Issue