• R/O
  • SSH

silny-kombat: コミット

Mercurial repo for silny-kombat project


コミットメタ情報

リビジョン423d14ac89a969a57ae64b6c00c927fdfacc30e9 (tree)
日時2022-09-08 04:46:41
作者Piotr Kozka <piotoor@gmai...>
コミッターPiotr Kozka

ログメッセージ

Fixed warnings in key_processing.rs

変更サマリ

差分

diff -r 7b7e9f3d78ac -r 423d14ac89a9 src/controller.rs
--- a/src/controller.rs Wed Sep 07 20:45:31 2022 +0200
+++ b/src/controller.rs Wed Sep 07 21:46:41 2022 +0200
@@ -92,11 +92,11 @@
9292 //let mut key_result = key_processor.match_key();
9393 if Key::A.is_pressed()
9494 {
95- output_b = process_key_result_for_character(&key_processor, &mut character_b, KeyEvents::Char_B_Left);
95+ output_b = process_key_result_for_character(&key_processor, &mut character_b, KeyEvents::CharBLeft);
9696 }
9797 if Key::D.is_pressed()
9898 {
99- output_b = process_key_result_for_character(&key_processor, &mut character_b, KeyEvents::Char_B_Right);
99+ output_b = process_key_result_for_character(&key_processor, &mut character_b, KeyEvents::CharBRight);
100100 }
101101 if Key::F4.is_pressed()
102102 {
@@ -109,11 +109,11 @@
109109 }
110110 if Key::LEFT.is_pressed()
111111 {
112- output_a = process_key_result_for_character(&key_processor, &mut character_a, KeyEvents::Char_Left);
112+ output_a = process_key_result_for_character(&key_processor, &mut character_a, KeyEvents::CharLeft);
113113 }
114114 if Key::RIGHT.is_pressed()
115115 {
116- output_a = process_key_result_for_character(&key_processor, &mut character_a, KeyEvents::Char_Right);
116+ output_a = process_key_result_for_character(&key_processor, &mut character_a, KeyEvents::CharRight);
117117 }
118118 // match key_result {
119119 // KeyEvents::Char_B_Left => {
diff -r 7b7e9f3d78ac -r 423d14ac89a9 src/key_processing.rs
--- a/src/key_processing.rs Wed Sep 07 20:45:31 2022 +0200
+++ b/src/key_processing.rs Wed Sep 07 21:46:41 2022 +0200
@@ -4,7 +4,7 @@
44
55 };
66
7-use crate::key_processing::KeyEvents::{Char_Left, Char_Right, Char_Key_Release};
7+use crate::key_processing::KeyEvents::{CharLeft, CharRight, CharKeyRelease};
88
99 //use crate::sprite_rendering;
1010
@@ -13,12 +13,12 @@
1313 pub enum KeyEvents {
1414 None = -1,
1515 Escape,
16- Char_Left,
17- Char_Right,
18- Char_Key_Release,
19- Char_B_Left = 11,
20- Char_B_Right = 12,
21- Char_B_Key_Release = 13,
16+ CharLeft,
17+ CharRight,
18+ CharKeyRelease,
19+ CharBLeft = 11,
20+ CharBRight = 12,
21+ CharBKeyRelease = 13,
2222 KeyTesting = 99
2323 }
2424
@@ -45,32 +45,15 @@
4545 }
4646
4747 pub fn process_key(&self, key_result: KeyEvents) -> SignalForSM {
48-
49- match key_result {
50- KeyEvents::Char_B_Left => return SignalForSM::MoveToLeft,
51- KeyEvents::Char_B_Right => return SignalForSM::MoveToRight,
52- KeyEvents::Char_Key_Release => return SignalForSM::KeyRelease,
53- KeyEvents::Char_Left => return SignalForSM::MoveToLeft,
54- KeyEvents::Char_Right => return SignalForSM::MoveToRight,
55- KeyEvents::Char_Key_Release => return SignalForSM::KeyRelease,
56-
57- _ => {return SignalForSM::None}
58- }
48+ return match key_result {
49+ KeyEvents::CharBLeft => SignalForSM::MoveToLeft,
50+ KeyEvents::CharBRight => SignalForSM::MoveToRight,
51+ CharKeyRelease => SignalForSM::KeyRelease,
52+ CharLeft => SignalForSM::MoveToLeft,
53+ CharRight => SignalForSM::MoveToRight,
5954
60- // if key_result == KeyEvents::Char_Left
61- // {
62- // return SignalForSM::MoveToLeft;
63- //
64- //
65- // } else if key_result == KeyEvents::Char_Right as i32
66- // {
67- // return SignalForSM::MoveToRight;
68- //
69- // } else if key_result == KeyEvents::Char_Key_Release as i32
70- // {
71- // return SignalForSM::KeyRelease;
72- // }
73- // return SignalForSM::None;
55+ _ => { SignalForSM::None }
56+ }
7457 }
7558
7659
@@ -81,11 +64,11 @@
8164 //TODO: refactor enum->i32 conversions, just return a enum
8265 if Key::A.is_pressed()
8366 {
84- return KeyEvents::Char_B_Left;
67+ return KeyEvents::CharBLeft;
8568 }
8669 if Key::D.is_pressed()
8770 {
88- return KeyEvents::Char_B_Right;
71+ return KeyEvents::CharBRight;
8972 }
9073 if Key::F4.is_pressed()
9174 {
@@ -97,11 +80,11 @@
9780 }
9881 if Key::LEFT.is_pressed()
9982 {
100- return KeyEvents::Char_Left;
83+ return CharLeft;
10184 }
10285 if Key::RIGHT.is_pressed()
10386 {
104- return KeyEvents::Char_Right;
87+ return CharRight;
10588 }
10689
10790 return KeyEvents::None;
旧リポジトリブラウザで表示