Files
chess/American-Identity-Project/LevelLoader.java
CoolGuy27 3658610a9f Update game to use the correct Java version and directory
Updated the project configuration to use Java 21 and run the game from the correct directory, resolving previous Java version conflicts and ensuring proper execution.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: f6819c21-e85d-45ac-acde-604db2cfa4fe
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: ed832e25-fc86-4753-8cfc-80cfabc64a02
Replit-Helium-Checkpoint-Created: true
2026-04-20 18:57:28 +00:00

63 lines
1.8 KiB
Java

import java.io.*;
import java.util.*;
public class LevelLoader {
static int enemyWidth[] = {0, 31, 20, 20, 20, 20, 20, 29, 29, 20, 20};
static int enemyHeight[] = {0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20};
public static void load(
int tileSize,
ArrayList<Collidable> collidables,
ArrayList<Collectable> collectables,
ArrayList<Enemy> enemies,
Flag flag,
Player player,
int level)
throws IOException {
collidables.clear();
collectables.clear();
enemies.clear();
/* left wall */ collidables.add(new Brick(-20, 0, 20, 2000));
BufferedReader br = new BufferedReader(new FileReader("Levels/level" + level + ".txt"));
String line;
int row = 0;
while ((line = br.readLine()) != null) {
for (int col = 0; col < line.length(); col++) {
char c = line.charAt(col);
int x = col * tileSize;
int y = row * tileSize;
switch (c) {
case 'B':
collidables.add(new Brick(x, y, tileSize, tileSize));
break;
case 'Q':
collidables.add(new PowerBrick(x, y, tileSize, tileSize, 1));
break;
case 'A':
collectables.add(new Amendment(x, y, tileSize, tileSize));
break;
case 'F':
flag.setPosition(x, y, tileSize, tileSize);
break;
case 'P':
player.x = x;
player.y = y;
player.rect.x = x;
player.rect.y = y;
break;
case 'E':
enemies.add(new Enemy(x, y, enemyWidth[level], enemyHeight[level], level));
break;
case 'X':
collidables.add(new InvisibleTile(x, y, tileSize, tileSize));
break;
}
}
row++;
}
br.close();
}
}