diff --git a/.gitignore b/.gitignore index 124aac0..4c67be8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,6 @@ # Godot-specific ignores .import/ -export.cfg -export_presets.cfg # Imported translations (automatically generated from CSV files) *.translation diff --git a/Godot_v4.2.2-stable_linux.x86_64 b/Godot_v4.2.2-stable_linux.x86_64 new file mode 100755 index 0000000..e6d9dc1 Binary files /dev/null and b/Godot_v4.2.2-stable_linux.x86_64 differ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ab49a82 --- /dev/null +++ b/flake.lock @@ -0,0 +1,112 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixgl": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1713543440, + "narHash": "sha256-lnzZQYG0+EXl/6NkGpyIz+FEOc/DSEG57AP1VsdeNrM=", + "owner": "guibou", + "repo": "nixGL", + "rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a", + "type": "github" + }, + "original": { + "owner": "guibou", + "repo": "nixGL", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1660551188, + "narHash": "sha256-a1LARMMYQ8DPx1BgoI/UN4bXe12hhZkCNqdxNi6uS0g=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "441dc5d512153039f19ef198e662e4f3dbb9fd65", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1722813957, + "narHash": "sha256-IAoYyYnED7P8zrBFMnmp7ydaJfwTnwcnqxUElC1I26Y=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cb9a96f23c491c081b38eab96d22fa958043c9fa", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1718428119, + "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixgl": "nixgl", + "nixpkgs": "nixpkgs_2", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1723083652, + "narHash": "sha256-ait+SeO67n8b3lIaBWwuzVX6F1zyTJ0cY6cHWtvhTyc=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "69e0ad9289fc08ee5a313fb107f00e0f21e7cbb2", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..449df38 --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + description = "Flake for developing and building godot projects"; + + # Flake inputs + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; # A helper for Rust + Nix + nixgl.url = "github:guibou/nixGL"; # Allows you to run OpenGL and or Vulkan applications in a nix shell + }; + + # Flake outputs + outputs = { self, nixpkgs, rust-overlay, nixgl, ... }: + let + # Overlays enable you to customize the Nixpkgs attribute set + overlays = [ + nixgl.overlay + # Makes a `rust-bin` attribute available in Nixpkgs + (import rust-overlay) + # Provides a `rustToolchain` attribute for Nixpkgs that we can use to + # create a Rust environment + (self: super: { + rustToolchain = super.rust-bin.stable.latest.default; + }) + ]; + + # Systems supported + allSystems = [ + "x86_64-linux" # 64-bit Intel/AMD Linux + "aarch64-linux" # 64-bit ARM Linux + "x86_64-darwin" # 64-bit Intel macOS + "aarch64-darwin" # 64-bit ARM macOS + ]; + + # Helper to provide system-specific attributes + forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f { + pkgs = import nixpkgs { inherit overlays system; }; + }); + in + { + # Development environment output + devShells = forAllSystems ({ pkgs }: { + default = import ./nix/shell.nix { inherit pkgs; }; + }); + # Builder + packages = forAllSystems ({ pkgs }: { + default = import ./nix/godot.nix { inherit pkgs; }; + rust = import ./nix/rust.nix { inherit pkgs; }; + }); + }; +} + diff --git a/game/export_presets.cfg b/game/export_presets.cfg new file mode 100644 index 0000000..e859bb9 --- /dev/null +++ b/game/export_presets.cfg @@ -0,0 +1,39 @@ +[preset.0] + +name="Linux/X11" +platform="Linux/X11" +runnable=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="./Game.x86_64" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=1 +binary_format/embed_pck=false +texture_format/bptc=true +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +binary_format/architecture="x86_64" +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="#!/usr/bin/env bash +export DISPLAY=:0 +unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" +\"{temp_dir}/{exe_name}\" {cmd_args}" +ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash +kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") +rm -rf \"{temp_dir}\"" diff --git a/game/icon.svg b/game/icon.svg new file mode 100644 index 0000000..3fe4f4a --- /dev/null +++ b/game/icon.svg @@ -0,0 +1 @@ + diff --git a/game/icon.svg.import b/game/icon.svg.import new file mode 100644 index 0000000..5173724 --- /dev/null +++ b/game/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cktpmnlpyck26" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/game/movement.gd b/game/movement.gd new file mode 100644 index 0000000..ed1b86d --- /dev/null +++ b/game/movement.gd @@ -0,0 +1,12 @@ +extends Sprite2D + +@export var speed = 400 +var velocity + +func get_input(): + var input_direction = Input.get_vector("left", "right", "up", "down") + velocity = input_direction * speed + +func _process(delta): + get_input() + global_position += velocity * delta diff --git a/game/prime.tscn b/game/prime.tscn new file mode 100644 index 0000000..6be55a1 --- /dev/null +++ b/game/prime.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=3 format=3 uid="uid://bmctre2rgtl8e"] + +[ext_resource type="Texture2D" uid="uid://cktpmnlpyck26" path="res://icon.svg" id="1_4hgq7"] +[ext_resource type="Script" path="res://movement.gd" id="2_cn868"] + +[node name="Prime" type="Node2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_4hgq7") +script = ExtResource("2_cn868") diff --git a/game/project.godot b/game/project.godot new file mode 100644 index 0000000..7d93364 --- /dev/null +++ b/game/project.godot @@ -0,0 +1,44 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Game" +run/main_scene="res://prime.tscn" +config/features=PackedStringArray("4.2", "GL Compatibility") +config/icon="res://icon.svg" + +[input] + +left={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null) +] +} +right={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null) +] +} +up={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null) +] +} +down={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null) +] +} + +[rendering] + +renderer/rendering_method="gl_compatibility" +renderer/rendering_method.mobile="gl_compatibility" diff --git a/nix/godot.nix b/nix/godot.nix new file mode 100644 index 0000000..0709566 --- /dev/null +++ b/nix/godot.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: + + + let + binName = "GodotNixBuild"; + dependencies = with pkgs; [ + godot_4 + ]; + in + pkgs.stdenv.mkDerivation { + name = binName; + src = ../.; + buildInputs = dependencies; + buildPhase = '' + # this line removes a bug where value of $HOME is set to a non-writable /homeless-shelter dir + export HOME=$TMPDIR + + mkdir -p $HOME/.local/share/godot/export_templates/4.2.2.stable + cp ${pkgs.godot_4-export-templates}/linux_* $HOME/.local/share/godot/export_templates/4.2.2.stable/ + + mkdir -p $out/bin + godot4 --headless --export-release Linux/X11 game/project.godot $out/bin/${binName} + + runHook postBuild + ''; + + dontInstall = true; + dontFixup = true; + dontStrip = true; + + } + diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 0000000..f9f3d6b --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1,21 @@ +{ pkgs ? import {} }: + +pkgs.mkShell { + # The Nix packages provided in the environment + packages = (with pkgs; [ + # Fluff + cargo-mommy + onefetch + # Tools + helix + lazygit + # Needed + nixgl.nixVulkanIntel + godot_4 # For now it recommended to install godot locally thought we might add NixGL in the future + rustToolchain + ]) ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs; [ libiconv ]); + shellHook = '' + onefetch + ''; +} + diff --git a/staticBinaries/linux_release.x86_64 b/staticBinaries/linux_release.x86_64 new file mode 100755 index 0000000..55c1fab Binary files /dev/null and b/staticBinaries/linux_release.x86_64 differ