Doors working
This commit is contained in:
parent
74e82abbb0
commit
88580aec12
|
@ -19,8 +19,6 @@ public class DoorTile extends Tile implements Ticker {
|
|||
public DoorTile(float x, float y, ImageMap map) {
|
||||
super(Tile.DOOR, x, y);
|
||||
this.map = map;
|
||||
|
||||
Main.instance.tickerAnmelden(this, 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,10 +12,10 @@ import main.maps.Map;
|
|||
*/
|
||||
public class World extends Knoten {
|
||||
|
||||
public static final int SCALE_FACTOR = 6; // Der Basis Zoomfaktor
|
||||
public static final int SCALE_FACTOR = 4; // Der Basis Zoomfaktor
|
||||
public static final int SCALE = SCALE_FACTOR * Tile.getSize(); // Eine Gameunit ist so viele pixel lang
|
||||
|
||||
private Map currentMap; // Die Map die aktuell angezeigt werden soll.
|
||||
private ImageMap currentMap; // Die Map die aktuell angezeigt werden soll.
|
||||
private ArrayList<ImageMap> dungeon;
|
||||
|
||||
private Player player;
|
||||
|
@ -27,6 +27,7 @@ public class World extends Knoten {
|
|||
ImageMap start = new ImageMap("/res/images/maps/map2.png");
|
||||
dungeon.add(start);
|
||||
currentMap = start;
|
||||
currentMap.start();
|
||||
|
||||
start.generate(dungeon, DoorTile.BOTTOM);
|
||||
|
||||
|
@ -49,12 +50,13 @@ public class World extends Knoten {
|
|||
}
|
||||
|
||||
public void changeMap(DoorTile door) {
|
||||
currentMap.stop();
|
||||
currentMap.entfernen(player.actionFigur);
|
||||
entfernen(currentMap);
|
||||
System.out.println(door);
|
||||
currentMap = door.getConnectedDoor().getMap();
|
||||
currentMap.add(player.actionFigur);
|
||||
add(currentMap);
|
||||
currentMap.start();
|
||||
door.getConnectedDoor().waitForLeave();
|
||||
player.setPos(door.getConnectedDoor().posX + 0.5f, door.getConnectedDoor().posY + 0.5f);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@ public class Player extends LivingEntity {
|
|||
spriteScale = 0.8f;
|
||||
posX = 7.5f;
|
||||
posY = 5.5f;
|
||||
|
||||
// XXX
|
||||
accelleration = 0.05f;
|
||||
|
||||
// unterschiedliche Animationsgeschwindigkeiten
|
||||
// für idle
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
|||
import javax.imageio.ImageIO;
|
||||
|
||||
import main.DoorTile;
|
||||
import main.Main;
|
||||
import main.Tile;
|
||||
|
||||
public class ImageMap extends Map {
|
||||
|
@ -22,6 +23,15 @@ public class ImageMap extends Map {
|
|||
public DoorTile leftDoor;
|
||||
public DoorTile rightDoor;
|
||||
public DoorTile bottomDoor;
|
||||
|
||||
private static ImageMap[] maps;
|
||||
|
||||
static {
|
||||
maps = new ImageMap[8];
|
||||
for (int i = 0; i < maps.length; i++) {
|
||||
maps[i] = new ImageMap("/res/images/maps/map" + (i + 1) + ".png");
|
||||
}
|
||||
}
|
||||
|
||||
public ImageMap(String path) {
|
||||
super(15, 11);
|
||||
|
@ -90,7 +100,6 @@ public class ImageMap extends Map {
|
|||
map = nextMap();
|
||||
} while (!connectDoors(topDoor, map));
|
||||
dungeon.add(map);
|
||||
System.out.println("TOP");
|
||||
map.generate(dungeon, DoorTile.BOTTOM);
|
||||
}
|
||||
if (bottomDoor != null && fromSide != DoorTile.BOTTOM) {
|
||||
|
@ -99,7 +108,6 @@ public class ImageMap extends Map {
|
|||
map = nextMap();
|
||||
} while (!connectDoors(bottomDoor, map));
|
||||
dungeon.add(map);
|
||||
System.out.println("BOTTOM");
|
||||
map.generate(dungeon, DoorTile.TOP);
|
||||
}
|
||||
if (leftDoor != null && fromSide != DoorTile.LEFT) {
|
||||
|
@ -108,7 +116,6 @@ public class ImageMap extends Map {
|
|||
map = nextMap();
|
||||
} while (!connectDoors(leftDoor, map));
|
||||
dungeon.add(map);
|
||||
System.out.println("LEFT");
|
||||
map.generate(dungeon, DoorTile.RIGHT);
|
||||
}
|
||||
if (rightDoor != null && fromSide != DoorTile.RIGHT) {
|
||||
|
@ -117,14 +124,13 @@ public class ImageMap extends Map {
|
|||
map = nextMap();
|
||||
} while (!connectDoors(rightDoor, map));
|
||||
dungeon.add(map);
|
||||
System.out.println("RIGHT");
|
||||
map.generate(dungeon, DoorTile.LEFT);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
private ImageMap nextMap() {
|
||||
return new ImageMap("/res/images/maps/map" + ((int) (Math.random() * 4) + 5) + ".png");
|
||||
return new ImageMap("/res/images/maps/map" + ((int) (Math.random() * 6) + 3) + ".png");
|
||||
}
|
||||
|
||||
private boolean connectDoors(DoorTile door, ImageMap otherMap) {
|
||||
|
@ -135,8 +141,6 @@ public class ImageMap extends Map {
|
|||
}
|
||||
door.setConnectedDoor(otherMap.bottomDoor);
|
||||
otherMap.bottomDoor.setConnectedDoor(door);
|
||||
System.out.println(door.getConnectedDoor());
|
||||
System.out.println(otherMap.bottomDoor.getConnectedDoor());
|
||||
return true;
|
||||
case DoorTile.BOTTOM:
|
||||
if (otherMap.topDoor == null) {
|
||||
|
@ -162,4 +166,34 @@ public class ImageMap extends Map {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (topDoor != null) {
|
||||
Main.instance.manager.anmelden(topDoor, 50);
|
||||
}
|
||||
if (bottomDoor != null) {
|
||||
Main.instance.manager.anmelden(bottomDoor, 50);
|
||||
}
|
||||
if (leftDoor != null) {
|
||||
Main.instance.manager.anmelden(leftDoor, 50);
|
||||
}
|
||||
if (rightDoor != null) {
|
||||
Main.instance.manager.anmelden(rightDoor, 50);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (topDoor != null) {
|
||||
Main.instance.manager.abmelden(topDoor);
|
||||
}
|
||||
if (bottomDoor != null) {
|
||||
Main.instance.manager.abmelden(bottomDoor);
|
||||
}
|
||||
if (leftDoor != null) {
|
||||
Main.instance.manager.abmelden(leftDoor);
|
||||
}
|
||||
if (rightDoor != null) {
|
||||
Main.instance.manager.abmelden(rightDoor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue