Skip to content

Commit

Permalink
Add abstract geometry stuff, other random trials
Browse files Browse the repository at this point in the history
  • Loading branch information
Tynan Richards committed Aug 4, 2024
1 parent c2924cb commit fffdd8d
Show file tree
Hide file tree
Showing 8 changed files with 1,476 additions and 126 deletions.
1 change: 1 addition & 0 deletions desktop_version/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ set(VVV_SRC
src/solver/Solver.cpp
src/solver/Terrain.cpp
src/solver/Heuristic.cpp
src/solver/Geometry.cpp
)
if(NOT CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED")
list(APPEND VVV_SRC src/CustomLevels.cpp)
Expand Down
19 changes: 19 additions & 0 deletions desktop_version/src/solver/Constants.h
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 */
64 changes: 64 additions & 0 deletions desktop_version/src/solver/Geometry.cpp
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();
}

}
Loading

0 comments on commit fffdd8d

Please sign in to comment.