Skip to content

Commit

Permalink
for reproduction
Browse files Browse the repository at this point in the history
  • Loading branch information
malezjaa committed Nov 11, 2024
1 parent 10e9407 commit e033012
Show file tree
Hide file tree
Showing 8 changed files with 2,164 additions and 552 deletions.
2,438 changes: 2,026 additions & 412 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
bevy = "0.14.2"
bevy = "0.15.0-rc.3"
bevy_rapier2d = "0.27.0"

[profile.dev]
Expand Down
Binary file added assets/cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions rustc-ice-2024-11-11T21_20_32-29384.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
thread 'rustc' panicked at compiler\rustc_trait_selection\src\error_reporting\traits\fulfillment_errors.rs:1820:44:
called `Option::unwrap()` on a `None` value
stack backtrace:
0: 0x7ffba4044fb3 - std::backtrace_rs::backtrace::dbghelp64::trace
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
1: 0x7ffba4044fb3 - std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\..\..\backtrace\src\backtrace\mod.rs:66
2: 0x7ffba4044fb3 - std::backtrace::Backtrace::create
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\backtrace.rs:331
3: 0x7ffba4044efa - std::backtrace::Backtrace::force_capture
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\backtrace.rs:312
4: 0x7ffba568805b - memchr
5: 0x7ffba405fc62 - alloc::boxed::impl$30::call
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/alloc\src\boxed.rs:1981
6: 0x7ffba405fc62 - std::panicking::rust_panic_with_hook
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\panicking.rs:809
7: 0x7ffba405fa72 - std::panicking::begin_panic_handler::closure$0
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\panicking.rs:667
8: 0x7ffba405d2af - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\sys\backtrace.rs:170
9: 0x7ffba405f6ae - std::panicking::begin_panic_handler
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\panicking.rs:665
10: 0x7ffba7093af1 - core::panicking::panic_fmt
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/core\src\panicking.rs:76
11: 0x7ffba7093bad - core::panicking::panic
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/core\src\panicking.rs:148
12: 0x7ffba7093a6e - core::option::unwrap_failed
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/core\src\option.rs:2008
13: 0x7ffba68fcc04 - <rustc_trait_selection[3dbf94cb46f90712]::error_reporting::TypeErrCtxt>::fuzzy_match_tys
14: 0x7ffba6989ecd - <rustc_trait_selection[3dbf94cb46f90712]::error_reporting::traits::on_unimplemented::WrappedParserError as rustc_errors[9c488d6ae8e44ce4]::diagnostic::LintDiagnostic<()>>::decorate_lint
15: 0x7ffba694d182 - <rustc_trait_selection[3dbf94cb46f90712]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
16: 0x7ffba42cb973 - rustc_hir_typeck[a5ddaf2af851908c]::typeck
17: 0x7ffba4e1accb - rustc_query_impl[1314cfb4603ed7b]::plumbing::query_key_hash_verify_all
18: 0x7ffba4d66d0a - rustc_ty_utils[c2708c13bfdf2f5f]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
19: 0x7ffba4e23264 - rustc_query_impl[1314cfb4603ed7b]::plumbing::query_key_hash_verify_all
20: 0x7ffba4340272 - <rustc_hir_typeck[a5ddaf2af851908c]::upvar::InferBorrowKind as rustc_hir_typeck[a5ddaf2af851908c]::expr_use_visitor::Delegate>::borrow
21: 0x7ffba43bb399 - rustc_hir_analysis[4b8241ff32ff1736]::check_crate
22: 0x7ffba40d1991 - rustc_interface[a39b52d048a80b08]::passes::resolver_for_lowering_raw
23: 0x7ffba10a480e - rustc_interface[a39b52d048a80b08]::passes::analysis
24: 0x7ffba3c53f5b - rustc_ty_utils[c2708c13bfdf2f5f]::ty::adt_sized_constraint
25: 0x7ffba3b6bcd7 - rustc_ty_utils[c2708c13bfdf2f5f]::ty::adt_sized_constraint
26: 0x7ffba3c59893 - rustc_query_impl[1314cfb4603ed7b]::query_system
27: 0x7ffba10634c7 - _rust_alloc_error_handler
28: 0x7ffba105f19f - _rust_alloc_error_handler
29: 0x7ffba10690a7 - _rust_alloc_error_handler
30: 0x7ffba407173d - alloc::boxed::impl$28::call_once
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/alloc\src\boxed.rs:1967
31: 0x7ffba407173d - alloc::boxed::impl$28::call_once
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/alloc\src\boxed.rs:1967
32: 0x7ffba407173d - std::sys::pal::windows::thread::impl$0::new::thread_start
at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\sys\pal\windows\thread.rs:55
33: 0x7ffcafe5257d - BaseThreadInitThunk
34: 0x7ffcb176af08 - RtlUserThreadStart


rustc version: 1.84.0-nightly (143ce0920 2024-11-10)
platform: x86_64-pc-windows-msvc

query stack during panic:
#0 [typeck] type-checking `cursor::setup_cursor`
#1 [analysis] running analysis passes on this crate
end of query stack
9 changes: 9 additions & 0 deletions src/cursor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use bevy::prelude::*;
use bevy::winit::cursor::CustomCursor;

pub fn setup_cursor(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.insert_resource(CustomCursor::Image {
handle: asset_server.load("cursor.png"),
hotspot: (128, 128),
}.into());
}
39 changes: 23 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,35 @@ pub mod player;
pub mod menu;
mod screen;
mod text;
mod cursor;

use bevy::prelude::*;
use bevy_rapier2d::prelude::*;
use crate::menu::{menu_plugin, setup_menu, GameState};
use crate::menu::{menu_plugin, setup_camera, GameState};
use bevy::window::{CursorMoved, WindowTheme};
use bevy::winit::cursor::{CursorIcon, CustomCursor};
use crate::cursor::setup_cursor;

pub const GAME_TITLE: &str = "Chronos Game";

fn main() {
App::new()
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.insert_resource(RapierConfiguration {
gravity: Vec2::new(0.0, -2000.0),
physics_pipeline_active: true,
query_pipeline_active: true,
timestep_mode: TimestepMode::Variable {
max_dt: 1.0 / 60.0,
time_scale: 1.0,
substeps: 1,
},
scaled_shape_subdivision: 10,
force_update_from_transform_changes: false,
})
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()).set(
WindowPlugin {
primary_window: Some(Window {
title: GAME_TITLE.into(),
window_theme: Some(WindowTheme::Dark),
enabled_buttons: bevy::window::EnabledButtons {
maximize: false,
..Default::default()
},
..default()
}),
..default()
}
))
.init_state::<GameState>()
.add_systems(Startup, setup_menu)
.add_plugins((menu_plugin))
.add_systems(Startup, (setup_camera, setup_cursor))
.add_plugins(menu_plugin)
.run();
}
152 changes: 37 additions & 115 deletions src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub enum GameState {
Game,
}

pub fn setup_menu(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
pub fn setup_camera(mut commands: Commands) {
commands.spawn(Camera2d::default());
}


Expand All @@ -21,7 +21,6 @@ pub fn menu_plugin(app: &mut App) {
.add_systems(OnEnter(GameState::Menu), menu_setup)
.add_systems(OnEnter(MenuState::Main), main_menu_setup)
.add_systems(OnExit(MenuState::Main), despawn_screen::<OnMainMenuScreen>)
.add_systems(OnEnter(MenuState::Settings), settings_menu_setup)
.add_systems(
OnExit(MenuState::Settings),
despawn_screen::<OnSettingsMenuScreen>,
Expand Down Expand Up @@ -111,85 +110,75 @@ fn menu_setup(mut menu_state: ResMut<NextState<MenuState>>) {
}

fn main_menu_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let button_icon_style = Style {
let button_icon_style = Node {
width: Val::Px(30.0),
position_type: PositionType::Absolute,
left: Val::Px(10.0),
..default()
};

let button_text_style = TextStyle {
let button_text_style = TextFont {
font_size: 40.0,
color: TEXT_COLOR,
..default()
};

commands
.spawn((
NodeBundle {
style: Style {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
..default()
},

background_color: Srgba::new(51.0, 51.0, 60.0, 0.0).into(),
Node {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
..default()
},
BackgroundColor(Srgba::new(51.0, 51.0, 60.0, 0.0).into()),
OnMainMenuScreen,
))
.with_children(|parent| {
parent
.spawn(ImageBundle {
style: Style {
width: Val::Percent(50.0),
height: Val::Percent(50.0),
justify_content: JustifyContent::Center,
flex_direction: FlexDirection::Column,
display: Display::Flex,
align_items: AlignItems::Center,
..default()
},
image: UiImage::new(
asset_server.load("blank.png"),
),
.spawn((UiImage {
image: asset_server.load("blank.png"),
..default()
})
}, Node {
width: Val::Percent(50.0),
height: Val::Percent(50.0),
justify_content: JustifyContent::Center,
flex_direction: FlexDirection::Column,
display: Display::Flex,
align_items: AlignItems::Center,
..default()
}))
.with_children(|parent| {
parent.spawn(
text_bundle("Main Menu", &asset_server, TextStyle {
text_bundle("Main Menu", &asset_server, (TextFont {
font_size: 65.0,
..default()
})
.with_style(Style {
margin: UiRect::all(Val::Px(60.0)),
}, Node {
margin: UiRect {
bottom: Val::Px(20.0),
..default()
}),
},
..default()
}))
);

parent.spawn(
(ButtonBundle {
style: Style {
width: Val::Px(200.0),
height: Val::Px(65.0),
margin: UiRect::all(Val::Px(20.0)),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..default()
},
(Button {}, Node {
width: Val::Px(200.0),
height: Val::Px(65.0),
margin: UiRect::all(Val::Px(20.0)),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..default()
},
MenuButtonAction::Play
)
).with_children(|parent| {
let icon = asset_server.load("textures/Game Icons/right.png");
parent.spawn(ImageBundle {
style: button_icon_style.clone(),
image: UiImage::new(icon),
parent.spawn((UiImage {
image: icon,
..default()
});
}, button_icon_style));
parent.spawn(
text_bundle("Play", &asset_server, button_text_style.clone())
);
Expand All @@ -198,73 +187,6 @@ fn main_menu_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
});
}

fn settings_menu_setup(mut commands: Commands) {
let button_style = Style {
width: Val::Px(200.0),
height: Val::Px(65.0),
margin: UiRect::all(Val::Px(20.0)),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..default()
};

let button_text_style = TextStyle {
font_size: 40.0,
color: TEXT_COLOR,
..default()
};

commands
.spawn((
NodeBundle {
style: Style {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
..default()
},
..default()
},
OnSettingsMenuScreen,
))
.with_children(|parent| {
parent
.spawn(NodeBundle {
style: Style {
flex_direction: FlexDirection::Column,
align_items: AlignItems::Center,
..default()
},
background_color: CRIMSON.into(),
..default()
})
.with_children(|parent| {
for (action, text) in [
(MenuButtonAction::SettingsDisplay, "Display"),
(MenuButtonAction::SettingsSound, "Sound"),
(MenuButtonAction::BackToMainMenu, "Back"),
] {
parent
.spawn((
ButtonBundle {
style: button_style.clone(),
background_color: NORMAL_BUTTON.into(),
..default()
},
action,
))
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
text,
button_text_style.clone(),
));
});
}
});
});
}

fn menu_action(
interaction_query: Query<
(&Interaction, &MenuButtonAction),
Expand Down
14 changes: 6 additions & 8 deletions src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ use bevy::prelude::*;

pub const TEXT_COLOR: Color = Color::srgb(0.0, 0.0, 0.0);

pub fn text_bundle(text: impl Into<String>, asset_server: &Res<AssetServer>, style: TextStyle) -> TextBundle {
TextBundle::from_section(
pub fn text_bundle(text: impl Into<String>, asset_server: &Res<AssetServer>, style: impl Bundle) -> impl Bundle {
(Text::new(
text,
TextStyle {
color: TEXT_COLOR,
font: asset_server.load("fonts/main-font.ttf"),
..style
},
)
), style, TextFont {
font: asset_server.load("fonts/Roboto-Regular.ttf"),
..default()
})
}

0 comments on commit e033012

Please sign in to comment.