-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
247 additions
and
23 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
id,comment,en,fr,zh-CN | ||
AD0,,Did you know? This game was developed during 7+ months!,Tu savais ? Cette jeux été déveloper dans plus de 7 mois!,你知道吗?这个游戏的开发周期长于7个月! | ||
AD1,,Did you know? This game uses it's cusiom engine!,Tu savais ? Cette jeux utilise sa propre moteur de jeux!,你知道吗?这个游戏用的是自己的引擎! | ||
AD1,,Did you know? This game uses its custom engine!,Tu savais ? Cette jeux utilise sa propre moteur de jeux!,你知道吗?这个游戏用的是自己的引擎! | ||
AD2,,Did you know? This game was coded entirely in C++!,Tu savais ? Cette jeux été crée entièrement avec C++!,你知道吗?这个游戏是完全用C++写的! | ||
AD3,,Did you know? This game handles (almost) everything by itself!,Tu savais ? Cette jeux fait tout par lui même!,你知道吗?这个游戏自己掌控所有东西! | ||
AD4,,Did you know? This game gets 1000+ FPS on natively!,Tu savais ? Cette jeux fait plus de 1000+ FPS!,你知道吗?这个游戏有1000+ FPS! | ||
AD4,,Did you know? This game gets 1000+ FPS natively!,Tu savais ? Cette jeux fait plus de 1000+ FPS!,你知道吗?这个游戏有1000+ FPS! |
File renamed without changes
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,39 @@ | ||
#pragma once | ||
|
||
#include "components.hpp" | ||
#include "components/inventory.hpp" | ||
#include "screens/screen.hpp" | ||
|
||
#include <cstdint> | ||
|
||
struct furnace_t {}; | ||
|
||
class FurnaceInventory : public Inventory { | ||
public: | ||
explicit FurnaceInventory(struct furnace_t); | ||
FurnaceInventory(FurnaceInventory&&) = delete; | ||
FurnaceInventory(const FurnaceInventory&) = delete; | ||
FurnaceInventory& operator=(FurnaceInventory&&) = delete; | ||
FurnaceInventory& operator=(const FurnaceInventory&) = delete; | ||
~FurnaceInventory() override = default; | ||
|
||
bool update(class Scene* scene, float delta) override; | ||
void draw(class Scene* scene) override; | ||
|
||
private: | ||
void craft(); | ||
void placeGrid(); | ||
bool checkRecipie(std::uint64_t r); | ||
|
||
std::vector<Components::Item> mSmeltingItems; | ||
std::vector<std::uint64_t> mSmeltingCount; | ||
|
||
std::size_t mLastCraft; | ||
|
||
constexpr const static inline double mAX = 56; | ||
constexpr const static inline double mAY = 97; | ||
constexpr const static inline double mBX = 0; | ||
constexpr const static inline double mBY = 36; | ||
constexpr const static inline double mOutX = 57; | ||
constexpr const static inline double mOutY = 23; | ||
}; |
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
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,150 @@ | ||
#include "components/furnace.hpp" | ||
|
||
#include "game.hpp" | ||
#include "managers/eventManager.hpp" | ||
#include "managers/systemManager.hpp" | ||
#include "opengl/mesh.hpp" | ||
#include "opengl/texture.hpp" | ||
#include "registers.hpp" | ||
#include "scene.hpp" | ||
#include "systems/UISystem.hpp" | ||
|
||
#include <SDL3/SDL.h> | ||
#include <algorithm> | ||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
// Crafting table | ||
FurnaceInventory::FurnaceInventory(struct furnace_t) | ||
: Inventory(Eigen::Vector2f(8, 8), "ui/furnace.png"), mSmeltingItems(2, Components::AIR()), | ||
mSmeltingCount(2, 0), mLastCraft(0) { | ||
mCountRegister[getID<FurnaceInventory>()] = &mSmeltingCount; | ||
mItemRegister[getID<FurnaceInventory>()] = &mSmeltingItems; | ||
} | ||
|
||
bool FurnaceInventory::update(class Scene* const, const float) { return true; } | ||
|
||
void FurnaceInventory::craft() {} | ||
|
||
bool FurnaceInventory::checkRecipie(const std::uint64_t r) { return r; } | ||
|
||
void FurnaceInventory::draw(class Scene* scene) { | ||
Inventory::drawInventory(scene); | ||
Inventory::drawItems(scene); | ||
|
||
SystemManager* const systemManager = mGame->getSystemManager(); | ||
const Eigen::Vector2f dimensions = systemManager->getDemensions(); | ||
Shader* const shader = systemManager->getShader("ui.vert", "ui.frag"); | ||
Mesh* const mesh = systemManager->getUISystem()->getMesh(); | ||
|
||
float sx, sy; | ||
float ox, oy; | ||
float scale; | ||
if (dimensions.x() <= dimensions.y()) { | ||
sx = dimensions.x() / 4 * 3; | ||
sy = sx / INVENTORY_TEXTURE_WIDTH * INVENTORY_TEXTURE_HEIGHT; | ||
ox = sx / 6; | ||
oy = (dimensions.y() - sy) / 2; | ||
|
||
scale = sx / INVENTORY_TEXTURE_WIDTH; | ||
} else { | ||
sy = dimensions.y() / 4 * 3; | ||
sx = sy / INVENTORY_TEXTURE_HEIGHT * INVENTORY_TEXTURE_WIDTH; | ||
ox = (dimensions.x() - sx) / 2; | ||
oy = sy / 6; | ||
|
||
scale = sy / INVENTORY_TEXTURE_HEIGHT; | ||
} | ||
|
||
ox += (INVENTORY_SLOTS_OFFSET_X + mAX) * scale - (INVENTORY_SLOT_X * scale - sx / INVENTORY_INV_SCALE); | ||
oy += (INVENTORY_SLOTS_OFFSET_Y + mAY) * scale - (INVENTORY_SLOT_Y * scale - sy / INVENTORY_INV_SCALE); | ||
|
||
shader->activate(); | ||
shader->set("texture_diffuse"_u, 0); | ||
shader->set("size"_u, sx / INVENTORY_INV_SCALE, sy / INVENTORY_INV_SCALE); | ||
|
||
const bool virtItems = | ||
scene->getSignal(EventManager::RIGHT_HOLD_SIGNAL) || scene->getSignal(EventManager::LEFT_HOLD_SIGNAL); | ||
|
||
std::uint64_t vcount = 0; | ||
if (scene->getSignal(EventManager::LEFT_HOLD_SIGNAL)) { | ||
if (!mPath.empty()) { | ||
vcount = scene->mMouse.count / mPath.size(); | ||
} | ||
} else { | ||
vcount = 1; | ||
} | ||
|
||
// Fuel spot | ||
if (!(mSmeltingCount[0] == 0 && !virtItems)) { | ||
auto type = mSmeltingItems[0]; | ||
auto count = mSmeltingCount[0]; | ||
if (virtItems) { | ||
if (auto s = std::ranges::find(mPath, std::make_pair(getID<FurnaceInventory>(), 0)); | ||
s != mPath.end()) { | ||
count += vcount; | ||
type = scene->mMouse.item; | ||
} else if (count == 0) { | ||
// This slot isn't in our path | ||
goto e1; | ||
} | ||
} | ||
|
||
Texture* const texture = systemManager->getTexture(registers::TEXTURES.at(type)); | ||
texture->activate(0); | ||
|
||
shader->set("offset"_u, ox + 5, oy); | ||
|
||
mesh->draw(shader); | ||
|
||
if (count > 1) { | ||
mGame->getSystemManager()->getTextSystem()->draw( | ||
std::to_string(count), Eigen::Vector2f(ox + INVENTORY_SLOT_X / 2 * scale - 2, oy - 5), | ||
false); | ||
} | ||
|
||
shader->activate(); | ||
} | ||
e1: | ||
|
||
ox += mBX * scale; | ||
oy += mBY * scale; | ||
// Item spot | ||
if (!(mSmeltingCount[1] == 0 && !virtItems)) { | ||
auto type = mSmeltingItems[1]; | ||
auto count = mSmeltingCount[1]; | ||
if (virtItems) { | ||
if (auto s = std::ranges::find(mPath, std::make_pair(getID<FurnaceInventory>(), 1)); | ||
s != mPath.end()) { | ||
count += vcount; | ||
type = scene->mMouse.item; | ||
} else if (count == 0) { | ||
// This slot isn't in our path | ||
goto e2; | ||
} | ||
} | ||
|
||
Texture* const texture = systemManager->getTexture(registers::TEXTURES.at(type)); | ||
texture->activate(0); | ||
|
||
shader->set("offset"_u, ox + 5, oy); | ||
|
||
mesh->draw(shader); | ||
|
||
if (count > 1) { | ||
mGame->getSystemManager()->getTextSystem()->draw( | ||
std::to_string(count), Eigen::Vector2f(ox + INVENTORY_SLOT_X / 2 * scale - 2, oy - 5), | ||
false); | ||
} | ||
|
||
shader->activate(); | ||
} | ||
e2: | ||
|
||
// Draw output slot | ||
// 57x9 | ||
ox += mOutX * scale; | ||
oy += mOutY * scale; | ||
|
||
Inventory::drawMouse(scene); | ||
} |
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
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
Oops, something went wrong.