• R/O
  • SSH

silny-kombat: Commit

Mercurial repo for silny-kombat project


Commit MetaInfo

Revisione4cdb3f1a39dcd049d92c3437f520033e008ad93 (tree)
Time2022-04-06 03:17:46
AuthorPiotr Kozka <piotoor@gmai...>
CommiterPiotr Kozka

Log Message

Merged feature branch.

Change Summary

Incremental Difference

diff -r 1373908174ca -r e4cdb3f1a39d src/character_state_machine.rs
--- a/src/character_state_machine.rs Wed Feb 09 21:38:31 2022 +0100
+++ b/src/character_state_machine.rs Tue Apr 05 20:17:46 2022 +0200
@@ -18,66 +18,24 @@
1818 }
1919
2020 pub struct StateMachineWrapper {
21- machine: StateMachine<CharacterFSM>,
22- num_state: i32
21+ machine: StateMachine<CharacterFSM>
2322 }
2423
2524 impl StateMachineWrapper {
2625 pub fn new() -> StateMachineWrapper {
2726 StateMachineWrapper {
28- machine: StateMachine::new(),
29- num_state: 0
27+ machine: StateMachine::new()
3028 }
3129 }
3230
33- // pub fn get_state(&self) -> &CharacterFSMState {
34- // &self.machine.state()
35- // }
36-
37- pub fn get_num_state(&self) -> i32 {
38- self.num_state
31+ pub fn get_state(&self) -> &CharacterFSMState {
32+ &self.machine.state()
3933 }
40- pub fn trigger(&mut self, signal: i32) -> i32 {
41- let output: Result<Option<CharacterFSMOutput>, TransitionImpossibleError>;
42- let mut ans = 1;
43- if signal == 1 {
44- output = self.machine.consume(&CharacterFSMInput::BackPressed);
45- match output {
46- Ok(v) => match v {
47- Some(CharacterFSMOutput::Back) => ans = 1,
48- Some(CharacterFSMOutput::Front) => ans = 2,
49- Some(CharacterFSMOutput::Idle) => ans = 0,
50- None => println!("None"),
51- }
52- Err(e) => println!("State machine error back pressed {}", e),
53- }
54- } else if signal == 2 {
55- output = self.machine.consume(&CharacterFSMInput::FrontPressed);
56- match output {
57- Ok(v) => match v {
58- Some(CharacterFSMOutput::Back) => ans = 1,
59- Some(CharacterFSMOutput::Front) => ans = 2,
60- Some(CharacterFSMOutput::Idle) => ans = 0,
61- None => println!("None"),
62- }
63- Err(e) => println!("State machine error front pressed {}", e),
64- }
65- } else {
66- output = self.machine.consume(&CharacterFSMInput::Released);
67- match output {
68- Ok(v) => match v {
69- Some(CharacterFSMOutput::Back) => ans = 1,
70- Some(CharacterFSMOutput::Front) => ans = 2,
71- Some(CharacterFSMOutput::Idle) => ans = 0,
72- None => println!("None"),
73- }
74- Err(e) => println!("State machine error released {}", e),
75- }
76- }
77- println!("ans = {}", ans);
78- self.num_state = ans;
79- ans
34+
35+ pub fn trigger_(&mut self, signal: CharacterFSMInput) -> Result<Option<CharacterFSMOutput>, TransitionImpossibleError> {
36+ self.machine.consume(&signal)
8037 }
8138
8239
40+
8341 }
diff -r 1373908174ca -r e4cdb3f1a39d src/sprite_rendering.rs
--- a/src/sprite_rendering.rs Wed Feb 09 21:38:31 2022 +0100
+++ b/src/sprite_rendering.rs Tue Apr 05 20:17:46 2022 +0200
@@ -36,13 +36,13 @@
3636 }
3737
3838 fn move_left(&mut self) {
39- let v = Vector2f::new(-1.0, 0.0);
39+ let v = Vector2f::new(-10.0, 0.0);
4040 self.sprite.move_(v);
4141 }
4242
4343
4444 pub fn move_right(&mut self) {
45- let v = Vector2f::new(1.0, 0.0);
45+ let v = Vector2f::new(10.0, 0.0);
4646 self.sprite.move_(v);
4747 }
4848
@@ -55,33 +55,33 @@
5555
5656 if state == States::Idle as i32
5757 {
58- if self.counter % 10 == 0
58+ if self.counter % 4 == 0
5959 {
6060 self.sprite.set_texture(&self.textures[1], true);
6161 }
62- if self.counter % 20 == 0
62+ if self.counter % 8 == 0
6363 {
6464 self.sprite.set_texture(&self.textures[0], true);
6565 }
6666 } else if state == States::MovingRight as i32
6767 {
6868 self.move_right();
69- if self.counter % 10 == 0
69+ if self.counter % 4 == 0
7070 {
7171 self.sprite.set_texture(&self.textures[2], true);
7272 }
73- if self.counter % 20 == 0
73+ if self.counter % 8 == 0
7474 {
7575 self.sprite.set_texture(&self.textures[3], true);
7676 }
7777 } else if state == States::MovingLeft as i32
7878 {
7979 self.move_left();
80- if self.counter % 10 == 0
80+ if self.counter % 4 == 0
8181 {
8282 self.sprite.set_texture(&self.textures[3], true);
8383 }
84- if self.counter % 20 == 0
84+ if self.counter % 8 == 0
8585 {
8686 self.sprite.set_texture(&self.textures[2], true);
8787 }
Show on old repository browser