Skip to content

Instantly share code, notes, and snippets.

@Archspect
Last active March 29, 2023 13:08
Show Gist options
  • Save Archspect/02a2007bbc85f90dc89db30b58d1fce7 to your computer and use it in GitHub Desktop.
Save Archspect/02a2007bbc85f90dc89db30b58d1fce7 to your computer and use it in GitHub Desktop.
//! Eat the cakes. Eat them all. An example 3D game.
use std::f32::consts::PI;
use bevy::prelude::*;
use rand::Rng;
#[derive(Clone, Eq, PartialEq, Debug, Hash, Default, States)]
enum GameState {
#[default]
Playing,
GameOver,
}
#[derive(Resource)]
struct BonusSpawnTimer(Timer);
fn main() {
App::new()
.init_resource::<Game>()
.insert_resource(BonusSpawnTimer(Timer::from_seconds(
5.0,
TimerMode::Repeating,
)))
.add_plugins(DefaultPlugins)
.add_state::<GameState>()
.add_systems((
setup_cameras.on_startup(),
setup.in_schedule(OnEnter(GameState::Playing)),
))
.add_systems(
(
move_player,
focus_camera,
rotate_bonus,
scoreboard_system,
spawn_bonus,
)
.in_set(OnUpdate(GameState::Playing)),
)
.add_systems((
teardown.in_schedule(OnExit(GameState::Playing)),
display_score.in_schedule(OnEnter(GameState::GameOver)),
gameover_keyboard.in_set(OnUpdate(GameState::GameOver)),
teardown.in_schedule(OnExit(GameState::GameOver)),
))
.add_system(bevy::window::close_on_esc)
.run();
}
struct Cell {
height: f32,
}
#[derive(Default)]
struct Player {
entity: Option<Entity>,
i: usize,
j: usize,
move_cooldown: Timer,
}
#[derive(Default)]
struct Bonus {
entity: Option<Entity>,
i: usize,
j: usize,
handle: Handle<Scene>,
}
#[derive(Resource, Default)]
struct Game {
board: Vec<Vec<Cell>>,
player: Player,
bonus: Bonus,
score: i32,
cake_eaten: u32,
camera_should_focus: Vec3,
camera_is_focus: Vec3,
}
const BOARD_SIZE_I: usize = 14;
const BOARD_SIZE_J: usize = 21;
const RESET_FOCUS: [f32; 3] = [
BOARD_SIZE_I as f32 / 2.0,
0.0,
BOARD_SIZE_J as f32 / 2.0 - 0.5,
];
fn setup_cameras(mut commands: Commands, mut game: ResMut<Game>) {
game.camera_should_focus = Vec3::from(RESET_FOCUS);
game.camera_is_focus = game.camera_should_focus;
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(
-(BOARD_SIZE_I as f32 / 2.0),
2.0 * BOARD_SIZE_J as f32 / 3.0,
BOARD_SIZE_J as f32 / 2.0 - 0.5,
)
.looking_at(game.camera_is_focus, Vec3::Y),
..default()
});
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>, mut game: ResMut<Game>) {
// reset the game state
game.cake_eaten = 0;
game.score = 0;
game.player.i = BOARD_SIZE_I / 2;
game.player.j = BOARD_SIZE_J / 2;
game.player.move_cooldown = Timer::from_seconds(0.3, TimerMode::Once);
commands.spawn(PointLightBundle {
transform: Transform::from_xyz(4.0, 10.0, 4.0),
point_light: PointLight {
intensity: 3000.0,
shadows_enabled: true,
range: 30.0,
..default()
},
..default()
});
// spawn the game board
let cell_scene = asset_server.load("models/AlienCake/tile.glb#Scene0");
game.board = (0..BOARD_SIZE_J)
.map(|j| {
(0..BOARD_SIZE_I)
.map(|i| {
let height = rand::thread_rng().gen_range(-0.1..0.1);
commands.spawn(SceneBundle {
transform: Transform::from_xyz(i as f32, height - 0.2, j as f32),
scene: cell_scene.clone(),
..default()
});
Cell { height }
})
.collect()
})
.collect();
// spawn the game character
game.player.entity = Some(
commands
.spawn(SceneBundle {
transform: Transform {
translation: Vec3::new(
game.player.i as f32,
game.board[game.player.j][game.player.i].height,
game.player.j as f32,
),
rotation: Quat::from_rotation_y(-PI / 2.),
..default()
},
scene: asset_server.load("models/AlienCake/alien.glb#Scene0"),
..default()
})
.id(),
);
// load the scene for the cake
game.bonus.handle = asset_server.load("models/AlienCake/cakeBirthday.glb#Scene0");
// scoreboard
commands.spawn(
TextBundle::from_section(
"Score:",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 40.0,
color: Color::rgb(0.5, 0.5, 1.0),
},
)
.with_style(Style {
position_type: PositionType::Absolute,
position: UiRect {
top: Val::Px(5.0),
left: Val::Px(5.0),
..default()
},
..default()
}),
);
}
// remove all entities that are not a camera
fn teardown(mut commands: Commands, entities: Query<Entity, Without<Camera>>) {
for entity in &entities {
commands.entity(entity).despawn();
}
}
// control the game character
fn move_player(
mut commands: Commands,
keyboard_input: Res<Input<KeyCode>>,
mut game: ResMut<Game>,
mut transforms: Query<&mut Transform>,
time: Res<Time>,
) {
if game.player.move_cooldown.tick(time.delta()).finished() {
let mut moved = false;
let mut rotation = 0.0;
if keyboard_input.pressed(KeyCode::Up) {
if game.player.i < BOARD_SIZE_I - 1 {
game.player.i += 1;
}
rotation = -PI / 2.;
moved = true;
}
if keyboard_input.pressed(KeyCode::Down) {
if game.player.i > 0 {
game.player.i -= 1;
}
rotation = PI / 2.;
moved = true;
}
if keyboard_input.pressed(KeyCode::Right) {
if game.player.j < BOARD_SIZE_J - 1 {
game.player.j += 1;
}
rotation = PI;
moved = true;
}
if keyboard_input.pressed(KeyCode::Left) {
if game.player.j > 0 {
game.player.j -= 1;
}
rotation = 0.0;
moved = true;
}
// move on the board
if moved {
game.player.move_cooldown.reset();
*transforms.get_mut(game.player.entity.unwrap()).unwrap() = Transform {
translation: Vec3::new(
game.player.i as f32,
game.board[game.player.j][game.player.i].height,
game.player.j as f32,
),
rotation: Quat::from_rotation_y(rotation),
..default()
};
}
}
// eat the cake!
if let Some(entity) = game.bonus.entity {
if game.player.i == game.bonus.i && game.player.j == game.bonus.j {
game.score += 2;
game.cake_eaten += 1;
commands.entity(entity).despawn_recursive();
game.bonus.entity = None;
}
}
}
// change the focus of the camera
fn focus_camera(
time: Res<Time>,
mut game: ResMut<Game>,
mut transforms: ParamSet<(Query<&mut Transform, With<Camera3d>>, Query<&Transform>)>,
) {
const SPEED: f32 = 2.0;
// if there is both a player and a bonus, target the mid-point of them
if let (Some(player_entity), Some(bonus_entity)) = (game.player.entity, game.bonus.entity) {
let transform_query = transforms.p1();
if let (Ok(player_transform), Ok(bonus_transform)) = (
transform_query.get(player_entity),
transform_query.get(bonus_entity),
) {
game.camera_should_focus = player_transform
.translation
.lerp(bonus_transform.translation, 0.5);
}
// otherwise, if there is only a player, target the player
} else if let Some(player_entity) = game.player.entity {
if let Ok(player_transform) = transforms.p1().get(player_entity) {
game.camera_should_focus = player_transform.translation;
}
// otherwise, target the middle
} else {
game.camera_should_focus = Vec3::from(RESET_FOCUS);
}
// calculate the camera motion based on the difference between where the camera is looking
// and where it should be looking; the greater the distance, the faster the motion;
// smooth out the camera movement using the frame time
let mut camera_motion = game.camera_should_focus - game.camera_is_focus;
if camera_motion.length() > 0.2 {
camera_motion *= SPEED * time.delta_seconds();
// set the new camera's actual focus
game.camera_is_focus += camera_motion;
}
// look at that new camera's actual focus
for mut transform in transforms.p0().iter_mut() {
*transform = transform.looking_at(game.camera_is_focus, Vec3::Y);
}
}
// despawn the bonus if there is one, then spawn a new one at a random location
fn spawn_bonus(
time: Res<Time>,
mut timer: ResMut<BonusSpawnTimer>,
mut next_state: ResMut<NextState<GameState>>,
mut commands: Commands,
mut game: ResMut<Game>,
) {
// make sure we wait enough time before spawning the next cake
if !timer.0.tick(time.delta()).finished() {
return;
}
if let Some(entity) = game.bonus.entity {
game.score -= 3;
commands.entity(entity).despawn_recursive();
game.bonus.entity = None;
if game.score <= -5 {
next_state.set(GameState::GameOver);
return;
}
}
// ensure bonus doesn't spawn on the player
loop {
game.bonus.i = rand::thread_rng().gen_range(0..BOARD_SIZE_I);
game.bonus.j = rand::thread_rng().gen_range(0..BOARD_SIZE_J);
if game.bonus.i != game.player.i || game.bonus.j != game.player.j {
break;
}
}
game.bonus.entity = Some(
commands
.spawn(SceneBundle {
transform: Transform::from_xyz(
game.bonus.i as f32,
game.board[game.bonus.j][game.bonus.i].height + 0.2,
game.bonus.j as f32,
),
scene: game.bonus.handle.clone(),
..default()
})
.with_children(|children| {
children.spawn(PointLightBundle {
point_light: PointLight {
color: Color::rgb(1.0, 1.0, 0.0),
intensity: 1000.0,
range: 10.0,
..default()
},
transform: Transform::from_xyz(0.0, 2.0, 0.0),
..default()
});
})
.id(),
);
}
// let the cake turn on itself
fn rotate_bonus(game: Res<Game>, time: Res<Time>, mut transforms: Query<&mut Transform>) {
if let Some(entity) = game.bonus.entity {
if let Ok(mut cake_transform) = transforms.get_mut(entity) {
cake_transform.rotate_y(time.delta_seconds());
cake_transform.scale =
Vec3::splat(1.0 + (game.score as f32 / 10.0 * time.elapsed_seconds().sin()).abs());
}
}
}
// update the score displayed during the game
fn scoreboard_system(game: Res<Game>, mut query: Query<&mut Text>) {
let mut text = query.single_mut();
text.sections[0].value = format!("Sugar Rush: {}", game.score);
}
// restart the game when pressing spacebar
fn gameover_keyboard(
mut next_state: ResMut<NextState<GameState>>,
keyboard_input: Res<Input<KeyCode>>,
) {
if keyboard_input.just_pressed(KeyCode::Space) {
next_state.set(GameState::Playing);
}
}
// display the number of cake eaten before losing
fn display_score(mut commands: Commands, asset_server: Res<AssetServer>, game: Res<Game>) {
commands
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
..default()
},
..default()
})
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
format!("Cake eaten: {}", game.cake_eaten),
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 80.0,
color: Color::rgb(0.5, 0.5, 1.0),
},
));
});
}
Compiling learn_rust v0.1.0 (/home/archspect/lCode/LearnRust)
Finished dev [optimized + debuginfo] target(s) in 1m 18s
Running `target/debug/learn_rust`
2023-03-29T11:37:43.717459Z INFO bevy_winit::system: Creating new window "Bevy App" (0v0)
2023-03-29T11:37:43.718344Z INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 1
2023-03-29T11:38:01.530559Z INFO bevy_render::renderer: AdapterInfo { name: "Mesa Intel(R) HD Graphics 2000 (SNB GT1)", vendor: 32902, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Gl }
2023-03-29T11:38:02.588862Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux rolling Arch Linux", kernel: "6.2.8-arch1-1", cpu: "Intel(R) Core(TM) i5-2320 CPU @ 3.00GHz", core_count: "4", memory: "7.6 GiB" }
2023-03-29T11:38:02.690195Z ERROR wgpu_hal::gles::egl: GLES: [API/Error] ID 1 : GL_INVALID_OPERATION in unsupported function called (unsupported extension or deprecated function?)
2023-03-29T11:38:02.690321Z ERROR wgpu_hal::gles::egl: GLES: [API/Error] ID 1 : GL_INVALID_OPERATION in unsupported function called (unsupported extension or deprecated function?)
2023-03-29T11:38:02.799516Z WARN bevy_asset::asset_server: encountered an error while reading an asset: path not found: /home/archspect/lCode/LearnRust/assets/fonts/FiraSans-Bold.ttf
2023-03-29T11:38:02.987930Z ERROR wgpu::backend::direct: Shader translation error for stage VERTEX: The selected version doesn't support CUBE_TEXTURES_ARRAY
2023-03-29T11:38:02.987947Z ERROR wgpu::backend::direct: Please report it to https://github.com/gfx-rs/naga
2023-03-29T11:38:02.987967Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'Compute Task Pool (1)' panicked at 'wgpu error: Validation Error
Caused by:
In Device::create_render_pipeline
note: label = `pbr_opaque_mesh_pipeline`
Internal error in VERTEX shader: The selected version doesn't support CUBE_TEXTURES_ARRAY
', /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.15.1/src/backend/direct.rs:3024:5
stack backtrace:
0: rust_begin_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:64:14
2: wgpu::backend::direct::default_error_handler
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.15.1/src/backend/direct.rs:3024:5
3: core::ops::function::Fn::call
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:161:5
4: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/alloc/src/boxed.rs:2032:9
5: wgpu::backend::direct::ErrorSinkRaw::handle_error
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.15.1/src/backend/direct.rs:3010:17
6: wgpu::backend::direct::Context::handle_error
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.15.1/src/backend/direct.rs:296:9
7: <wgpu::backend::direct::Context as wgpu::context::Context>::device_create_render_pipeline
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.15.1/src/backend/direct.rs:1185:13
8: <T as wgpu::context::DynContext>::device_create_render_pipeline
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.15.1/src/context.rs:2191:13
9: wgpu::Device::create_render_pipeline
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.15.1/src/lib.rs:2055:26
10: bevy_render::renderer::render_device::RenderDevice::create_render_pipeline
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.10.0/src/renderer/render_device.rs:105:36
11: bevy_render::render_resource::pipeline_cache::PipelineCache::process_render_pipeline
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.10.0/src/render_resource/pipeline_cache.rs:612:24
12: bevy_render::render_resource::pipeline_cache::PipelineCache::process_queue
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.10.0/src/render_resource/pipeline_cache.rs:683:21
13: bevy_render::render_resource::pipeline_cache::PipelineCache::process_pipeline_queue_system
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.10.0/src/render_resource/pipeline_cache.rs:718:9
14: core::ops::function::FnMut::call_mut
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:337:5
15: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:617:13
16: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0) .> Out>>::run::call_inner
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/system/function_system.rs:629:21
17: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0) .> Out>>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/system/function_system.rs:632:17
18: <bevy_ecs::system::function_system::FunctionSystem<Marker,F> as bevy_ecs::system::system::System>::run_unsafe
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/system/function_system.rs:466:19
19: bevy_ecs::schedule::executor::multi_threaded::MultiThreadedExecutor::spawn_system_task::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/schedule/executor/multi_threaded.rs:448:26
20: core::ops::function::FnOnce::call_once
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:507:5
21: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panic/unwind_safe.rs:271:9
22: std::panicking::try::do_call
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:483:40
23: std::panicking::try
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:447:19
24: std::panic::catch_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panic.rs:137:14
25: bevy_ecs::schedule::executor::multi_threaded::MultiThreadedExecutor::spawn_system_task::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/schedule/executor/multi_threaded.rs:446:23
26: async_executor::Executor::spawn::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.5.0/src/lib.rs:139:19
27: async_task::raw::RawTask<F,T,S,M>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.4.0/src/raw.rs:563:17
28: async_task::runnable::Runnable<M>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.4.0/src/runnable.rs:782:18
29: async_executor::Executor::run::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.5.0/src/lib.rs:230:21
30: <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:529:33
31: async_executor::Executor::run::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.5.0/src/lib.rs:237:31
32: futures_lite::future::block_on::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:89:27
33: std::thread::local::LocalKey<T>::try_with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:446:16
34: std::thread::local::LocalKey<T>::with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:422:9
35: futures_lite::future::block_on
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:79:5
36: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:171:37
37: std::panicking::try::do_call
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:483:40
38: std::panicking::try
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:447:19
39: std::panic::catch_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panic.rs:137:14
40: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:165:43
41: std::thread::local::LocalKey<T>::try_with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:446:16
42: std::thread::local::LocalKey<T>::with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:422:9
43: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:158:25
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'Compute Task Pool (1)' panicked at 'A system has panicked so the executor cannot continue.: RecvError', /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/schedule/executor/multi_threaded.rs:194:60
stack backtrace:
0: rust_begin_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:64:14
2: core::result::unwrap_failed
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/result.rs:1791:5
3: core::result::Result<T,E>::expect
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/result.rs:1070:23
4: <bevy_ecs::schedule::executor::multi_threaded::MultiThreadedExecutor as bevy_ecs::schedule::executor::SystemExecutor>::run::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/schedule/executor/multi_threaded.rs:194:33
5: async_executor::Executor::spawn::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.5.0/src/lib.rs:139:19
6: async_task::raw::RawTask<F,T,S,M>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.4.0/src/raw.rs:563:17
7: async_task::runnable::Runnable<M>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.4.0/src/runnable.rs:782:18
8: async_executor::Executor::run::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.5.0/src/lib.rs:230:21
9: <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:529:33
10: async_executor::Executor::run::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.5.0/src/lib.rs:237:31
11: futures_lite::future::block_on::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:89:27
12: std::thread::local::LocalKey<T>::try_with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:446:16
13: std::thread::local::LocalKey<T>::with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:422:9
14: futures_lite::future::block_on
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:79:5
15: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:171:37
16: std::panicking::try::do_call
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:483:40
17: std::panicking::try
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:447:19
18: std::panic::catch_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panic.rs:137:14
19: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:165:43
20: std::thread::local::LocalKey<T>::try_with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:446:16
21: std::thread::local::LocalKey<T>::with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:422:9
22: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:158:25
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:376:49
stack backtrace:
0: rust_begin_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:64:14
2: core::panicking::panic
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:111:5
3: core::option::Option<T>::unwrap
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/option.rs:778:21
4: bevy_tasks::task_pool::TaskPool::scope_with_executor_inner::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:376:38
5: <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:529:33
6: bevy_tasks::task_pool::TaskPool::execute_scope::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:500:40
7: bevy_tasks::task_pool::TaskPool::scope_with_executor_inner::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:411:84
8: futures_lite::future::block_on::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:89:27
9: std::thread::local::LocalKey<T>::try_with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:446:16
10: std::thread::local::LocalKey<T>::with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:422:9
11: futures_lite::future::block_on
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:79:5
12: bevy_tasks::task_pool::TaskPool::scope_with_executor_inner
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:372:13
13: bevy_tasks::task_pool::TaskPool::scope_with_executor::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:311:17
14: std::thread::local::LocalKey<T>::try_with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:446:16
15: std::thread::local::LocalKey<T>::with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:422:9
16: bevy_tasks::task_pool::TaskPool::scope_with_executor
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:307:9
17: <bevy_ecs::schedule::executor::multi_threaded::MultiThreadedExecutor as bevy_ecs::schedule::executor::SystemExecutor>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/schedule/executor/multi_threaded.rs:178:9
18: bevy_ecs::world::World::run_schedule_ref
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/world/mod.rs:1748:9
19: bevy_ecs::world::World::run_schedule
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/world/mod.rs:1724:9
20: bevy_app::app::App::add_simple_outer_schedule::run_main_schedule
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.10.0/src/app.rs:549:13
21: core::ops::function::FnMut::call_mut
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:337:5
22: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:617:13
23: <Func as bevy_ecs::system::exclusive_function_system::ExclusiveSystemParamFunction<fn() .> Out>>::run::call_inner
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/system/exclusive_function_system.rs:205:21
24: <Func as bevy_ecs::system::exclusive_function_system::ExclusiveSystemParamFunction<fn() .> Out>>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/system/exclusive_function_system.rs:208:17
25: <bevy_ecs::system::exclusive_function_system::ExclusiveFunctionSystem<Marker,F> as bevy_ecs::system::system::System>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/system/exclusive_function_system.rs:104:19
26: <bevy_ecs::schedule::executor::single_threaded::SingleThreadedExecutor as bevy_ecs::schedule::executor::SystemExecutor>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/schedule/executor/single_threaded.rs:98:17
27: bevy_ecs::world::World::run_schedule_ref
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/world/mod.rs:1748:9
28: bevy_app::app::SubApp::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.10.0/src/app.rs:167:9
29: <bevy_render::pipelined_rendering::PipelinedRenderingPlugin as bevy_app::plugin::Plugin>::setup::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.10.0/src/pipelined_rendering.rs:119:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'Compute Task Pool (1)' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.10.0/src/pipelined_rendering.rs:136:45
stack backtrace:
0: rust_begin_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:64:14
2: core::result::unwrap_failed
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/result.rs:1791:5
3: core::result::Result<T,E>::unwrap
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/result.rs:1113:23
4: bevy_render::pipelined_rendering::update_rendering::{{closure}}::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.10.0/src/pipelined_rendering.rs:136:21
5: async_executor::Executor::spawn::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.5.0/src/lib.rs:139:19
6: async_task::raw::RawTask<F,T,S,M>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.4.0/src/raw.rs:563:17
7: async_task::runnable::Runnable<M>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.4.0/src/runnable.rs:782:18
8: async_executor::Executor::run::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.5.0/src/lib.rs:230:21
9: <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:529:33
10: async_executor::Executor::run::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.5.0/src/lib.rs:237:31
11: futures_lite::future::block_on::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:89:27
12: std::thread::local::LocalKey<T>::try_with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:446:16
13: std::thread::local::LocalKey<T>::with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:422:9
14: futures_lite::future::block_on
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:79:5
15: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:171:37
16: std::panicking::try::do_call
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:483:40
17: std::panicking::try
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:447:19
18: std::panic::catch_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panic.rs:137:14
19: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:165:43
20: std::thread::local::LocalKey<T>::try_with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:446:16
21: std::thread::local::LocalKey<T>::with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:422:9
22: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:158:25
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:376:49
stack backtrace:
0: rust_begin_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:64:14
2: core::panicking::panic
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:111:5
3: core::option::Option<T>::unwrap
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/option.rs:778:21
4: bevy_tasks::task_pool::TaskPool::scope_with_executor_inner::{{closure}}::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:376:38
5: <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:529:33
6: bevy_tasks::task_pool::TaskPool::execute_global_scope::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:482:40
7: bevy_tasks::task_pool::TaskPool::scope_with_executor_inner::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:409:88
8: futures_lite::future::block_on::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:89:27
9: std::thread::local::LocalKey<T>::try_with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:446:16
10: std::thread::local::LocalKey<T>::with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:422:9
11: futures_lite::future::block_on
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:79:5
12: bevy_tasks::task_pool::TaskPool::scope_with_executor_inner
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:372:13
13: bevy_tasks::task_pool::TaskPool::scope_with_executor::{{closure}}
14: std::thread::local::LocalKey<T>::try_with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:446:16
15: std::thread::local::LocalKey<T>::with
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/thread/local.rs:422:9
16: bevy_tasks::task_pool::TaskPool::scope_with_executor
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:307:9
17: bevy_render::pipelined_rendering::update_rendering::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.10.0/src/pipelined_rendering.rs:132:30
18: bevy_ecs::world::World::resource_scope
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/world/mod.rs:1313:22
19: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/alloc/src/boxed.rs:2032:9
20: bevy_app::app::SubApp::extract
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.10.0/src/app.rs:175:9
21: bevy_app::app::App::update
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.10.0/src/app.rs:256:13
22: bevy_winit::winit_runner::{{closure}}
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_winit-0.10.0/src/lib.rs:643:21
23: winit::platform_impl::platform::sticky_exit_callback
24: winit::platform_impl::platform::x11::EventLoop<T>::run_return::single_iteration
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.3/src/platform_impl/linux/x11/mod.rs:358:17
25: winit::platform_impl::platform::x11::EventLoop<T>::run_return
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.3/src/platform_impl/linux/x11/mod.rs:483:27
26: winit::platform_impl::platform::x11::EventLoop<T>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.3/src/platform_impl/linux/x11/mod.rs:498:25
27: winit::platform_impl::platform::EventLoop<T>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.3/src/platform_impl/linux/mod.rs:792:56
28: winit::event_loop::EventLoop<T>::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.3/src/event_loop.rs:305:9
29: bevy_winit::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_winit-0.10.0/src/lib.rs:171:5
30: bevy_winit::winit_runner
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_winit-0.10.0/src/lib.rs:731:9
31: core::ops::function::Fn::call
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:161:5
32: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/alloc/src/boxed.rs:2032:9
33: bevy_app::app::App::run
at /home/archspect/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.10.0/src/app.rs:301:9
34: learn_rust::main
at ./src/main.rs:81:5
35: core::ops::function::FnOnce::call_once
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
* The terminal process "cargo 'run', '--package', 'learn_rust', '--bin', 'learn_rust'" terminated with exit code: 101.
* Terminal will be reused by tasks, press any key to close it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment