fix zombies spawn on x or y = 0

This commit is contained in:
Makussu 2024-06-11 11:12:24 +02:00
parent 0b13018263
commit 7607e80c08
2 changed files with 13 additions and 1 deletions

4
.idea/misc.xml generated
View File

@ -1,4 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" value="$PROJECT_DIR$/docs" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>

View File

@ -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);
}