Add christmas edition
This commit is contained in:
parent
2f1c7d9e82
commit
b62af486a7
74 changed files with 3422 additions and 1 deletions
24
christmas/AdAstra/src/util/vec2/vec2.c
Normal file
24
christmas/AdAstra/src/util/vec2/vec2.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "vec2.h"
|
||||
|
||||
|
||||
const Vec2 directions[] = {
|
||||
[north] = (Vec2){0, -1},
|
||||
[west] = (Vec2){-1, 0},
|
||||
[south] = (Vec2){0, 1},
|
||||
[east] = (Vec2){1, 0}
|
||||
};
|
||||
|
||||
Vec2 add(Vec2 v1, Vec2 v2) {
|
||||
return (Vec2){v1.x + v2.x, v1.y + v2.y};
|
||||
}
|
||||
|
||||
Vec2 substract(Vec2 v1, Vec2 v2) {
|
||||
return (Vec2){v1.x - v2.x, v1.y - v2.y};
|
||||
}
|
||||
|
||||
Vec2 clampVec2(Vec2 v) {
|
||||
return (Vec2){
|
||||
v.x == 0 ? 0 : (v.x > 0 ? 1 : -1),
|
||||
v.y == 0 ? 0 : (v.y > 0 ? 1 : -1)
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue