Mercurial repo for silny-kombat project
Révision | 8c381616eb278d88a05306785935ddc41d3901fc (tree) |
---|---|
l'heure | 2022-01-13 05:10:43 |
Auteur | SecT |
Commiter | SecT |
Set the ground level
@@ -107,41 +107,46 @@ | ||
107 | 107 | pub fn check_test_results(A_x_min: i32, A_x_max: i32, B_x_min: i32, B_x_max: i32) ->bool{ |
108 | 108 | |
109 | 109 | let values: Vec<i32> = get_test_values_from_dump_file(); |
110 | + //[groundLevel, Ax,Ay, Bx, By] | |
110 | 111 | |
111 | 112 | for value in & values { |
112 | 113 | println!("value: {}", value) |
113 | 114 | } |
114 | 115 | |
116 | + | |
117 | + let groundLevel = values[0]; | |
118 | + | |
115 | 119 | // let A_x_min = 55; |
116 | 120 | // let A_x_max = 65; |
117 | 121 | // |
118 | 122 | // let B_x_min = 535; |
119 | 123 | // let B_x_max = 545; |
120 | 124 | |
125 | + let startOfCharCoordinateData=1; | |
121 | 126 | |
122 | - if values.len() >= 4 { | |
127 | + if values.len() >= 5 { | |
123 | 128 | |
124 | 129 | //Character A, X value |
125 | - if values[0] < A_x_min || values[0] > A_x_max { | |
126 | - println!("FAIL values[0]: {}", values[0]); | |
130 | + if values[startOfCharCoordinateData+0] < A_x_min || values[startOfCharCoordinateData+0] > A_x_max { | |
131 | + println!("FAIL values[0]: {}", values[startOfCharCoordinateData+0]); | |
127 | 132 | return false; |
128 | 133 | } |
129 | 134 | |
130 | 135 | //Character A, Y value |
131 | - if values[1] != 0 { | |
132 | - println!("FAIL values[1]: {}", values[1]); | |
136 | + if values[startOfCharCoordinateData+1] != groundLevel+0 { | |
137 | + println!("FAIL values[1]: {}", values[startOfCharCoordinateData+1]); | |
133 | 138 | return false; |
134 | 139 | } |
135 | 140 | |
136 | 141 | //Character B, X value |
137 | - if values[2] < B_x_min || values[2] > B_x_max { | |
138 | - println!("FAIL values[2]: {}", values[2]); | |
142 | + if values[startOfCharCoordinateData+2] < B_x_min || values[startOfCharCoordinateData+2] > B_x_max { | |
143 | + println!("FAIL values[2]: {}", values[startOfCharCoordinateData+2]); | |
139 | 144 | return false; |
140 | 145 | } |
141 | 146 | |
142 | 147 | //Character B, Y value |
143 | - if values[3] != 0 { | |
144 | - println!("FAIL values[3]: {}", values[3]); | |
148 | + if values[startOfCharCoordinateData+3] != groundLevel+0 { | |
149 | + println!("FAIL values[3]: {}", values[startOfCharCoordinateData+3]); | |
145 | 150 | return false; |
146 | 151 | } |
147 | 152 |
@@ -72,7 +72,11 @@ | ||
72 | 72 | |
73 | 73 | println!("{} vs {}", character_A.get_name(), character_B.get_name()); |
74 | 74 | |
75 | - character_B.char_sprite.sprite.set_position(Vector2f::new(600.0, 0.0)); | |
75 | + let groundLevel = 100.0; | |
76 | + | |
77 | + character_A.char_sprite.sprite.set_position(Vector2f::new(0.0, groundLevel + 0.0)); | |
78 | + | |
79 | + character_B.char_sprite.sprite.set_position(Vector2f::new(600.0, groundLevel + 0.0)); | |
76 | 80 | character_B.char_sprite.sprite.set_scale(Vector2f::new(-1.0, 1.0)); |
77 | 81 | |
78 | 82 | //loop |
@@ -91,7 +95,7 @@ | ||
91 | 95 | if key_result == 99 { |
92 | 96 | //testing |
93 | 97 | println!("Testing: dump values to check"); |
94 | - save_test_data_to_file(&character_A.char_sprite, &character_B.char_sprite); | |
98 | + save_test_data_to_file(groundLevel, &character_A.char_sprite, &character_B.char_sprite); | |
95 | 99 | } |
96 | 100 | |
97 | 101 |
@@ -209,12 +213,14 @@ | ||
209 | 213 | } |
210 | 214 | } |
211 | 215 | |
212 | -pub fn save_test_data_to_file(spriteA: &CharacterSprite, spriteB: &CharacterSprite) | |
216 | +pub fn save_test_data_to_file(groundLevel:f32, spriteA: &CharacterSprite, spriteB: &CharacterSprite) | |
213 | 217 | { |
214 | 218 | let mut data_to_dump: String = "spriteAData\n".to_string(); |
215 | 219 | |
216 | 220 | //data_to_dump = &String::from("spriteAData"); |
217 | 221 | |
222 | + data_to_dump.push_str(&groundLevel.to_string()); | |
223 | + data_to_dump.push_str("\n"); | |
218 | 224 | data_to_dump.push_str( &spriteA.sprite.position().x.to_string()); |
219 | 225 | data_to_dump.push_str("\n"); |
220 | 226 | data_to_dump.push_str( &spriteA.sprite.position().y.to_string()); |
@@ -64,6 +64,8 @@ | ||
64 | 64 | |
65 | 65 | //data_to_dump = &String::from("spriteAData"); |
66 | 66 | |
67 | + | |
68 | + | |
67 | 69 | data_to_dump.push_str( &sprite_a.sprite.position().x.to_string()); |
68 | 70 | data_to_dump.push_str("\n"); |
69 | 71 | data_to_dump.push_str( &sprite_a.sprite.position().y.to_string()); |