Skip to content

Commit dead723

Browse files
committed
update to bevy v0.4
1 parent fc7705b commit dead723

File tree

14 files changed

+98
-60
lines changed

14 files changed

+98
-60
lines changed

.metals/metals.h2.db

5.12 MB
Binary file not shown.

.metals/metals.lock.db

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#FileLock
2+
#Wed Dec 09 10:00:35 CST 2020
3+
server=localhost\:53584
4+
hostName=localhost
5+
method=file
6+
id=176453a93b562371c6ea9ed823f9dd1a1367ea514b3

.metals/metals.log

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2020.12.09 10:00:31 INFO Started: Metals version 0.9.7 in workspace 'C:\Project\github\bevy-tetris' for client vscode.
2+
2020.12.09 10:00:34 INFO time: initialize in 2.82s
3+
2020.12.09 10:00:35 WARN Build server is not auto-connectable.
4+
2020.12.09 10:00:35 WARN no build tool detected in workspace 'C:\Project\github\bevy-tetris'. The most common cause for this problem is that the editor was opened in the wrong working directory, for example if you use sbt then the workspace directory should contain build.sbt.

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"files.watcherExclude": {
3+
"**/target": true
4+
}
5+
}

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ version = "0.1.0"
1010
#complie sucess with
1111
#bevy = "0.3.0"
1212

13-
bevy = "0.3"
13+
bevy = "0.4"
1414
lazy_static = "1.4"
1515
rand = "0.7"
1616

example/step1.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
//we compile as windows app instead of console app
22
#![windows_subsystem = "windows"]
33
use bevy::prelude::*;
4-
fn main(){
4+
fn main() {
55
App::build()
6-
//we initial windows size here:
7-
.add_resource(WindowDescriptor {
8-
title: "Tetris".to_string(),width: 360,height: 443,..Default::default()})
9-
.add_startup_system(setup.system())
10-
.add_plugins(DefaultPlugins)
11-
.run();
6+
//we initial windows size here:
7+
.add_resource(WindowDescriptor {
8+
title: "Tetris".to_string(),
9+
width: 360.0,
10+
height: 443.0,
11+
..Default::default()
12+
})
13+
.add_startup_system(setup.system())
14+
.add_plugins(DefaultPlugins)
15+
.run();
1216
}
13-
fn setup(mut commands: Commands,
17+
fn setup(
18+
commands: &mut Commands,
1419
asset_server: Res<AssetServer>,
15-
mut materials: ResMut<Assets<ColorMaterial>>) {
20+
mut materials: ResMut<Assets<ColorMaterial>>,
21+
) {
1622
let start_handle = asset_server.load("screen.png");
17-
commands.spawn(Camera2dComponents::default())
18-
.spawn(SpriteComponents {
23+
commands
24+
.spawn(Camera2dBundle::default())
25+
.spawn(SpriteBundle {
1926
material: materials.add(start_handle.into()),
2027
..Default::default()
2128
});

example/step2.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,35 @@ fn main() {
66
//we initial windows size here:
77
.add_resource(WindowDescriptor {
88
title: "Tetris".to_string(),
9-
width: 360,
10-
height: 443,
9+
width: 360.0,
10+
height: 443.0,
1111
..Default::default()
1212
})
1313
.add_startup_system(setup.system())
1414
.add_plugins(DefaultPlugins)
1515
.run();
1616
}
1717
fn setup(
18-
mut commands: Commands,
18+
commands: &mut Commands,
1919
asset_server: Res<AssetServer>,
2020
mut materials: ResMut<Assets<ColorMaterial>>,
2121
) {
2222
let start_handle = asset_server.load("screen.png");
2323

2424
commands
25-
.spawn(Camera2dComponents::default())
26-
.spawn(SpriteComponents {
25+
.spawn(Camera2dBundle::default())
26+
.spawn(SpriteBundle {
2727
material: materials.add(start_handle.into()),
2828
..Default::default()
2929
});
30-
commands.spawn(UiCameraComponents::default());
30+
commands.spawn(CameraUiBundle::default());
3131
spwan_board_dot(commands, materials);
3232
}
33-
fn spwan_board_dot(mut commands: Commands, mut materials: ResMut<Assets<ColorMaterial>>) {
33+
fn spwan_board_dot(commands: &mut Commands, mut materials: ResMut<Assets<ColorMaterial>>) {
3434
let black = materials.add(Color::rgb_u8(0, 0, 0).into());
3535
let background = materials.add(Color::rgb_u8(158, 173, 135).into());
3636
commands
37-
.spawn(NodeComponents {
37+
.spawn(NodeBundle {
3838
style: Style {
3939
position_type: PositionType::Absolute,
4040
position: Rect {
@@ -57,7 +57,7 @@ fn spwan_child_dot(
5757
background: Handle<ColorMaterial>,
5858
) {
5959
commands
60-
.spawn(NodeComponents {
60+
.spawn(NodeBundle {
6161
material: black.clone(),
6262
style: Style {
6363
size: Size::new(Val::Px(20.0), Val::Px(20.0)),
@@ -74,7 +74,7 @@ fn spwan_child_dot(
7474
})
7575
.with_children(|parent| {
7676
parent
77-
.spawn(NodeComponents {
77+
.spawn(NodeBundle {
7878
material: background,
7979
style: Style {
8080
size: Size::new(Val::Px(16.0), Val::Px(16.0)),
@@ -88,7 +88,7 @@ fn spwan_child_dot(
8888
..Default::default()
8989
})
9090
.with_children(|parent| {
91-
parent.spawn(NodeComponents {
91+
parent.spawn(NodeBundle {
9292
material: black,
9393
style: Style {
9494
size: Size::new(Val::Px(12.0), Val::Px(12.0)),

example/step3.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@ fn main() {
99
//we initial windows size here:
1010
.add_resource(WindowDescriptor {
1111
title: "Tetris".to_string(),
12-
width: 360,
13-
height: 443,
12+
width: 360.0,
13+
height: 443.0,
1414
..Default::default()
1515
})
1616
.add_startup_system(setup.system())
1717
.add_plugins(DefaultPlugins)
1818
.run();
1919
}
2020
fn setup(
21-
mut commands: Commands,
21+
mut commands: &mut Commands,
2222
asset_server: Res<AssetServer>,
2323
mut materials: ResMut<Assets<ColorMaterial>>,
2424
) {
2525
let start_handle = asset_server.load("screen.png");
2626

2727
commands
28-
.spawn(Camera2dComponents::default())
29-
.spawn(SpriteComponents {
28+
.spawn(Camera2dBundle::default())
29+
.spawn(SpriteBundle {
3030
material: materials.add(start_handle.into()),
3131
..Default::default()
3232
});
33-
commands.spawn(UiCameraComponents::default());
33+
commands.spawn(CameraUiBundle::default());
3434

3535
let black = materials.add(Color::rgb_u8(0, 0, 0).into());
3636
let background = materials.add(Color::rgb_u8(158, 173, 135).into());
@@ -50,7 +50,7 @@ fn spwan_brick_at(
5050
y: f32,
5151
) {
5252
commands
53-
.spawn(NodeComponents {
53+
.spawn(NodeBundle {
5454
style: Style {
5555
position_type: PositionType::Absolute,
5656
position: Rect {
@@ -76,7 +76,7 @@ fn spwan_child_dot(
7676
dot: &Dot,
7777
) {
7878
commands
79-
.spawn(NodeComponents {
79+
.spawn(NodeBundle {
8080
material: black.clone(),
8181
style: Style {
8282
size: Size::new(Val::Px(20.0), Val::Px(20.0)),
@@ -93,7 +93,7 @@ fn spwan_child_dot(
9393
})
9494
.with_children(|parent| {
9595
parent
96-
.spawn(NodeComponents {
96+
.spawn(NodeBundle {
9797
material: background,
9898
style: Style {
9999
size: Size::new(Val::Px(16.0), Val::Px(16.0)),
@@ -107,7 +107,7 @@ fn spwan_child_dot(
107107
..Default::default()
108108
})
109109
.with_children(|parent| {
110-
parent.spawn(NodeComponents {
110+
parent.spawn(NodeBundle {
111111
material: black,
112112
style: Style {
113113
size: Size::new(Val::Px(12.0), Val::Px(12.0)),

src/consts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
use crate::bricks::{Brick, Dot};
33
use lazy_static::*;
44

5-
pub(crate) const WINDOWS_WIDTH: u32 = 360;
6-
pub(crate) const WINDOWS_HEIGHT: u32 = 443;
5+
pub(crate) const WINDOWS_WIDTH: f32 = 360.0;
6+
pub(crate) const WINDOWS_HEIGHT: f32 = 443.0;
77

88
pub(crate) const TEXT_SCORE_X: f32 = 248.0;
99
pub(crate) const TEXT_SCORE_Y: f32 = 48.0;
@@ -37,7 +37,7 @@ pub(crate) const BRICKS_TYPES: usize = 7;
3737
pub(crate) const SCORE_PER_DROP: u32 = 10;
3838

3939
pub(crate) const STRING_GAME_START: &str = "PRESS SPACE";
40-
pub(crate) const STRING_GAME_PLAYING: &str = "";
40+
pub(crate) const STRING_GAME_PLAYING: &str = " ";
4141
pub(crate) const STRING_GAME_OVER: &str = " GAME OVER \n\nPRESS SPACE";
4242

4343
//delay = 725 * .85 ^ level + level (ms)

src/inputs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ fn handle_keyboard(
4242
board: Res<Board>,
4343
bricks: Query<(&BrickShape, &Dot)>,
4444
) {
45-
keyboard_timer.0.tick(time.delta_seconds);
46-
falling_timer.0.tick(time.delta_seconds);
45+
keyboard_timer.0.tick(time.delta_seconds());
46+
falling_timer.0.tick(time.delta_seconds());
4747

4848
movement.0 = Movements::None;
4949
let mut falling_dot = Dot(0, 0);
@@ -72,7 +72,7 @@ fn handle_keyboard(
7272
}
7373
}
7474
}
75-
if falling_timer.0.finished {
75+
if falling_timer.0.finished() {
7676
for (brick_shape, dot) in &mut bricks.iter() {
7777
let next_position = dot.down();
7878
//BUG: initial brick out of Y
@@ -85,7 +85,7 @@ fn handle_keyboard(
8585
}
8686
}
8787
}
88-
if keyboard_timer.0.finished {
88+
if keyboard_timer.0.finished() {
8989
for (brick_shape, dot) in &mut bricks.iter() {
9090
if keyboard.pressed(KeyCode::Right) {
9191
let next_dot = dot.right().with_orignal_dot(&falling_dot);

0 commit comments

Comments
 (0)