From a9054b3be4fc7d913a23f1c7a16f3b07c97f829f Mon Sep 17 00:00:00 2001 From: Syed Daanish Date: Tue, 14 Jul 2026 13:07:13 +0100 Subject: [PATCH] Cleanup --- flake.nix | 23 +++++++++++++++-------- include/app/elements.h | 4 ++-- include/ecs/ecs.h | 8 ++++++-- samples/button.rb | 8 +++++++- src/app/app.cc | 2 +- 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index 630d761..a2fe280 100644 --- a/flake.nix +++ b/flake.nix @@ -1,20 +1,27 @@ { - description = "game"; + description = "game engine"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = { self, nixpkgs }: + outputs = + { self, nixpkgs }: let systems = [ "x86_64-linux" ]; - forAllSystems = f: - nixpkgs.lib.genAttrs systems (system: - f (import nixpkgs { - inherit system; - })); - in { + forAllSystems = + f: + nixpkgs.lib.genAttrs systems ( + system: + f ( + import nixpkgs { + inherit system; + } + ) + ); + in + { devShells = forAllSystems (pkgs: { default = pkgs.mkShell { packages = with pkgs; [ diff --git a/include/app/elements.h b/include/app/elements.h index bb7b5c5..9188c2a 100644 --- a/include/app/elements.h +++ b/include/app/elements.h @@ -73,8 +73,8 @@ private: }; struct ERect : Element { - Color color = {255, 255, 255}; Vec2 shape = {0, 0}; + Color color = {255, 255, 255}; Vec2 size() override; @@ -97,4 +97,4 @@ struct EWorld : Element { inline Pool element_pool; } // namespace app -#endif \ No newline at end of file +#endif diff --git a/include/ecs/ecs.h b/include/ecs/ecs.h index 751a44c..136e3b6 100644 --- a/include/ecs/ecs.h +++ b/include/ecs/ecs.h @@ -3,8 +3,12 @@ #include "utils.h" -struct Entity; +struct Entity {}; struct Component; struct System; -#endif \ No newline at end of file +struct EntityPool { + Entity entities[]; +}; + +#endif diff --git a/samples/button.rb b/samples/button.rb index 7996b7e..2f43e5e 100644 --- a/samples/button.rb +++ b/samples/button.rb @@ -58,12 +58,18 @@ rect.click do end App.map_key :mouse_left, :action_name +App.map_key :q, :quit start = Time.now c_ = 0.0 c_c = 0 App.update do |delta_time| + if App.pressed?(:quit) + App.exit! + next + end + c_ += delta_time c_c += 1 @@ -114,4 +120,4 @@ p "Average delta time: #{c_ / c_c}s" p "Average FPS (real): #{c_c / time}s" p "Average FPS (from dt): #{c_c / c_}" p "Time since start (real): #{time}s" -p "Time since start (from dt): #{c_}s" \ No newline at end of file +p "Time since start (from dt): #{c_}s" diff --git a/src/app/app.cc b/src/app/app.cc index 56add03..2fbca29 100644 --- a/src/app/app.cc +++ b/src/app/app.cc @@ -108,4 +108,4 @@ void App::loop() { window.clear(); } } -} // namespace app \ No newline at end of file +} // namespace app