setup compiler
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/target
|
4734
Cargo.lock
generated
Normal file
4734
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
50
Cargo.toml
Normal file
50
Cargo.toml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
cargo-features = ["codegen-backend"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "game"
|
||||||
|
path = "src/game/main.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "snake"
|
||||||
|
path = "src/snake/main.rs"
|
||||||
|
|
||||||
|
[package]
|
||||||
|
name = "glite"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bevy = { version = "0.15.0", features = ["dynamic_linking"] }
|
||||||
|
|
||||||
|
# Enable a small amount of optimization in the dev profile.
|
||||||
|
[profile.dev]
|
||||||
|
opt-level = 1
|
||||||
|
codegen-backend = "cranelift"
|
||||||
|
|
||||||
|
# Enable a large amount of optimization in the dev profile for dependencies.
|
||||||
|
[profile.dev.package."*"]
|
||||||
|
codegen-backend = "llvm"
|
||||||
|
opt-level = 3
|
||||||
|
|
||||||
|
[unstable]
|
||||||
|
codegen-backend = true
|
||||||
|
|
||||||
|
# Enable more optimization in the release profile at the cost of compile time.
|
||||||
|
[profile.release]
|
||||||
|
# Compile the entire create as one unit.
|
||||||
|
# Slows compile times, marginal improvements.
|
||||||
|
codegen-units = 1
|
||||||
|
# Do a second optimization pass over the entire program, including dependencies.
|
||||||
|
# Slows compile times, marginal improvements.
|
||||||
|
lto = "thin"
|
||||||
|
|
||||||
|
# Optimize for size in the wasm-release profile to reduce load times and bandwidth usage on web.
|
||||||
|
[profile.wasm-release]
|
||||||
|
# Default to release profile values.
|
||||||
|
inherits = "release"
|
||||||
|
# Optimize with size in mind (also try "z", sometimes it is better).
|
||||||
|
# Slightly slows compile times, great improvements to file size and runtime performance.
|
||||||
|
opt-level = "s"
|
||||||
|
# Strip all debugging information from the binary to slightly reduce file size.
|
||||||
|
strip = "debuginfo"
|
||||||
|
|
53
src/game/main.rs
Normal file
53
src/game/main.rs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
struct Person;
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
struct Name(String);
|
||||||
|
|
||||||
|
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())));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
|
struct GreetTimer(Timer);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn change_names(mut query: Query<&mut Name, With<Person>>) {
|
||||||
|
for mut name in &mut query {
|
||||||
|
if name.0 == "Elaina Proctor" {
|
||||||
|
name.0 = "Elain Hume".to_string();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn hello_world() {
|
||||||
|
println!("hello world!");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct HelloPlugin;
|
||||||
|
|
||||||
|
impl Plugin for HelloPlugin {
|
||||||
|
fn build(&self, app: &mut App) {
|
||||||
|
app.insert_resource(GreetTimer(Timer::from_seconds(2.0, TimerMode::Repeating)));
|
||||||
|
app.add_systems(Startup, add_people);
|
||||||
|
app.add_systems(Update, (change_names, greet_people).chain());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn main() {
|
||||||
|
App::new()
|
||||||
|
.add_plugins(DefaultPlugins)
|
||||||
|
.add_plugins(HelloPlugin)
|
||||||
|
.run();
|
||||||
|
}
|
3
src/snake/main.rs
Normal file
3
src/snake/main.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
App::new().add_plugins(DefaultPlugins).run();
|
||||||
|
}
|
Reference in New Issue
Block a user