forked from TerryCavanagh/VVVVVV
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add abstract geometry stuff, other random trials
- Loading branch information
Tynan Richards
committed
Aug 4, 2024
1 parent
c2924cb
commit fffdd8d
Showing
8 changed files
with
1,476 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef SOLVER_CONSTANTS_H | ||
#define SOLVER_CONSTANTS_H | ||
|
||
#define VIRIDIAN_CX (6) | ||
#define VIRIDIAN_CY (2) | ||
#define VIRIDIAN_W (12) | ||
#define VIRIDIAN_H (21) | ||
|
||
#define X_ACCEL_EFF (1.9f) | ||
#define Y_ACCEL_EFF (2.75f) | ||
#define MAX_X_SPEED (6) | ||
#define MAX_Y_SPEED (10) | ||
|
||
#define TOWER_RX (9) | ||
|
||
#define RENDER_OFFSET_X (11) | ||
#define RENDER_OFFSET_Y (12) | ||
|
||
#endif /* SOLVER_CONSTANTS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "Geometry.h" | ||
|
||
namespace Geometry { | ||
IntInterval IntInterval::join(const IntInterval& a, const IntInterval& b) { | ||
int min = SDL_min(a.min, b.min); | ||
int max = SDL_max(a.max, b.max); | ||
return IntInterval(min, max); | ||
} | ||
IntInterval IntInterval::intersect(const IntInterval& a, const IntInterval& b) { | ||
int min = SDL_max(a.min, b.min); | ||
int max = SDL_min(a.max, b.max); | ||
return IntInterval(min, max); | ||
} | ||
IntInterval& IntInterval::join(const IntInterval& other) { | ||
min = SDL_min(min, other.min); | ||
max = SDL_max(max, other.max); | ||
return regularize(); | ||
} | ||
IntInterval& IntInterval::intersect(const IntInterval& other) { | ||
min = SDL_max(min, other.min); | ||
max = SDL_min(max, other.max); | ||
return regularize(); | ||
} | ||
|
||
bool IntInterval::contains(int val) const { | ||
return val >= min && val <= max; | ||
} | ||
bool IntInterval::contains(const IntInterval& other) const { | ||
return other.min >= min && other.max <= max; | ||
} | ||
|
||
Region Region::join(const Region& a, const Region& b) { | ||
IntInterval x_interval = IntInterval::join(a.x, b.x); | ||
IntInterval y_interval = IntInterval::join(a.y, b.y); | ||
return Region(x_interval, y_interval); | ||
} | ||
Region Region::intersect(const Region& a, const Region& b) { | ||
IntInterval x_interval = IntInterval::intersect(a.x, b.x); | ||
IntInterval y_interval = IntInterval::intersect(a.y, b.y); | ||
return Region(x_interval, y_interval); | ||
} | ||
|
||
bool Region::contains(const Region& other) const { | ||
return x.contains(other.x) && y.contains(other.y); | ||
} | ||
bool Region::contains(const IntVector& val) const { | ||
return x.contains(val.x) && y.contains(val.y); | ||
} | ||
bool Region::contains(int x_val, int y_val) const { | ||
return x.contains(x_val) && y.contains(y_val); | ||
} | ||
|
||
Region& Region::join(const Region& other) { | ||
x.join(other.x); | ||
y.join(other.y); | ||
return regularize(); | ||
} | ||
Region& Region::intersect(const Region& other) { | ||
x.intersect(other.x); | ||
y.intersect(other.y); | ||
return regularize(); | ||
} | ||
|
||
} |
Oops, something went wrong.