Changes
7 changed files (+103/-47)
-
-
@@ -1,3 +1,4 @@/.lake result *.AppImage save*
-
-
-
@@ -70,9 +70,6 @@-- Each cell of the grid corresponds to 5m, so peeps move at 15m/s (≈33 mph) def ticksPerSecond := 3 def initialScreenWidth := 960 def initialScreenHeight := 640 /-- Keyboard sensitivity -/ def sensitivity := 5
-
@@ -1183,7 +1180,9 @@ closeWindowdef main (args : List String) : IO Unit := do setConfigFlags <| Flags.window_resizable ||| Flags.window_highdpi initWindow initialScreenWidth initialScreenHeight "MonotoniCity" initWindow 960 640 "MonotoniCity" -- The initial dimensions don't matter since we immediately resize the window to work around a HiDPI bug maximizeWindow setTargetFPS fps let mut s := { rng := mkStdGen (← IO.rand 0 (2 ^ 32))
-
-
-
@@ -8,13 +8,13 @@ TODO screenshot## Building To build this using Nix (least painful trust me), just run `nix build`. (TODO: this is broken) To build this using Nix (least painful trust me), just run `nix build`. On NixOS you can also build this by hardcoding the directory of `libraylib.so` in `lakefile.toml` (for instance `moreLinkArgs = ["-L/nix/store/2ndddyrjb1ahx05kmsjqvzkagz1bdmpk-raylib-6.0/lib", "-lraylib"]`) and running `lake build`, which can be much faster due to caching. Otherwise, install Raylib and run `lake build` and hope for the best. It probably won't work, but you can give it a try. To build a (huge) precompiled bundle that can run on any Linux distro, run `nix bundle .#packages.x86_64-linux.default`. (TODO this seems to be broken?) To build an AppImage that can run on any Linux distro, run `nix bundle --bundler github:NixOS/bundlers#toAppImage`. ## Gameplay
-
-
-
@@ -1,12 +1,51 @@{ "nodes": { "flake-utils": { "inputs": { "systems": "systems" }, "locked": { "lastModified": 1731533236, "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { "owner": "numtide", "repo": "flake-utils", "type": "github" } }, "nixgl": { "inputs": { "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" ] }, "locked": { "lastModified": 1762090880, "narHash": "sha256-fbRQzIGPkjZa83MowjbD2ALaJf9y6KMDdJBQMKFeY/8=", "owner": "nix-community", "repo": "nixGL", "rev": "b6105297e6f0cd041670c3e8628394d4ee247ed5", "type": "github" }, "original": { "owner": "nix-community", "repo": "nixGL", "type": "github" } }, "nixpkgs": { "locked": { "lastModified": 1782841244, "narHash": "sha256-AVPp5GMqkr2zVPMQ9XH23j2plIxl98Y0YdwankKC+o8=", "lastModified": 1782856423, "narHash": "sha256-ehxnpv3BZodGJeFPIXnDs4GpHdkqU3+MtW6OCwRzwnM=", "owner": "i-love-lean", "repo": "nixpkgs", "rev": "8a3b31e901545f7bd238edb7d7cabb801717c7f9", "rev": "ac5524f9353a9a596e0dbef34438af5f528fcd2b", "type": "github" }, "original": {
-
@@ -18,7 +57,23 @@ }}, "root": { "inputs": { "nixgl": "nixgl", "nixpkgs": "nixpkgs" } }, "systems": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "owner": "nix-systems", "repo": "default", "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "type": "github" }, "original": { "owner": "nix-systems", "repo": "default", "type": "github" } } },
-
-
-
@@ -1,14 +1,27 @@{ description = "An OpenTTD-like game written in Lean"; # TODO: Change this back to nixos-unstable once it gets lean4 v4.31.0 inputs.nixpkgs.url = "github:i-love-lean/nixpkgs/lean4-bump"; inputs = { # TODO: Change this back to nixos-unstable once it gets lean4 v4.31.0 nixpkgs.url = "github:i-love-lean/nixpkgs/lean4-bump"; nixgl = { url = "github:nix-community/nixGL"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs }: { self, nixpkgs, nixgl, }: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; pkgs = import nixpkgs { inherit system; overlays = [ nixgl.overlay ]; }; in { packages.${system}.default = pkgs.leanPackages.buildLakePackage {
-
@@ -32,8 +45,12 @@ '';}; apps.${system}.default = let # Use nixGL for running this on non-NixOS # TODO: Nvidia support wrapper = pkgs.writeShellScript "monotonicity" '' exec ${pkgs.rlwrap}/bin/rlwrap ${self.packages.${system}.default}/bin/monotonicity "$@" exec ${pkgs.nixgl.nixGLIntel}/bin/nixGLIntel ${pkgs.rlwrap}/bin/rlwrap ${ self.packages.${system}.default }/bin/monotonicity "$@" ''; in {
-
-
-
@@ -27,31 +27,6 @@ The internal data representation of the game is a 2D vector for the grid for fast access for info about a point and arrays of vehicles, buildings etc to easily iterate over all those objects. To save the game we dump all these to JSON and vice versa for loading a save (unfortunately this bloats up the binary ugh). I don't really need to plan this out in advance but rather just add more fields as neededFirst step: render the grid using raylib Street names TODO: bundle seems to be missing deps? NFO: Initializing raylib 6.0 INFO: Platform backend: DESKTOP (GLFW) INFO: Supported raylib modules: INFO: > rcore:..... loaded (mandatory) INFO: > rlgl:...... loaded (mandatory) INFO: > rshapes:... loaded (optional) INFO: > rtextures:. loaded (optional) INFO: > rtext:..... loaded (optional) INFO: > rmodels:... loaded (optional) INFO: > raudio:.... loaded (optional) Fontconfig error: Cannot load default config file: No such file: (null) Gtk-Message: 19:24:22.735: Failed to load module "colorreload-gtk-module" Gtk-Message: 19:24:22.735: Failed to load module "window-decorations-gtk-module" WARNING: GLFW: Error: 65542 Description: EGL: Failed to get EGL display: Success WARNING: GLFW: Failed to initialize Window WARNING: SYSTEM: Failed to initialize platform INFO: TIMER: Target time per frame: 16.667 milliseconds https://www.raylib.com/cheatsheet/cheatsheet.html The street names are from https://github.com/rossburton/barnum/blob/master/source-data/street-names.txt
-
-
-
@@ -1,5 +1,5 @@diff --git a/c/raylib_bindings.c b/c/raylib_bindings.c index 902a945..0750084 100644 index 902a945..37e2a51 100644 --- a/c/raylib_bindings.c +++ b/c/raylib_bindings.c @@ -314,11 +314,11 @@ static inline Camera2D camera2D_of_arg(lean_obj_arg camera) {
-
@@ -19,10 +19,16 @@ +// }lean_obj_res initWindow(lean_obj_arg width, lean_obj_arg height, b_lean_obj_arg title) { @@ -336,6 +336,18 @@ lean_obj_res closeWindow(void) { @@ -336,6 +336,24 @@ lean_obj_res closeWindow(void) { return IO_UNIT; } +lean_obj_res maximizeWindow(void) { + MaximizeWindow(); + return IO_UNIT; +} + + +lean_obj_res getScreenWidth(void) { + return lean_io_result_mk_ok(lean_uint32_to_nat(GetScreenWidth())); +}
-
@@ -38,7 +44,7 @@ +lean_obj_res beginDrawing(void) { BeginDrawing(); return IO_UNIT; @@ -402,6 +414,15 @@ lean_obj_res beginMode3D(lean_obj_arg camera) { @@ -402,6 +420,15 @@ lean_obj_res beginMode3D(lean_obj_arg camera) { return IO_UNIT; }
-
@@ -54,7 +60,7 @@ +lean_obj_res drawCube(lean_obj_arg position, double width, double height, double length, lean_obj_arg color) { DrawCube(vector3_of_arg(position), width, height, length, @@ -416,6 +437,13 @@ lean_obj_res drawCubeWires(lean_obj_arg position, double width, double height, @@ -416,6 +443,13 @@ lean_obj_res drawCubeWires(lean_obj_arg position, double width, double height, return IO_UNIT; }
-
@@ -69,13 +75,16 @@ lean_obj_res drawGrid(lean_obj_arg slices, double spacing) {DrawGrid(lean_uint32_of_nat_mk(slices), spacing); return IO_UNIT; diff --git a/lean/Raylean/Core.lean b/lean/Raylean/Core.lean index e0818b6..23f03d9 100644 index e0818b6..ef40dfb 100644 --- a/lean/Raylean/Core.lean +++ b/lean/Raylean/Core.lean @@ -15,6 +15,15 @@ opaque closeWindow : IO Unit @@ -15,6 +15,18 @@ opaque closeWindow : IO Unit @[extern "windowShouldClose"] opaque windowShouldClose : IO Bool +@[extern "maximizeWindow"] +opaque maximizeWindow : IO Unit + +@[extern "getScreenWidth"] +opaque getScreenWidth : IO Nat +
-
@@ -88,7 +97,7 @@ +/- Cursor-related functions -/ @[extern "disableCursor"] @@ -43,6 +52,9 @@ opaque beginMode3D : (camera : @& Camera3D) → IO Unit @@ -43,6 +55,9 @@ opaque beginMode3D : (camera : @& Camera3D) → IO Unit @[extern "endMode3D"] opaque endMode3D : IO Unit
-
@@ -98,7 +107,7 @@ +/- Timing-related functions -/ @[extern "setTargetFPS"] @@ -112,12 +124,18 @@ opaque drawText : (text : @& String) → (posX : Nat) → (posY : Nat) → (font @@ -112,12 +127,18 @@ opaque drawText : (text : @& String) → (posX : Nat) → (posY : Nat) → (font /- Basic geometric 3D shapes drawing functions -/
-