Browse Source

Fix: input bounds checking for x-axis

tjalkane 4 years ago
parent
commit
a73640764d

+ 2 - 2
book/src/chapter_2.md

@@ -544,7 +544,7 @@ fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
         pos.y += delta_y;
 
         if pos.x < 0 { pos.x = 0; }
-        if pos.x > 79 { pos.y = 79; }
+        if pos.x > 79 { pos.x = 79; }
         if pos.y < 0 { pos.y = 0; }
         if pos.y > 49 { pos.y = 49; }
     }
@@ -635,7 +635,7 @@ fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
         pos.y += delta_y;
 
         if pos.x < 0 { pos.x = 0; }
-        if pos.x > 79 { pos.y = 79; }
+        if pos.x > 79 { pos.x = 79; }
         if pos.y < 0 { pos.y = 0; }
         if pos.y > 49 { pos.y = 49; }
     }

+ 2 - 2
book/src/chapter_3.md

@@ -165,7 +165,7 @@ fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
         }
@@ -259,7 +259,7 @@ fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
         }

+ 1 - 1
book/src/chapter_5.md

@@ -453,7 +453,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-02-helloecs/src/main.rs

@@ -37,7 +37,7 @@ fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
         pos.y += delta_y;
 
         if pos.x < 0 { pos.x = 0; }
-        if pos.x > 79 { pos.y = 79; }
+        if pos.x > 79 { pos.x = 79; }
         if pos.y < 0 { pos.y = 0; }
         if pos.y > 49 { pos.y = 49; }
     }

+ 1 - 1
chapter-03-walkmap/src/main.rs

@@ -75,7 +75,7 @@ fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
         }

+ 1 - 1
chapter-04-newmap/src/player.rs

@@ -14,7 +14,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
         }

+ 1 - 1
chapter-05-fov/src/player.rs

@@ -17,7 +17,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-06-monsters/src/player.rs

@@ -17,7 +17,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-07-damage/src/player.rs

@@ -29,7 +29,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-08-ui/src/player.rs

@@ -29,7 +29,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-09-items/src/player.rs

@@ -30,7 +30,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-10-ranged/src/player.rs

@@ -30,7 +30,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-11-loadsave/src/player.rs

@@ -30,7 +30,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-12-delvingdeeper/src/player.rs

@@ -30,7 +30,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-13-difficulty/src/player.rs

@@ -30,7 +30,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-14-gear/src/player.rs

@@ -30,7 +30,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-16-nicewalls/src/player.rs

@@ -30,7 +30,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-17-blood/src/player.rs

@@ -30,7 +30,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-18-particles/src/player.rs

@@ -30,7 +30,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-19-food/src/player.rs

@@ -30,7 +30,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-20-magicmapping/src/player.rs

@@ -30,7 +30,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-21-rexmenu/src/player.rs

@@ -30,7 +30,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             pos.y += delta_y;
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-22-simpletraps/src/player.rs

@@ -32,7 +32,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             entity_moved.insert(entity, EntityMoved{}).expect("Unable to insert marker");
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-23-generic-map/src/player.rs

@@ -32,7 +32,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             entity_moved.insert(entity, EntityMoved{}).expect("Unable to insert marker");
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-24-map-testing/src/player.rs

@@ -32,7 +32,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             entity_moved.insert(entity, EntityMoved{}).expect("Unable to insert marker");
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-25-bsproom-dungeons/src/player.rs

@@ -32,7 +32,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             entity_moved.insert(entity, EntityMoved{}).expect("Unable to insert marker");
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-26-bsp-interiors/src/player.rs

@@ -32,7 +32,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             entity_moved.insert(entity, EntityMoved{}).expect("Unable to insert marker");
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }
 

+ 1 - 1
chapter-27-cellular-automota/src/player.rs

@@ -32,7 +32,7 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
             entity_moved.insert(entity, EntityMoved{}).expect("Unable to insert marker");
 
             if pos.x < 0 { pos.x = 0; }
-            if pos.x > 79 { pos.y = 79; }
+            if pos.x > 79 { pos.x = 79; }
             if pos.y < 0 { pos.y = 0; }
             if pos.y > 49 { pos.y = 49; }