WarpPI/src/main/java/org/warp/picalculator/extra/mario/MarioWorld.java

65 lines
1.3 KiB
Java
Raw Normal View History

2018-04-01 01:01:57 +02:00
package org.warp.picalculator.extra.mario;
public class MarioWorld {
private int[] spawnPoint;
private int width;
private int height;
2018-04-01 16:49:54 +02:00
private byte[][] data;
2018-04-01 01:01:57 +02:00
private MarioEvent[] events;
private MarioEntity[] entities;
/**
* @param width
* @param height
* @param data
* @param events
* @param marioEnemies
*/
2018-04-01 16:49:54 +02:00
public MarioWorld(int[] spawnPoint, int width, int height, byte[][] data, MarioEvent[] events, MarioEntity[] entities) {
2018-04-01 01:01:57 +02:00
this.spawnPoint = spawnPoint;
this.width = width;
this.height = height;
this.data = data;
this.events = events;
this.entities = entities;
}
public byte getBlockIdAt(int x, int y) {
2018-04-01 16:49:54 +02:00
int idy = (height - 1 - y);
if (idy < 0 || idy >= data.length) return 0b0;
int idx = x;
if (idx < 0 || idx >= data[0].length) return 0b0;
return data[idy][idx];
2018-04-01 01:01:57 +02:00
}
public MarioBlock getBlockAt(int x, int y) {
return new MarioBlock(x, y, getBlockIdAt(x, y));
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public void reset() {
}
public double getSpawnPointX() {
return spawnPoint[0];
}
public double getSpawnPointY() {
return spawnPoint[1];
}
public MarioEntity[] getEntities() {
return entities;
}
}