Organize game files into their project directory and ensure proper build configuration
Moves all game source files and assets into the 'American-Identity-Project' directory and updates the manifest to point to the 'Display' class as the main entry point. Replit-Commit-Author: Agent Replit-Commit-Session-Id: f6819c21-e85d-45ac-acde-604db2cfa4fe Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: a9500e48-7f68-408f-a5c6-28df9f59fe00 Replit-Helium-Checkpoint-Created: true
This commit is contained in:
62
American-Identity-Project/LevelLoader.java
Normal file
62
American-Identity-Project/LevelLoader.java
Normal file
@@ -0,0 +1,62 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user