Initial commit

This commit is contained in:
Daniel Flanagan 2023-12-19 11:17:49 -06:00
parent 925ca1941d
commit b3aaafae3c
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
6 changed files with 4395 additions and 12 deletions

4
.cargo/config.toml Normal file
View file

@ -0,0 +1,4 @@
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=/nix/store/n6fa181ai5hxjd8dpa2qqhd4lql3475x-mold-2.4.0/bin/mold"]

7
.gitignore vendored
View file

@ -1,2 +1,9 @@
/target /target
/.direnv /.direnv
# Added by cargo
#
# already existing elements were commented out
#/target

4292
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

17
Cargo.toml Normal file
View file

@ -0,0 +1,17 @@
[package]
name = "kodotag-rs"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
# TODO(dmf): @release remove `dynamic_linking`
bevy = { version = "0.12.1", features = ["wayland", "file_watcher", "async-io", "serialize", "trace", "dynamic_linking"] }
[profile.dev]
opt-level = 1
[profile.dev.package."*"]
opt-level = 3

View file

@ -4,29 +4,41 @@
self, self,
nixpkgs, nixpkgs,
}: let }: let
inherit (self) outputs;
supportedSystems = ["x86_64-linux"]; supportedSystems = ["x86_64-linux"];
forEachSupportedSystem = f: forEachSupportedSystem = nixpkgs.lib.genAttrs supportedSystems;
nixpkgs.lib.genAttrs supportedSystems (system:
f {
inherit system;
pkgs = import nixpkgs {inherit system;};
});
in { in {
devShells = forEachSupportedSystem ({ devShells = forEachSupportedSystem (system: let
pkgs, pkgs = import nixpkgs {inherit system;};
system, in {
}: { # TODO: packages
rust-development = pkgs.mkShell { # TODO: checks
rust-dev = pkgs.mkShell rec {
nativeBuildInputs = with pkgs; [pkg-config];
buildInputs = with pkgs; [ buildInputs = with pkgs; [
clang
cargo cargo
rustc rustc
rustfmt rustfmt
rustPackages.clippy rustPackages.clippy
rust-analyzer rust-analyzer
mold
# source: https://github.com/bevyengine/bevy/blob/main/docs/linux_dependencies.md#nix
udev
alsa-lib
vulkan-loader
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
libxkbcommon
wayland
]; ];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
}; };
default = forEachSupportedSystem ({system, ...}: self.outputs.${system}.rust-development); default = outputs.devShells.${system}.rust-dev;
}); });
}; };
} }

51
src/main.rs Normal file
View file

@ -0,0 +1,51 @@
use bevy::prelude::*;
#[derive(Component)]
struct Person;
#[derive(Component)]
struct Name(String);
#[derive(Component)]
struct Position {
x: f32,
y: f32,
}
#[derive(Resource)]
struct GreetTimer(Timer);
struct Entity(u64);
pub struct HelloPlugin;
impl Plugin for HelloPlugin {
fn build(&self, app: &mut App) {
// add things to your app here
}
}
fn add_people(mut commands: Commands) {
commands.spawn((Person, Name("Elaina Proctor".to_string())));
commands.spawn((Person, Name("Renzo Hume".to_string())));
commands.spawn((Person, Name("Zayna Nieves".to_string())));
}
fn main() {
let mut app = App::new();
app.add_plugins((DefaultPlugins, HelloPlugin))
.add_systems(Startup, add_people)
.add_systems(Update, greet_people)
.insert_resource(GreetTimer(Timer::from_seconds(0.2, TimerMode::Repeating)));
app.run()
}
fn greet_people(time: Res<Time>, mut timer: ResMut<GreetTimer>, query: Query<&Name, With<Person>>) {
// update our timer with the time elapsed since the last update
// if that caused the timer to finish, we say hello to everyone
if timer.0.tick(time.delta()).just_finished() {
for name in &query {
println!("hello {}!", name.0);
}
}
}