diff --git a/src/nostalgia/core/context.hpp b/src/nostalgia/core/context.hpp index cd842632..95dfbaa2 100644 --- a/src/nostalgia/core/context.hpp +++ b/src/nostalgia/core/context.hpp @@ -8,6 +8,7 @@ #include "assetmanager.hpp" #include "event.hpp" +#include "input.hpp" namespace nostalgia::common { class Size; @@ -16,13 +17,7 @@ class Size; namespace nostalgia::core { class Context; - -class Drawer { - public: - virtual ~Drawer() = default; - - virtual void draw(Context*) noexcept = 0; -}; +class Drawer; // User Input Output class Context { @@ -31,6 +26,7 @@ class Context { friend constexpr T *applicationData(Context *ctx) noexcept; friend constexpr void setConstantRefresh(Context *ctx, bool) noexcept; friend bool bgStatus(Context *ctx, unsigned bg) noexcept; + friend bool buttonDown(Context *ctx, Key) noexcept; friend common::Size getScreenSize(Context *ctx) noexcept; friend int getScreenHeight(Context *ctx) noexcept; friend int getScreenWidth(Context *ctx) noexcept; diff --git a/src/nostalgia/core/gfx.hpp b/src/nostalgia/core/gfx.hpp index ebc797bb..c4a59b8d 100644 --- a/src/nostalgia/core/gfx.hpp +++ b/src/nostalgia/core/gfx.hpp @@ -17,6 +17,13 @@ namespace nostalgia::core { extern char charMap[128]; +class Drawer { + public: + virtual ~Drawer() = default; + + virtual void draw(Context*) noexcept = 0; +}; + enum class TileSheetSpace { Background, Sprite diff --git a/src/nostalgia/core/glfw/gfx.cpp b/src/nostalgia/core/glfw/gfx.cpp index b88302f9..f687e862 100644 --- a/src/nostalgia/core/glfw/gfx.cpp +++ b/src/nostalgia/core/glfw/gfx.cpp @@ -3,7 +3,6 @@ */ #include <GLFW/glfw3.h> -#include <imgui_impl_opengl3.h> #include <imgui_impl_glfw.h> #include <ox/std/defines.hpp> diff --git a/src/nostalgia/core/ptidxconv.hpp b/src/nostalgia/core/ptidxconv.hpp index 3c19227c..fe8d4744 100644 --- a/src/nostalgia/core/ptidxconv.hpp +++ b/src/nostalgia/core/ptidxconv.hpp @@ -11,24 +11,19 @@ namespace nostalgia::core { [[nodiscard]] -constexpr std::size_t pointToIdx(int w, int x, int y) noexcept { +constexpr std::size_t ptToIdx(int x, int y, int c) noexcept { constexpr auto colLength = static_cast<std::size_t>(PixelsPerTile); - const auto rowLength = static_cast<std::size_t>(static_cast<std::size_t>(w / TileWidth) * colLength); + const auto rowLength = static_cast<std::size_t>(static_cast<std::size_t>(c / TileWidth) * colLength); const auto colStart = static_cast<std::size_t>(colLength * static_cast<std::size_t>(x / TileWidth)); const auto rowStart = static_cast<std::size_t>(rowLength * static_cast<std::size_t>(y / TileHeight)); const auto colOffset = static_cast<std::size_t>(x % TileWidth); - const auto rowOffset = static_cast<std::size_t>((y % TileHeight) * TileHeight); + const auto rowOffset = static_cast<std::size_t>(static_cast<std::size_t>(y % TileHeight) * TileHeight); return static_cast<std::size_t>(colStart + colOffset + rowStart + rowOffset); } [[nodiscard]] -constexpr std::size_t ptToIdx(int x, int y, int c) noexcept { - return pointToIdx(c * TileWidth, x, y); -} - -[[nodiscard]] -constexpr std::size_t ptToIdx(common::Point pt, int c) noexcept { - return pointToIdx(c * TileWidth, pt.x, pt.y); +constexpr std::size_t ptToIdx(const common::Point &pt, int c) noexcept { + return ptToIdx(pt.x, pt.y, c * TileWidth); } [[nodiscard]]