Skip to content

Commit

Permalink
FloodForge v1.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Haizlbliek committed Jan 23, 2025
1 parent 1e3ca6f commit 8eb62a7
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 160 deletions.
18 changes: 17 additions & 1 deletion Build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,25 @@ else
fi

if [ $? -eq 0 ]; then
# create distribution zip if on release mode
if [[ $buildmode == "release" ]]; then
# windows: 7zip
if [[ -f "/c/Program Files/7-Zip/7z.exe" ]]; then
echo \[INF\] Using 7-Zip to create distribution...
"/c/Program Files/7-Zip/7z.exe" a FloodForge.zip FloodForge.exe README.md LICENSE assets/* -r

# linux: zip command
elif command -v zip 2>&1 >/dev/null; then
echo \[INF\] Using zip to create distribution...
zip -r FloodForge.zip FloodForge README.md LICENSE assets/*
fi
fi

# auto-run executable if not in release mode and --no-run flag was not specified
if [[ $buildmode != "release" && $norun != 1 ]]; then
build/FloodForge
./FloodForge
fi
else
echo "Compilation failed."
exit 1
fi
Binary file modified assets/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/splashTitle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endif

# determine libs to link with based off platform
ifeq ($(OS),Windows_NT)
LIBS += lib/GLFW/libglfw3.a -lgdi32 -lopengl32 -luser32 -lcomdlg32 -lole32
LIBS += build/resource.o lib/GLFW/libglfw3.a -lgdi32 -lopengl32 -luser32 -lcomdlg32 -lole32
else
# items to plug into pkg-config to find libs and includes
REQPKGS += glfw3
Expand Down
12 changes: 12 additions & 0 deletions src/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,18 @@ class Window {
bool keyPressed(uint16_t key) {
return GLFW_PRESS == glfwGetKey(glfwWindow, key);
}

bool modifierPressed(uint16_t modifier) {
switch (modifier) {
case GLFW_MOD_CONTROL:
return keyPressed(GLFW_KEY_LEFT_CONTROL) || keyPressed(GLFW_KEY_RIGHT_CONTROL) || keyPressed(GLFW_KEY_LEFT_SUPER) || keyPressed(GLFW_KEY_RIGHT_SUPER);

case GLFW_MOD_SHIFT:
return keyPressed(GLFW_KEY_LEFT_SHIFT) || keyPressed(GLFW_KEY_RIGHT_SHIFT);
}

return false;
}

double getMouseScrollX() {
double scrollX = scrollXAccumulator;
Expand Down
8 changes: 8 additions & 0 deletions src/math/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ class Vector2 {
return Vector2(this->x - other.x, this->y - other.y);
}

void X(const double x) {
this->x = x;
}

void Y(const double y) {
this->y = y;
}

static Vector2 min(const Vector2 &a, const Vector2 &b) {
return Vector2(
(a.x < b.x) ? a.x : b.x,
Expand Down
2 changes: 1 addition & 1 deletion src/popup/SplashArtPopup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SplashArtPopup : public Popup {
Draw::color(1.0f, 1.0f, 1.0f);
Fonts::rodondo->writeCentred("FloodForge", 0.0, 0.1, 0.2, CENTRE_XY);
Fonts::rainworld->writeCentred("World Editor", 0.0, -0.1, 0.1, CENTRE_XY);
Fonts::rainworld->write("v1.3.4", -0.88, 0.43, 0.04);
Fonts::rainworld->write("v1.3.5", -0.88, 0.43, 0.04);
}

void mouseClick(double mouseX, double mouseY) {
Expand Down
4 changes: 2 additions & 2 deletions src/world/DebugData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#include "Globals.hpp"

namespace DebugData {
void draw(Window *window, Vector2 mouse) {
void draw(Window *window, Vector2 mouse, double lineSize) {
Connection *hoveringConnection = nullptr;
Room *hoveringRoom = nullptr;

for (auto it = connections.rbegin(); it != connections.rend(); it++) {
Connection *connection = *it;

if (connection->collides(mouse)) {
if (connection->distance(mouse) < 1.0 / lineSize) {
hoveringConnection = connection;

break;
Expand Down
1 change: 1 addition & 0 deletions src/world/MenuItems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void MenuItems::init(Window *window) {
roomName = roomName.substr(0, roomName.find_last_of('.'));

Room *room = new Room(path.string().substr(0, path.string().find_last_of('.')), roomName);
room->Position(cameraOffset);
rooms.push_back(room);
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/world/MenuItems.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class MenuItems {

rooms.push_back(room);

Vector2 *position = room->Position();
Vector2 &position = room->Position();

std::string temp;
std::stringstream data(line.substr(line.find(':') + 1));
Expand All @@ -226,8 +226,8 @@ class MenuItems {
std::getline(data, temp, '>'); // Subregion
std::string subregion = temp;

position->x = x - room->Width() * 0.5;
position->y = y + room->Height() * 0.5;
position.x = x - room->Width() * 0.5;
position.y = y + room->Height() * 0.5;
room->Layer(layer);
if (layer >= LAYER_HIDDEN && layer <= LAYER_HIDDEN + 2) {
room->Hidden(true);
Expand Down Expand Up @@ -433,10 +433,10 @@ class MenuItems {

std::cout << "Exporting rooms" << std::endl;
for (Room *room : rooms) {
Vector2 *roomPosition = room->Position();
const Vector2 &roomPosition = room->Position();
Vector2 position = Vector2(
(roomPosition->x + room->Width() * 0.5) * 3.0,
(roomPosition->y - room->Height() * 0.5) * 3.0
(roomPosition.x + room->Width() * 0.5) * 3.0,
(roomPosition.y - room->Height() * 0.5) * 3.0
);

file << std::setprecision(12);
Expand Down Expand Up @@ -519,10 +519,10 @@ class MenuItems {
for (Room *room : rooms) {
if (room->Hidden()) continue;

double left = room->Position()->x;
double right = room->Position()->x + room->Width();
double top = -room->Position()->y + room->Height();
double bottom = -room->Position()->y;
double left = room->Position().x;
double right = room->Position().x + room->Width();
double top = -room->Position().y + room->Height();
double bottom = -room->Position().y;
bounds.X0(std::min(bounds.X0(), left));
bounds.X1(std::max(bounds.X1(), right));
bounds.Y0(std::min(bounds.Y0(), bottom));
Expand Down Expand Up @@ -573,8 +573,8 @@ class MenuItems {
if (room->Hidden()) continue;

// Top left corner
int x = std::floor(room->Position()->x - room->Width() * 0.0 - bounds.X0()) + padding;
int y = std::floor(-room->Position()->y - room->Height() * 0.0 - bounds.Y0()) + padding;
int x = std::floor(room->Position().x - room->Width() * 0.0 - bounds.X0()) + padding;
int y = std::floor(-room->Position().y - room->Height() * 0.0 - bounds.Y0()) + padding;
y += (2 - room->Layer()) * height / 3;

for (int ox = 0; ox < room->Width(); ox++) {
Expand Down
8 changes: 4 additions & 4 deletions src/world/OffscreenRoom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class OffscreenRoom : public Room {
0.0f
);

coord = new Vector2(72 * 0.5, 43 * -0.5);
// coord = new Vector2(72 * 0.5, 43 * -0.5);

width = 72;
height = 43;
Expand All @@ -36,17 +36,17 @@ class OffscreenRoom : public Room {

void draw(Vector2 mousePosition, double lineSize) override {
Draw::color(1.00f, 1.00f, 1.00f);
fillRect(position->x, position->y, position->x + width, position->y - height);
fillRect(position.x, position.y, position.x + width, position.y - height);

Draw::color(0.00f, 0.00f, 0.00f);
Fonts::rainworld->writeCentred(this->roomName, position->x + (width * 0.5), position->y - (height * 0.5), 5, CENTRE_XY);
Fonts::rainworld->writeCentred(this->roomName, position.x + (width * 0.5), position.y - (height * 0.5), 5, CENTRE_XY);

if (inside(mousePosition)) {
Draw::color(0.00f, 0.75f, 0.00f);
} else {
Draw::color(0.75f, 0.75f, 0.75f);
}
strokeRect(position->x, position->y, position->x + width, position->y - height);
strokeRect(position.x, position.y, position.x + width, position.y - height);
}
};

Expand Down
30 changes: 15 additions & 15 deletions src/world/Room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void Room::draw(Vector2 mousePosition, double lineSize) {
GLuint tintLoc = glGetUniformLocation(Shaders::roomShader, "tintColour");

glUniformMatrix4fv(projLoc, 1, GL_FALSE, projectionMatrix(cameraOffset, cameraScale).m);
glUniformMatrix4fv(modelLoc, 1, GL_FALSE, modelMatrix(position->x, position->y).m);
glUniformMatrix4fv(modelLoc, 1, GL_FALSE, modelMatrix(position.x, position.y).m);
if (hidden) {
glUniform4f(tintLoc, tint.R(), tint.G(), tint.B(), 0.5f);
} else {
Expand All @@ -50,16 +50,16 @@ void Room::draw(Vector2 mousePosition, double lineSize) {
Draw::flushOnEnd = false;
if (water != -1) {
Draw::color(Colour(0.0, 0.0, 0.5, 0.5));
fillRect(position->x, position->y - (height - std::min(water, height)), position->x + width, position->y - height);
fillRect(position.x, position.y - (height - std::min(water, height)), position.x + width, position.y - height);
}

if (inside(mousePosition)) {
Draw::color(Colour(0.00, 0.75, 0.00));
} else {
Draw::color(Colour(0.75, 0.75, 0.75));
}
strokeRect(position->x, position->y, position->x + width, position->y - height);
Draw::flushOnEnd = true;
strokeRect(position.x, position.y, position.x + width, position.y - height);
}

void Room::addQuad(const Vertex &a, const Vertex &b, const Vertex &c, const Vertex &d) {
Expand Down Expand Up @@ -96,21 +96,21 @@ void Room::generateVBO() {
glGenVertexArrays(2, &vao);

addQuad(
{ (float) position->x, (float) position->y, 1.0, 1.0, 1.0 },
{ (float) position->x + width, (float) position->y, 1.0, 1.0, 1.0 },
{ (float) position->x + width, (float) position->y - height, 1.0, 1.0, 1.0 },
{ (float) position->x, (float) position->y - height, 1.0, 1.0, 1.0 }
{ (float) position.x, (float) position.y, 1.0, 1.0, 1.0 },
{ (float) position.x + width, (float) position.y, 1.0, 1.0, 1.0 },
{ (float) position.x + width, (float) position.y - height, 1.0, 1.0, 1.0 },
{ (float) position.x, (float) position.y - height, 1.0, 1.0, 1.0 }
);

for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
int tileType = getTile(x, y) % 16;
int tileData = getTile(x, y) / 16;

float x0 = position->x + x;
float y0 = position->y - y;
float x1 = position->x + x + 1;
float y1 = position->y - y - 1;
float x0 = position.x + x;
float y0 = position.y - y;
float x1 = position.x + x + 1;
float y1 = position.y - y - 1;
float x2 = (x0 + x1) * 0.5;
float y2 = (y0 + y1) * 0.5;

Expand Down Expand Up @@ -222,10 +222,10 @@ void Room::generateVBO() {
}

for (Vector2i &shortcutEntrance : shortcutEntrances) {
float x0 = position->x + shortcutEntrance.x;
float y0 = position->y - shortcutEntrance.y;
float x1 = position->x + shortcutEntrance.x + 1;
float y1 = position->y - shortcutEntrance.y - 1;
float x0 = position.x + shortcutEntrance.x;
float y0 = position.y - shortcutEntrance.y;
float x1 = position.x + shortcutEntrance.x + 1;
float y1 = position.y - shortcutEntrance.y - 1;

addQuad(
{ x0 + 0.25f, y0 - 0.25f, 1.0, 0.0, 1.0 },
Expand Down
54 changes: 24 additions & 30 deletions src/world/Room.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class Room {
0.0f
);

coord = new Vector2();

width = 1;
height = 1;

Expand All @@ -63,12 +61,8 @@ class Room {
}

virtual ~Room() {
delete position;
delete coord;
delete[] geometry;

position = nullptr;
coord = nullptr;
geometry = nullptr;

glDeleteBuffers(2, vbo);
Expand All @@ -77,10 +71,10 @@ class Room {

bool inside(Vector2 otherPosition) {
return (
otherPosition.x >= position->x &&
otherPosition.y >= position->y - height &&
otherPosition.x <= position->x + width &&
otherPosition.y <= position->y
otherPosition.x >= position.x &&
otherPosition.y >= position.y - height &&
otherPosition.x <= position.x + width &&
otherPosition.y <= position.y
);
}

Expand All @@ -89,10 +83,10 @@ class Room {
Vector2 cornerMax = Vector2::max(corner0, corner1);

return (
cornerMin.x <= position->x + width &&
cornerMin.y <= position->y &&
cornerMax.x >= position->x &&
cornerMax.y >= position->y - height
cornerMin.x <= position.x + width &&
cornerMin.y <= position.y &&
cornerMax.x >= position.x &&
cornerMax.y >= position.y - height
);
}

Expand All @@ -107,27 +101,27 @@ class Room {

virtual void draw(Vector2 mousePosition, double lineSize);

void Position(Vector2 newPosition) {
position->x = newPosition.x;
position->y = newPosition.y;
void Position(Vector2 position) {
this->position.x = position.x;
this->position.y = position.y;
}

Vector2 *Position() const {
Vector2 &Position() {
return position;
}

void Coord(const Vector2 &coord) {
this->coord->x = coord.x;
this->coord->y = coord.y;
}
// void Coord(const Vector2 &coord) {
// this->coord.x = coord.x;
// this->coord.y = coord.y;
// }

const std::vector<Vector2> Connections() const {
std::vector<Vector2> transformedConnections;

for (Vector2i connection : connections) {
transformedConnections.push_back(Vector2(
position->x + connection.x + 0.5,
position->y - connection.y - 0.5
position.x + connection.x + 0.5,
position.y - connection.y - 0.5
));
}

Expand All @@ -152,17 +146,17 @@ class Room {
if (connectionId >= connections.size()) return Vector2(0, 0);
Vector2i connection = connections[connectionId];
return Vector2(
position->x + connection.x + 0.5,
position->y - connection.y - 0.5
position.x + connection.x + 0.5,
position.y - connection.y - 0.5
);
}

const Vector2 getShortcutConnectionPosition(unsigned int connectionId) const {
if (connectionId >= connections.size()) return Vector2(0, 0);
Vector2i connection = getShortcutConnection(connectionId);
return Vector2(
position->x + connection.x + 0.5,
position->y - connection.y - 0.5
position.x + connection.x + 0.5,
position.y - connection.y - 0.5
);
}

Expand Down Expand Up @@ -448,8 +442,8 @@ class Room {
std::string path;
std::string roomName;

Vector2 *position;
Vector2 *coord;
Vector2 position;
// Vector2 coord;

int width;
int height;
Expand Down
Loading

0 comments on commit 8eb62a7

Please sign in to comment.