• R/O
  • SSH

silny-kombat: Commit

Mercurial repo for silny-kombat project


Commit MetaInfo

Révision1e30795bf6a599eead56c174997f4aa03d3a25c3 (tree)
l'heure2022-10-07 03:35:31
AuteurPiotr Kozka <piotoor@gmai...>
CommiterPiotr Kozka

Message de Log

merged warning_fixes_22092022

Change Summary

Modification

diff -r bd7764e9f686 -r 1e30795bf6a5 src/character.rs
--- a/src/character.rs Wed Sep 21 20:08:00 2022 +0200
+++ b/src/character.rs Thu Oct 06 20:35:31 2022 +0200
@@ -1,7 +1,5 @@
11 use crate::character_state_machine;
22 use crate::sprite_rendering;
3-
4-use crate::key_processing::SignalForSM;
53 use rust_fsm::TransitionImpossibleError;
64
75 use sfml::{
diff -r bd7764e9f686 -r 1e30795bf6a5 src/controller.rs
--- a/src/controller.rs Wed Sep 21 20:08:00 2022 +0200
+++ b/src/controller.rs Thu Oct 06 20:35:31 2022 +0200
@@ -16,12 +16,12 @@
1616 graphics::{
1717 Color, Transformable, Texture, RenderWindow, RenderTarget
1818 },
19- window::{ ContextSettings, Style},
19+ window::{ ContextSettings, Style, event},
2020 system::Vector2f,
2121 SfBox
2222 };
2323 use crate::key_processing::{KeyProcessor, SignalForSM, KeyEvents};
24-use sfml::window::Key;
24+use sfml::window::{Event, Key};
2525
2626 pub struct Controller<'a> {
2727 character_a : Option<&'a Character<'a>>,
@@ -84,9 +84,14 @@
8484 //loop
8585
8686 //let &mut mut stateReference: &mut i32;
87+ while window.is_open() {
88+ for event in window.poll_event() {
89+ match event {
90+ Event::Closed => window.close(),
91+ _ => {/* do nothing */}
92+ }
93+ }
8794
88-
89- loop {
9095 let mut output_a: Result<Option<character_state_machine::CharacterFSMOutput>, TransitionImpossibleError> = character_a.trigger(character_state_machine::CharacterFSMInput::Released);
9196 let mut output_b: Result<Option<character_state_machine::CharacterFSMOutput>, TransitionImpossibleError> = character_b.trigger(character_state_machine::CharacterFSMInput::Released);
9297 //let mut key_result = key_processor.match_key();
diff -r bd7764e9f686 -r 1e30795bf6a5 src/key_processing.rs
--- a/src/key_processing.rs Wed Sep 21 20:08:00 2022 +0200
+++ b/src/key_processing.rs Thu Oct 06 20:35:31 2022 +0200
@@ -1,25 +1,23 @@
11 use sfml::{
2- window::{ Event, Key},
3-
4-
2+ window::{Event, Key},
53 };
64
75 use crate::key_processing::KeyEvents::{CharLeft, CharRight, CharKeyRelease};
86
97 //use crate::sprite_rendering;
108
11-pub const KEY_BASE : i32 = 10;
9+// pub const KEY_BASE : i32 = 10;
1210
1311 pub enum KeyEvents {
14- None = -1,
15- Escape,
12+ //None = -1,
13+ //Escape,
1614 CharLeft,
1715 CharRight,
1816 CharKeyRelease,
1917 CharBLeft = 11,
2018 CharBRight = 12,
21- CharBKeyRelease = 13,
22- KeyTesting = 99
19+ //CharBKeyRelease = 13,
20+ //KeyTesting = 99
2321 }
2422
2523 pub enum SignalForSM {
@@ -36,7 +34,7 @@
3634
3735 impl KeyProcessor {
3836
39- pub const KEY_BASE : i32 = 10;
37+ // pub const KEY_BASE : i32 = 10;
4038
4139 //fn new(new_sprite: &'a Sprite) -> Self{
4240 //pub fn new(new_sprite: &'a mut Sprite<'a>) -> Self{
@@ -52,43 +50,43 @@
5250 CharLeft => SignalForSM::MoveToLeft,
5351 CharRight => SignalForSM::MoveToRight,
5452
55- _ => { SignalForSM::None }
53+ //_ => { SignalForSM::None }
5654 }
5755 }
5856
5957
6058
61- pub fn match_key(&self) -> KeyEvents {
62-
63- //TODO: refactor enum->i32 conversions, just return a enum
64- //TODO: refactor enum->i32 conversions, just return a enum
65- if Key::A.is_pressed()
66- {
67- return KeyEvents::CharBLeft;
68- }
69- if Key::D.is_pressed()
70- {
71- return KeyEvents::CharBRight;
72- }
73- if Key::F4.is_pressed()
74- {
75- return KeyEvents::KeyTesting;
76- }
77- if Key::ESCAPE.is_pressed()
78- {
79- return KeyEvents::Escape;
80- }
81- if Key::LEFT.is_pressed()
82- {
83- return CharLeft;
84- }
85- if Key::RIGHT.is_pressed()
86- {
87- return CharRight;
88- }
89-
90- return KeyEvents::None;
91- }
59+ // pub fn match_key(&self) -> KeyEvents {
60+ //
61+ // //TODO: refactor enum->i32 conversions, just return a enum
62+ // //TODO: refactor enum->i32 conversions, just return a enum
63+ // if Key::A.is_pressed()
64+ // {
65+ // return KeyEvents::CharBLeft;
66+ // }
67+ // if Key::D.is_pressed()
68+ // {
69+ // return KeyEvents::CharBRight;
70+ // }
71+ // if Key::F4.is_pressed()
72+ // {
73+ // return KeyEvents::KeyTesting;
74+ // }
75+ // if Key::ESCAPE.is_pressed()
76+ // {
77+ // return KeyEvents::Escape;
78+ // }
79+ // if Key::LEFT.is_pressed()
80+ // {
81+ // return CharLeft;
82+ // }
83+ // if Key::RIGHT.is_pressed()
84+ // {
85+ // return CharRight;
86+ // }
87+ //
88+ // return KeyEvents::None;
89+ // }
9290
9391
9492 }
\ No newline at end of file
Afficher sur ancien navigateur de dépôt.