
Untitled
By:
TheDuceCat on
Jan 28th, 2012 | syntax:
Java | size: 0.86 KB | hits: 14 | expires: Never
package com.theducecat.blockdude;
import java.awt.Graphics2D;
import java.util.ArrayList;
public class Level {
private int width;
private int height;
private String src;
private ArrayList<ArrayList<Block>> blocks;
public Level(String src) {
this.src = src;
blocks = new LevelLoader(src).getBlocks();
}
public void draw(Graphics2D g2d) {
for (int i = 0; i < blocks.size(); i++) {
for (int j = 0; j < blocks.get(i).size(); j++) {
switch (blocks.get(i).get(j)) {
case BLOCK:
g2d.drawImage(Textures.block, j * 16, i * 16, null);
break;
case BRICK:
g2d.drawImage(Textures.brick, j * 16, i * 16, null);
break;
case DOOR:
g2d.drawImage(Textures.door, j * 16, i * 16, null);
break;
}
}
}
}
public ArrayList<ArrayList<Block>> getBlocks() {
return blocks;
}
}