Fix crudely for bevy 0.13
This commit is contained in:
1802
Cargo.lock
generated
1802
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -7,12 +7,12 @@ edition = "2021"
|
||||
itertools = "0.12.1"
|
||||
rand = "0.8.5"
|
||||
bevy_editor_pls = { git = "https://github.com/jakobhellermann/bevy_editor_pls" }
|
||||
bevy_tweening = "0.9.0"
|
||||
leafwing-input-manager = "0.11.2"
|
||||
bevy_asset_loader = "0.19.0"
|
||||
bevy_tweening = "0.10.0"
|
||||
leafwing-input-manager = "0.13.3"
|
||||
bevy_asset_loader = "0.20.0"
|
||||
|
||||
[dependencies.bevy]
|
||||
version = "0.12"
|
||||
version = "0.13"
|
||||
features = ["wayland", "wav"]
|
||||
|
||||
# [profile.dev.package."*"]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
struct FragmentInput {
|
||||
@builtin(position) fragment_coordinate: vec4<f32>,
|
||||
@location(0) world_position: vec4<f32>,
|
||||
@location(1) world_normal: vec3<f32>,
|
||||
@location(2) uv: vec2<f32>,
|
||||
};
|
||||
#import bevy_sprite::mesh2d_vertex_output::VertexOutput
|
||||
|
||||
struct TileLight {
|
||||
color: vec4<f32>,
|
||||
@@ -18,11 +13,11 @@ struct CanvasMaterial {
|
||||
};
|
||||
|
||||
|
||||
@group(1) @binding(0)
|
||||
@group(2) @binding(0)
|
||||
var<uniform> canvas_material: CanvasMaterial;
|
||||
|
||||
@fragment
|
||||
fn fragment(input: FragmentInput) -> @location(0) vec4<f32> {
|
||||
fn fragment(input: VertexOutput) -> @location(0) vec4<f32> {
|
||||
var output_color = canvas_material.ambient_color;
|
||||
|
||||
var lighting = vec4<f32>();
|
||||
|
||||
@@ -3,7 +3,7 @@ mod tile_light;
|
||||
use crate::grid;
|
||||
use bevy::{
|
||||
prelude::*,
|
||||
reflect::{TypePath, TypeUuid},
|
||||
reflect::TypePath,
|
||||
render::{
|
||||
render_resource::{encase, AsBindGroup, OwnedBindingResource, ShaderRef, ShaderType},
|
||||
renderer::RenderQueue,
|
||||
@@ -30,8 +30,7 @@ impl Plugin for CanvasPlugin {
|
||||
|
||||
const CANVAS_COLOR: Color = Color::rgb(0.05, 0.05, 0.05);
|
||||
|
||||
#[derive(AsBindGroup, TypeUuid, TypePath, Asset, Clone)]
|
||||
#[uuid = "24f83f6e-e52d-41a6-bf1d-0e46e57a4995"]
|
||||
#[derive(AsBindGroup, TypePath, Asset, Clone)]
|
||||
struct CanvasMaterial {
|
||||
#[uniform(0)]
|
||||
ambient_color: Color,
|
||||
@@ -98,7 +97,7 @@ fn spawn_canvas(
|
||||
) {
|
||||
commands
|
||||
.spawn(MaterialMesh2dBundle {
|
||||
mesh: mesh_assets.add(Mesh::from(shape::Quad::default())).into(),
|
||||
mesh: mesh_assets.add(Mesh::from(Rectangle::default())).into(),
|
||||
material: canvas_material_assets.add(CanvasMaterial::default()),
|
||||
transform: Transform::from_scale(Vec3::splat(
|
||||
grid::SEGMENT_SIZE * f32::from(grid::SIZE),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use bevy::{
|
||||
math::Vec3Swizzles,
|
||||
prelude::*,
|
||||
render::{render_resource::ShaderType, Extract},
|
||||
};
|
||||
|
||||
@@ -89,7 +89,7 @@ fn main() {
|
||||
..Default::default()
|
||||
}))
|
||||
.init_collection::<audio::Assets>()
|
||||
.add_state::<AppState>()
|
||||
.init_state::<AppState>()
|
||||
.add_plugins((
|
||||
TweeningPlugin,
|
||||
SnakePlugin,
|
||||
@@ -132,8 +132,8 @@ fn update_score_system(mut score: ResMut<Score>, mut eaten_event: EventReader<fr
|
||||
score.0 += eaten_event.read().count() as u32;
|
||||
}
|
||||
|
||||
fn pause_system(keypress: Res<Input<KeyCode>>, mut time: ResMut<Time<Virtual>>) {
|
||||
if keypress.just_pressed(KeyCode::P) {
|
||||
fn pause_system(keypress: Res<ButtonInput<KeyCode>>, mut time: ResMut<Time<Virtual>>) {
|
||||
if keypress.just_pressed(KeyCode::KeyP) {
|
||||
if time.is_paused() {
|
||||
time.unpause()
|
||||
} else {
|
||||
|
||||
16
src/snake.rs
16
src/snake.rs
@@ -161,10 +161,10 @@ fn setup_snake_system(mut commands: Commands) {
|
||||
.insert(Name::new("Snake"))
|
||||
.insert(InputManagerBundle::<Direction> {
|
||||
input_map: InputMap::new([
|
||||
(KeyCode::Up, Direction::Up),
|
||||
(KeyCode::Down, Direction::Down),
|
||||
(KeyCode::Left, Direction::Left),
|
||||
(KeyCode::Right, Direction::Right),
|
||||
(Direction::Up, KeyCode::ArrowUp),
|
||||
(Direction::Down, KeyCode::ArrowDown),
|
||||
(Direction::Left, KeyCode::ArrowLeft),
|
||||
(Direction::Right, KeyCode::ArrowRight),
|
||||
]),
|
||||
..Default::default()
|
||||
})
|
||||
@@ -175,9 +175,9 @@ fn eaten_event_system(
|
||||
mut eaten_event_reader: EventReader<fruit::EatenEvent>,
|
||||
mut tail_event_writer: EventWriter<AddTailEvent>,
|
||||
) {
|
||||
eaten_event_reader
|
||||
.read()
|
||||
.for_each(|_| tail_event_writer.send(AddTailEvent));
|
||||
eaten_event_reader.read().for_each(|_| {
|
||||
tail_event_writer.send(AddTailEvent);
|
||||
});
|
||||
}
|
||||
|
||||
fn add_tail_system(
|
||||
@@ -302,7 +302,7 @@ mod debug {
|
||||
use super::*;
|
||||
|
||||
pub(super) fn add_tail(
|
||||
keypress: Res<Input<KeyCode>>,
|
||||
keypress: Res<ButtonInput<KeyCode>>,
|
||||
mut tail_event_writer: EventWriter<AddTailEvent>,
|
||||
) {
|
||||
if keypress.just_pressed(KeyCode::Space) {
|
||||
|
||||
Reference in New Issue
Block a user