From 7607e80c081d4bed48d7a183321526624fcc8618 Mon Sep 17 00:00:00 2001 From: Makussu Date: Tue, 11 Jun 2024 11:12:24 +0200 Subject: [PATCH] fix zombies spawn on x or y = 0 --- .idea/misc.xml | 4 ++++ src/Tiles.java | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 5af9c98..e77902f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,8 @@ + + + diff --git a/src/Tiles.java b/src/Tiles.java index 7abfc3d..82e2421 100644 --- a/src/Tiles.java +++ b/src/Tiles.java @@ -128,7 +128,15 @@ public class Tiles implements Drawable { void spawn_zombie() { if(num_enemies < 30) { - tileMap[rand.nextInt(80)][rand.nextInt(80)].character = new Enemy(window, 20); + int x = rand.nextInt(80); + int y = rand.nextInt(80); + if (x == 0) { + x = 1; + } + if (y == 0) { + y = 1; + } + tileMap[y][x].character = new Enemy(window, 20); num_enemies++; System.out.println("Number of Zombies: " + num_enemies); }