forked from kdx/jtmm2-old
65ceff3971
- [input] Completely rewrote most of the code - [input/camera] Renamed `*_draw` functions used in debug section to `*_draw_debug` - [main/input] Now use `_Bool` instead of `int` when appropriate - [input] Added function `input_is_up` - [player] Added function `player_draw_debug` - [vec] Use `int` instead of `float`, new macro `VEC_PRECISION` - [main/camera/player/vec] Updated vector related code to work with the new system
32 lines
689 B
C
32 lines
689 B
C
#ifndef _DEF_VEC
|
|
#define _DEF_VEC
|
|
|
|
#define VEC_PRECISION 512
|
|
|
|
typedef struct Vec
|
|
{
|
|
int x;
|
|
int y;
|
|
} Vec;
|
|
|
|
/* like memcpy but for vectors */
|
|
void vec_cpy(Vec *destination, Vec source);
|
|
|
|
/* apply a force on a vector */
|
|
void vec_add(Vec *vector, Vec force);
|
|
|
|
/* apply the opposite of a force on a vector */
|
|
void vec_sub(Vec *vector, Vec force);
|
|
|
|
/* multiply a vector by a scale */
|
|
void vec_mul(Vec *vector, float scale);
|
|
|
|
/* divise a vector by a scale */
|
|
void vec_div(Vec *vector, float scale);
|
|
|
|
/* Linear interpolation between two vectors.
|
|
* Require a scale ranging from 0 to 1 (0 is instant, 1 is completly still). */
|
|
void vec_lerp(Vec *from, Vec to, float scale);
|
|
|
|
#endif /* _DEF_VEC */
|