Skip to content

Commit b099c80

Browse files
authored
Merge pull request #33 from hyoi/migration_0.14
v0.14.0のリリース(Bevy 0.14対応)
2 parents 77e69e0 + c147fd2 commit b099c80

File tree

20 files changed

+590
-498
lines changed

20 files changed

+590
-498
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ resolver = "2"
33
members = [ "crates/tigtag" ]
44

55
[workspace.package]
6-
version = "0.13.0"
6+
version = "0.14.0"
77
edition = "2021"
88

99
[workspace.dependencies]
10+
#bevy = { git = "https://github.com/bevyengine/bevy", branch = "release-0.14.0" }
1011
#bevy = { git = "https://github.com/bevyengine/bevy" } #Master branch
11-
bevy = "0.13"
12+
bevy = "0.14"
1213
once_cell = "1"
1314
rand = "0.8"
1415
chrono = "0.4"

crates/share/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use bevy::
33
{ prelude::*,
44
window::WindowMode,
55
ecs::query::QueryFilter,
6+
color::palettes::css,
67
};
78
use once_cell::sync::Lazy;
89

crates/share/src/misc/constants.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![allow( dead_code )]
22

3+
use super::*;
4+
35
////////////////////////////////////////////////////////////////////////////////
46

57
//アプリの情報
@@ -15,4 +17,42 @@ pub const SPRITE_SHEET_OFF: fn() -> bool = || cfg!( feature = "sprite_sheet_off"
1517

1618
////////////////////////////////////////////////////////////////////////////////
1719

20+
//v0.14.0でカラー定数がmodule移動したので、とりあえず自力で追加
21+
22+
//オーファンルール対策用trait
23+
pub trait ColorConstants
24+
{ const BISQUE : Color;
25+
const DARK_GRAY: Color;
26+
const RED : Color;
27+
const GREEN : Color;
28+
const BLUE : Color;
29+
const GRAY : Color;
30+
const YELLOW : Color;
31+
const TEAL : Color;
32+
const SILVER : Color;
33+
const SEA_GREEN: Color;
34+
const GOLD : Color;
35+
const CYAN : Color;
36+
const PINK : Color;
37+
}
38+
39+
//カラー定数を bevy::prelude::Color へ追加(とりあえず)
40+
impl ColorConstants for bevy::prelude::Color
41+
{ const BISQUE : Color = Color::Srgba( css::BISQUE );
42+
const DARK_GRAY: Color = Color::Srgba( css::DARK_GRAY );
43+
const RED : Color = Color::Srgba( css::RED );
44+
const GREEN : Color = Color::Srgba( css::GREEN );
45+
const BLUE : Color = Color::Srgba( css::BLUE );
46+
const GRAY : Color = Color::Srgba( css::GRAY );
47+
const YELLOW : Color = Color::Srgba( css::YELLOW );
48+
const TEAL : Color = Color::Srgba( css::TEAL );
49+
const SILVER : Color = Color::Srgba( css::SILVER );
50+
const SEA_GREEN: Color = Color::Srgba( css::SEA_GREEN );
51+
const GOLD : Color = Color::Srgba( css::GOLD );
52+
const CYAN : Color = Color::Srgba( css::AQUA );
53+
const PINK : Color = Color::Srgba( css::PINK );
54+
}
55+
56+
////////////////////////////////////////////////////////////////////////////////
57+
1858
//End of code.

crates/share/src/misc/functions.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,21 @@ pub fn hide_component<T: Component>
166166

167167
////////////////////////////////////////////////////////////////////////////////
168168

169+
//bevy::window::close_on_escがv0.14.0で廃止になったため代替
170+
// remove close_on_esc #12859
171+
// https://github.com/bevyengine/bevy/pull/12859
172+
pub fn close_on_esc
173+
( mut cmds: Commands,
174+
windows: Query< ( Entity, &Window ) >,
175+
inkey: Res< ButtonInput< KeyCode > >,
176+
)
177+
{ for ( id, window ) in windows.iter()
178+
{ if window.focused && inkey.just_pressed( KeyCode::Escape )
179+
{ cmds.entity( id ).despawn();
180+
}
181+
}
182+
}
183+
184+
////////////////////////////////////////////////////////////////////////////////
185+
169186
//End of code.

crates/tigtag/src/debug.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use super::*;
66
pub fn spawn_2d_sprites
77
( mut cmds: Commands,
88
)
9-
{ let color = Color::rgba( 0.1, 0.1, 0.1, 0.4 );
9+
{ let color = Color::srgba( 0.1, 0.1, 0.1, 0.4 );
1010
let custom_size = Some ( GRID_CUSTOM_SIZE * 0.9 );
1111

1212
for x in GRIDS_X_RANGE
@@ -268,7 +268,7 @@ pub fn catch_input_mouse
268268
//ホイールで極座標を更新する
269269
for mouse_wheel in evt_mouse_wheel.read()
270270
{ orbit.r += mouse_wheel.y * 0.2; //感度良すぎるので
271-
orbit.r = orbit.r.min( CAMERA_ORBIT_MAX_R ).max( CAMERA_ORBIT_MIN_R );
271+
orbit.r = orbit.r.clamp( CAMERA_ORBIT_MIN_R, CAMERA_ORBIT_MAX_R );
272272
}
273273

274274
//右ボタンが押されていないなら
@@ -278,7 +278,7 @@ pub fn catch_input_mouse
278278
for mouse_motion in evt_mouse_motion.read()
279279
{ //上下
280280
orbit.theta += mouse_motion.delta.y * 0.01; //感度良すぎるので
281-
orbit.theta = orbit.theta.min( CAMERA_ORBIT_MAX_THETA ).max( CAMERA_ORBIT_MIN_THETA );
281+
orbit.theta = orbit.theta.clamp( CAMERA_ORBIT_MIN_THETA, CAMERA_ORBIT_MAX_THETA );
282282

283283
//左右
284284
orbit.phi -= mouse_motion.delta.x * 0.01; //感度良すぎるので
@@ -328,7 +328,7 @@ pub fn catch_input_gamepad
328328
if let Some ( value ) = axis_stick.get( stick_y )
329329
{ if value != 0.0
330330
{ orbit.theta += value * time_delta;
331-
orbit.theta = orbit.theta.min( CAMERA_ORBIT_MAX_THETA ).max( CAMERA_ORBIT_MIN_THETA );
331+
orbit.theta = orbit.theta.clamp( CAMERA_ORBIT_MIN_THETA, CAMERA_ORBIT_MAX_THETA );
332332
flag = true;
333333
}
334334
}

crates/tigtag/src/init_app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const FOOTER_RIGHT: &[ MessageSect ] =
9696
const GRID_X_KANI: i32 = SCREEN_GRIDS_WIDTH - 4;
9797
const GRID_Y_KANI: i32 = SCREEN_GRIDS_HEIGHT - 1;
9898
const MAGNIFY_SPRITE_KANI: f32 = 0.9;
99-
const COLOR_SPRITE_KANI: Color = Color::rgba( 1.0, 1.0, 1.0, 0.6 );
99+
const COLOR_SPRITE_KANI: Color = Color::srgba( 1.0, 1.0, 1.0, 0.6 );
100100

101101
////////////////////////////////////////////////////////////////////////////////
102102

crates/tigtag/src/load_assets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn is_loading_done
117117
for handle in assets.handles.iter()
118118
{ match asset_svr.get_load_state( handle )
119119
{ Some ( LoadState::Loaded ) => (), //ロード完了
120-
Some ( LoadState::Failed ) =>
120+
Some ( LoadState::Failed (_) ) =>
121121
{ //ロード失敗⇒パニック
122122
let mut filename = "Unknown".to_string();
123123
if let Some ( asset_path ) = handle.path()

crates/tigtag/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ fn main()
7070
misc::change_gamepad_connection,
7171

7272
//特殊な操作
73-
( bevy::window::close_on_esc, //[ESC]で終了
74-
misc::toggle_window_mode, //フルスクリーン切換
73+
( misc::close_on_esc, //[ESC]で終了
74+
misc::toggle_window_mode, //フルスクリーン切換
7575
)
7676
.run_if( not( WASM ) ),
7777
),

crates/tigtag_inside/src/chasers.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ pub struct Chaser
1515
pub px_end : Vec2, //1フレーム時間に移動した微小区間の終点
1616
pub opt_fn_autochase: Option<FnAutoChase>, //敵キャラの移動方向を決める関数
1717
pub color : Color, //敵キャラの表示色
18-
pub anime_timer: Timer, //アニメーションのタイマー
19-
pub sprite_sheet_frame: usize, //アニメーションのフレーム数
20-
pub sprite_sheet_indexes: HashMap<News, usize>, //アニメーションの先頭位置(offset値)
18+
pub anime_timer: Timer, //アニメーションのタイマー
19+
pub sprite_sheet_frame: u32, //アニメーションのフレーム数
20+
pub sprite_sheet_indexes: HashMap<News, u32>, //アニメーションの先頭位置(offset値)
2121
}
2222

2323
impl Default for Chaser
@@ -48,10 +48,10 @@ impl CharacterAnimation for Chaser
4848
{ fn anime_timer_mut( &mut self ) -> &mut Timer
4949
{ &mut self.anime_timer
5050
}
51-
fn sprite_sheet_frame( &self ) -> usize
51+
fn sprite_sheet_frame( &self ) -> u32
5252
{ self.sprite_sheet_frame
5353
}
54-
fn sprite_sheet_offset( &self, news: News ) -> usize
54+
fn sprite_sheet_offset( &self, news: News ) -> u32
5555
{ *self.sprite_sheet_indexes.get( &news ).unwrap()
5656
}
5757
fn direction( &self ) -> News
@@ -76,10 +76,10 @@ const MAX_X: i32 = map::MAP_GRIDS_WIDTH - 2;
7676
const MAX_Y: i32 = map::MAP_GRIDS_HEIGHT - 2;
7777

7878
//スプライトシートを使ったアニメーションの情報
79-
const SPRITE_SHEET_SIZE_CHASER: Vec2 = Vec2::new( 8.0, 8.0 );
80-
const SPRITE_SHEET_COLS_CHASER: usize = 4;
81-
const SPRITE_SHEET_ROWS_CHASER: usize = 4;
82-
static SPRITE_SHEET_IDXS_CHASER: Lazy<HashMap<News,usize>> = Lazy::new
79+
const SPRITE_SHEET_SIZE_CHASER: UVec2 = UVec2::new( 8, 8 );
80+
const SPRITE_SHEET_COLS_CHASER: u32 = 4;
81+
const SPRITE_SHEET_ROWS_CHASER: u32 = 4;
82+
static SPRITE_SHEET_IDXS_CHASER: Lazy<HashMap<News,u32>> = Lazy::new
8383
( ||
8484
HashMap::from
8585
( [ ( News::North, 0 ),
@@ -156,8 +156,8 @@ pub fn spawn_sprite
156156
None, None
157157
)
158158
);
159-
let index = chaser.sprite_sheet_offset( chaser.direction() );
160-
cmds.spawn( ( SpriteSheetBundle::default(), chaser ) )
159+
let index = chaser.sprite_sheet_offset( chaser.direction() ) as usize;
160+
cmds.spawn( ( SpriteBundle::default(), chaser ) )
161161
.insert( Sprite { custom_size, ..default() } )
162162
.insert( asset_svr.load( asset_file ) as Handle<Image> )
163163
.insert( TextureAtlas { layout, index } )
@@ -253,9 +253,9 @@ pub fn move_sprite
253253

254254
//進行方向が変わったらスプライトの見栄えを変える(スプライトシートのindexを変える)
255255
if ! SPRITE_SHEET_OFF() && chaser.direction != new_side
256-
{ let old_offset = chaser.sprite_sheet_offset( chaser.direction );
257-
let new_offset = chaser.sprite_sheet_offset( new_side );
258-
sprite_sheet.index = sprite_sheet.index - old_offset + new_offset;
256+
{ let old_offset = chaser.sprite_sheet_offset( chaser.direction ) as usize;
257+
let new_offset = chaser.sprite_sheet_offset( new_side ) as usize;
258+
sprite_sheet.index = sprite_sheet.index + new_offset - old_offset;
259259
}
260260
chaser.direction = new_side;
261261

@@ -273,7 +273,7 @@ pub fn move_sprite
273273

274274
//後続の処理にtimer finishedを伝達する
275275
if ! chaser_timer_finished.is_empty()
276-
{ evt_timer.send( EventTimerChasers ( chaser_timer_finished ) );
276+
{ evt_timer.send( EventTimerChasers );
277277
}
278278

279279
//敵キャラは重なるとスピードアップする

crates/tigtag_inside/src/common.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ impl Record
4242
//System間の通知用イベント
4343
#[derive( Event )] pub struct EventClear;
4444
#[derive( Event )] pub struct EventOver;
45-
#[derive( Event )] pub struct EventEatDot ( pub IVec2 );
45+
#[derive( Event )] pub struct EventEatDot;
4646
#[derive( Event )] pub struct EventTimerPlayer;
47-
#[derive( Event )] pub struct EventTimerChasers ( pub Vec<Color> );
47+
#[derive( Event )] pub struct EventTimerChasers;
4848

4949
////////////////////////////////////////////////////////////////////////////////
5050

@@ -129,8 +129,8 @@ impl AddAssign<News> for IVec2
129129
//スプライトシートでアニメーションするためのトレイト
130130
pub trait CharacterAnimation
131131
{ fn anime_timer_mut( &mut self ) -> &mut Timer;
132-
fn sprite_sheet_frame( &self ) -> usize;
133-
fn sprite_sheet_offset( &self, news: News ) -> usize;
132+
fn sprite_sheet_frame( &self ) -> u32;
133+
fn sprite_sheet_offset( &self, news: News ) -> u32;
134134
fn direction( &self ) -> News;
135135
}
136136

0 commit comments

Comments
 (0)