• R/O
  • SSH

silny-kombat: Commit

Mercurial repo for silny-kombat project


Commit MetaInfo

Revisionb2f5ba8f93a5d321895b2de3dd2ac1ad543e3c0d (tree)
Time2021-11-11 04:25:31
AuthorSecT
CommiterSecT

Log Message

Timer based on iteration counter. Not finished

Change Summary

Incremental Difference

diff -r 29c07ae25f97 -r b2f5ba8f93a5 Cargo.toml
--- a/Cargo.toml Thu Oct 07 20:53:39 2021 +0200
+++ b/Cargo.toml Wed Nov 10 20:25:31 2021 +0100
@@ -25,6 +25,9 @@
2525 version = "1.0"
2626 optional = true
2727
28+[dependencies.tokio]
29+version = "1.13"
30+
2831 [dependencies.csfml-system-sys]
2932 path = "csfml/csfml-system-sys"
3033 version = "0.5.0"
diff -r 29c07ae25f97 -r b2f5ba8f93a5 src/controller.rs
--- a/src/controller.rs Thu Oct 07 20:53:39 2021 +0200
+++ b/src/controller.rs Wed Nov 10 20:25:31 2021 +0100
@@ -12,6 +12,7 @@
1212 use std::io::prelude::*;
1313 use std::path::Path;
1414
15+
1516 use sfml::{
1617 graphics::{
1718 Color, Transformable, Sprite, Texture, RenderWindow, RenderTarget
@@ -97,6 +98,9 @@
9798 let mut characterAInput : bool = false;
9899 let mut characterBInput : bool = false;
99100
101+ //TODO: use some kind of a timer
102+ let mut currentFrameTimer = 0;
103+
100104 loop {
101105 while let Some(event) = window.poll_event() {
102106 let mut key_result = keyProcessor.match_key(event);
@@ -116,6 +120,7 @@
116120
117121
118122 if key_result < KeyProcessor::KEY_BASE && !characterAInput{
123+ println!("A moved");
119124 //first char
120125 process_key_result_for_character(&keyProcessor, &mut character_A, key_result);
121126
@@ -125,12 +130,10 @@
125130 counter = 0;
126131 }
127132
128- if characterAInput && characterBInput{
129- characterAInput = false;
130- characterBInput = false;
131- }
132133
133134 } else if key_result >= KeyProcessor::KEY_BASE && !characterBInput {
135+ println!("B moved");
136+
134137 //second char
135138 key_result = key_result - KeyProcessor::KEY_BASE;
136139 process_key_result_for_character( &keyProcessor,&mut character_B, key_result);
@@ -141,11 +144,16 @@
141144 counter = 0;
142145 }
143146
144- if characterAInput && characterBInput{
145- characterAInput = false;
146- characterBInput = false;
147- }
148147
148+
149+ }
150+ else {
151+ println!("Neither char moves key_result: {} AInput: {} BInput: {}", key_result, characterAInput, characterBInput);
152+ }
153+
154+ if characterAInput && characterBInput{
155+ characterAInput = false;
156+ characterBInput = false;
149157 }
150158
151159 // if key_result == 3 {
@@ -167,6 +175,20 @@
167175 // state_b = 0;
168176 // counter = 0;
169177 // }
178+
179+ currentFrameTimer = currentFrameTimer +1;
180+
181+ if currentFrameTimer > 1
182+ {
183+ println!("currentFrameTimer expired");
184+
185+ //release the characters
186+ characterAInput = false;
187+ characterBInput = false;
188+
189+ currentFrameTimer = 0;
190+ }
191+
170192 }
171193
172194
@@ -177,6 +199,8 @@
177199 counter = 0;
178200 }
179201
202+
203+
180204 //character_A.char_sprite.show_sprite(state, counter);
181205 //character_B.char_sprite.show_sprite(state_b, counter);
182206
Show on old repository browser