Refactor some code and create new Forrest map
This commit is contained in:
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
BIN
maps/551e1afc-9cda-4d9f-8817-bfd831fc0a75.dat
Normal file
BIN
maps/551e1afc-9cda-4d9f-8817-bfd831fc0a75.dat
Normal file
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
BASE Demo*com.bartlomiejpluta.demo.runner.DemoRunner`
|
BASE Demo*com.bartlomiejpluta.demo.runner.DemoRunner`
|
||||||
$f845355e-b9ad-4884-a217-dd3a4c18a3fa(f845355e-b9ad-4884-a217-dd3a4c18a3fa.datForrest Temple"d
|
$f845355e-b9ad-4884-a217-dd3a4c18a3fa(f845355e-b9ad-4884-a217-dd3a4c18a3fa.datForrest TempleY
|
||||||
|
$551e1afc-9cda-4d9f-8817-bfd831fc0a75(551e1afc-9cda-4d9f-8817-bfd831fc0a75.datForrest"d
|
||||||
$d314b030-f865-432e-a356-3845f8aac7bc(d314b030-f865-432e-a356-3845f8aac7bc.pngForrest Temple ](2Z
|
$d314b030-f865-432e-a356-3845f8aac7bc(d314b030-f865-432e-a356-3845f8aac7bc.pngForrest Temple ](2Z
|
||||||
$0dcbaf26-d634-4ca8-9691-7a8ff966f702(0dcbaf26-d634-4ca8-9691-7a8ff966f702.pngGaro (2\
|
$0dcbaf26-d634-4ca8-9691-7a8ff966f702(0dcbaf26-d634-4ca8-9691-7a8ff966f702.pngGaro (2\
|
||||||
$61393836-8127-4277-853f-87b48022ae43(61393836-8127-4277-853f-87b48022ae43.pngCorpse (2^
|
$61393836-8127-4277-853f-87b48022ae43(61393836-8127-4277-853f-87b48022ae43.pngCorpse (2^
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import com.bartlomiejpluta.base.api.icon.Icon;
|
|||||||
|
|
||||||
import com.bartlomiejpluta.base.lib.camera.*;
|
import com.bartlomiejpluta.base.lib.camera.*;
|
||||||
|
|
||||||
import com.bartlomiejpluta.base.util.world.CharacterSpawner;
|
import com.bartlomiejpluta.base.util.world.*;
|
||||||
|
|
||||||
import com.bartlomiejpluta.demo.runner.DemoRunner;
|
import com.bartlomiejpluta.demo.runner.DemoRunner;
|
||||||
import com.bartlomiejpluta.demo.entity.*;
|
import com.bartlomiejpluta.demo.entity.*;
|
||||||
@@ -34,7 +34,6 @@ public abstract class BaseMapHandler implements MapHandler {
|
|||||||
protected Player player;
|
protected Player player;
|
||||||
protected ObjectLayer mainLayer;
|
protected ObjectLayer mainLayer;
|
||||||
protected CameraController cameraController;
|
protected CameraController cameraController;
|
||||||
protected final List<CharacterSpawner> spawners = new LinkedList<>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Context context, GameMap map) {
|
public void onCreate(Context context, GameMap map) {
|
||||||
@@ -75,13 +74,13 @@ public abstract class BaseMapHandler implements MapHandler {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(input.isKeyPressed(Key.KEY_DOWN)) {
|
if(input.isKeyPressed(Key.KEY_DOWN)) {
|
||||||
mainLayer.pushMovement(player.prepareMovement(Direction.DOWN));
|
player.getLayer().pushMovement(player.prepareMovement(Direction.DOWN));
|
||||||
} else if(input.isKeyPressed(Key.KEY_UP)) {
|
} else if(input.isKeyPressed(Key.KEY_UP)) {
|
||||||
mainLayer.pushMovement(player.prepareMovement(Direction.UP));
|
player.getLayer().pushMovement(player.prepareMovement(Direction.UP));
|
||||||
} else if(input.isKeyPressed(Key.KEY_LEFT)) {
|
} else if(input.isKeyPressed(Key.KEY_LEFT)) {
|
||||||
mainLayer.pushMovement(player.prepareMovement(Direction.LEFT));
|
player.getLayer().pushMovement(player.prepareMovement(Direction.LEFT));
|
||||||
} else if(input.isKeyPressed(Key.KEY_RIGHT)) {
|
} else if(input.isKeyPressed(Key.KEY_RIGHT)) {
|
||||||
mainLayer.pushMovement(player.prepareMovement(Direction.RIGHT));
|
player.getLayer().pushMovement(player.prepareMovement(Direction.RIGHT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,40 +88,47 @@ public abstract class BaseMapHandler implements MapHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void update(Context context, GameMap map, float dt) {
|
public void update(Context context, GameMap map, float dt) {
|
||||||
cameraController.update();
|
cameraController.update();
|
||||||
for(var spawner : spawners) {
|
|
||||||
spawner.update(dt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enemy enemy(@NonNull String id) {
|
public Enemy enemy(@NonNull String id) {
|
||||||
return new Enemy(id);
|
return new Enemy(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enemy enemy(int x, int y, @NonNull String id) {
|
public Enemy enemy(ObjectLayer layer, int x, int y, @NonNull String id) {
|
||||||
var enemy = new Enemy(id);
|
var enemy = new Enemy(id);
|
||||||
enemy.setCoordinates(x, y);
|
enemy.setCoordinates(x, y);
|
||||||
mainLayer.addEntity(enemy);
|
layer.addEntity(enemy);
|
||||||
return enemy;
|
return enemy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapObject object(int x, int y, @NonNull String id) {
|
public MapObject object(ObjectLayer layer, int x, int y, @NonNull String id) {
|
||||||
var object = new MapObject(id);
|
var object = new MapObject(id);
|
||||||
object.setCoordinates(x, y);
|
object.setCoordinates(x, y);
|
||||||
mainLayer.addEntity(object);
|
layer.addEntity(object);
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CharacterSpawner spawner(int x, int y, ObjectLayer layer) {
|
public CharacterSpawner spawner(ObjectLayer layer, int x, int y) {
|
||||||
var spawner = new CharacterSpawner(x, y, context, map, layer).trackEntities(EnemyDiedEvent.TYPE);
|
var spawner = new CharacterSpawner().trackEntities(EnemyDiedEvent.TYPE);
|
||||||
this.spawners.add(spawner);
|
spawner.setCoordinates(x, y);
|
||||||
|
layer.addEntity(spawner);
|
||||||
return spawner;
|
return spawner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void icon(int x, int y, String iconSetUid, int row, int column) {
|
public Icon icon(ObjectLayer layer, int x, int y, String iconSetUid, int row, int column) {
|
||||||
var icon = context.createIcon(iconSetUid, row, column);
|
var icon = context.createIcon(iconSetUid, row, column);
|
||||||
icon.setScale(1f);
|
icon.setScale(1f);
|
||||||
icon.setZIndex(-1);
|
icon.setZIndex(-1);
|
||||||
icon.setCoordinates(x, y);
|
icon.setCoordinates(x, y);
|
||||||
mainLayer.addEntity(icon);
|
layer.addEntity(icon);
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Warp warp(ObjectLayer layer, int x, int y, String targetMap, String targetLayer, int targetX, int targetY) {
|
||||||
|
var warp = new Warp(A.maps.get(targetMap).uid, A.maps.getLayer(targetMap, targetLayer), targetX, targetY);
|
||||||
|
warp.setEntity(player);
|
||||||
|
warp.setCoordinates(x, y);
|
||||||
|
layer.addEntity(warp);
|
||||||
|
return warp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.bartlomiejpluta.demo.map;
|
||||||
|
|
||||||
|
import com.bartlomiejpluta.base.api.context.Context;
|
||||||
|
import com.bartlomiejpluta.base.api.input.Input;
|
||||||
|
import com.bartlomiejpluta.base.api.map.model.GameMap;
|
||||||
|
import com.bartlomiejpluta.base.api.map.handler.MapHandler;
|
||||||
|
import com.bartlomiejpluta.base.api.screen.Screen;
|
||||||
|
|
||||||
|
public class ForrestHandler extends BaseMapHandler {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,6 +7,8 @@ import com.bartlomiejpluta.base.api.screen.Screen;
|
|||||||
|
|
||||||
public class ForrestTempleHandler extends BaseMapHandler {
|
public class ForrestTempleHandler extends BaseMapHandler {
|
||||||
public static final String UID = "f845355e-b9ad-4884-a217-dd3a4c18a3fa";
|
public static final String UID = "f845355e-b9ad-4884-a217-dd3a4c18a3fa";
|
||||||
|
public static final A.maps.GameMapAsset_Layers_ForrestTemple LAYERS = A.maps.forrest_temple.layers;
|
||||||
|
|
||||||
public static final int MAIN_LAYER = 4;
|
public static final int MAIN_LAYER = 4;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ public class DemoRunner implements GameRunner {
|
|||||||
|
|
||||||
private void configureScreen() {
|
private void configureScreen() {
|
||||||
var resolution = screen.getCurrentResolution();
|
var resolution = screen.getCurrentResolution();
|
||||||
screen.setSize(800, 600);
|
screen.setSize(1800, 1000);
|
||||||
screen.setPosition((resolution.x() - 800)/2, (resolution.y() - 600)/2);
|
screen.setPosition((resolution.x() - 1800)/2, (resolution.y() - 1000)/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureCamera() {
|
private void configureCamera() {
|
||||||
@@ -79,7 +79,6 @@ public class DemoRunner implements GameRunner {
|
|||||||
this.player.setSpeed(4f);
|
this.player.setSpeed(4f);
|
||||||
this.player.setAnimationSpeed(2f);
|
this.player.setAnimationSpeed(2f);
|
||||||
this.player.setBlocking(true);
|
this.player.setBlocking(true);
|
||||||
this.player.setCoordinates(14, 11);
|
|
||||||
this.player.setWeapon(new RangedWeapon("wooden_bow"));
|
this.player.setWeapon(new RangedWeapon("wooden_bow"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,8 +86,9 @@ public class DemoRunner implements GameRunner {
|
|||||||
menu.closeAll();
|
menu.closeAll();
|
||||||
menu.enableGameMenu();
|
menu.enableGameMenu();
|
||||||
resetPlayer();
|
resetPlayer();
|
||||||
context.openMap(A.maps.forrest_temple.uid);
|
context.openMap(A.maps.forrest.uid);
|
||||||
context.getMap().getObjectLayer(ForrestTempleHandler.MAIN_LAYER).addEntity(this.player);
|
context.getMap().getObjectLayer(A.maps.forrest.layers.main).addEntity(this.player);
|
||||||
|
player.setCoordinates(5, 36);
|
||||||
context.resume();
|
context.resume();
|
||||||
hud.show();
|
hud.show();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user