starting hauling jobs
parent
913a455e6d
commit
47099b3057
BIN
res/textures.png
BIN
res/textures.png
Binary file not shown.
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.1 KiB |
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import xyz.valnet.engine.graphics.Drawing;
|
||||
import xyz.valnet.engine.graphics.Sprite;
|
||||
import xyz.valnet.engine.math.Vector2i;
|
||||
import xyz.valnet.engine.math.Vector4f;
|
||||
import xyz.valnet.engine.scenegraph.GameObject;
|
||||
import xyz.valnet.hadean.gameobjects.Camera;
|
||||
|
|
@ -29,6 +30,10 @@ public class Tile extends GameObject {
|
|||
this.y = y;
|
||||
}
|
||||
|
||||
public Vector2i getCoords() {
|
||||
return new Vector2i(x, y);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
camera = get(Camera.class);
|
||||
|
||||
|
|
@ -39,6 +44,13 @@ public class Tile extends GameObject {
|
|||
}
|
||||
}
|
||||
|
||||
public void placeThing(ITileThing thing) {
|
||||
stuff.add(thing);
|
||||
if(thing instanceof GameObject) {
|
||||
add((GameObject)thing);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float dTime) {
|
||||
for(ITileThing thing : stuff) {
|
||||
|
|
@ -58,7 +70,7 @@ public class Tile extends GameObject {
|
|||
|
||||
@Override
|
||||
public void render() {
|
||||
Drawing.setLayer(2f);
|
||||
Drawing.setLayer(Layers.TILES);
|
||||
Assets.flat.pushColor(color);
|
||||
camera.draw(sprite, x, y);
|
||||
Assets.flat.popColor();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package xyz.valnet.hadean.gameobjects;
|
||||
|
||||
public interface ITransferrable {
|
||||
|
||||
}
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
package xyz.valnet.hadean.gameobjects;
|
||||
|
||||
import xyz.valnet.engine.graphics.Drawing;
|
||||
import xyz.valnet.engine.math.Vector2i;
|
||||
import xyz.valnet.engine.math.Vector4f;
|
||||
import xyz.valnet.engine.scenegraph.GameObject;
|
||||
import xyz.valnet.hadean.Layers;
|
||||
import xyz.valnet.hadean.util.Action;
|
||||
import xyz.valnet.hadean.util.Assets;
|
||||
|
||||
public class Log extends GameObject implements ITileThing, ISelectable {
|
||||
public class Log extends GameObject implements ITileThing, ISelectable, ITransferrable, IWorkable {
|
||||
|
||||
private Camera camera;
|
||||
|
||||
|
|
@ -59,5 +60,29 @@ public class Log extends GameObject implements ITileThing, ISelectable {
|
|||
public String details() {
|
||||
return "A fat log";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWork() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2i[] getWorablePositions() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2i getLocation() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import xyz.valnet.hadean.util.Assets;
|
|||
|
||||
public class Pawn extends GameObject implements ISelectable {
|
||||
|
||||
private ITransferrable carrying = null;
|
||||
|
||||
private float x = 0.5f + (int)(Math.random() * Terrain.WORLD_SIZE), y = 0.5f + (int)(Math.random() * Terrain.WORLD_SIZE);
|
||||
|
||||
private float counter = 0;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
package xyz.valnet.hadean.gameobjects;
|
||||
|
||||
import xyz.valnet.engine.graphics.Drawing;
|
||||
import xyz.valnet.engine.math.Vector4f;
|
||||
import xyz.valnet.engine.scenegraph.GameObject;
|
||||
import xyz.valnet.hadean.Layers;
|
||||
import xyz.valnet.hadean.util.Action;
|
||||
import xyz.valnet.hadean.util.Assets;
|
||||
|
||||
public class Stockpile extends GameObject implements ITileThing, ISelectable {
|
||||
|
||||
private int x, y;
|
||||
private Camera camera;
|
||||
|
||||
public Stockpile(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
camera = get(Camera.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
Drawing.setLayer(Layers.GROUND);
|
||||
camera.draw(Assets.stockpile, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWalkable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRemove() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector4f getWorldBox() {
|
||||
return new Vector4f(x, y, x+1, y+1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action[] getActions() {
|
||||
return new Action[] {};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAction(Action action) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String details() {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package xyz.valnet.hadean.gameobjects;
|
||||
|
||||
import xyz.valnet.engine.math.Vector2i;
|
||||
import xyz.valnet.engine.scenegraph.GameObject;
|
||||
import xyz.valnet.hadean.Tile;
|
||||
import xyz.valnet.hadean.pathfinding.IPathable;
|
||||
|
|
@ -22,11 +23,22 @@ public class Terrain extends GameObject implements IPathable {
|
|||
add(tiles[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
Tile randomTile = getRandomTile();
|
||||
Vector2i coords = randomTile.getCoords();
|
||||
Stockpile stockpile = new Stockpile(coords.x, coords.y);
|
||||
randomTile.placeThing(stockpile);
|
||||
|
||||
camera = get(Camera.class);
|
||||
|
||||
camera.focus(WORLD_SIZE / 2, WORLD_SIZE / 2);
|
||||
}
|
||||
|
||||
private Tile getRandomTile() {
|
||||
int x = (int) Math.floor(Math.random() * WORLD_SIZE);
|
||||
int y = (int) Math.floor(Math.random() * WORLD_SIZE);
|
||||
return getTile(x, y);
|
||||
}
|
||||
|
||||
public Tile getTile(int x, int y) {
|
||||
return tiles[x][y];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public class Assets {
|
|||
public static final Sprite log;
|
||||
public static final Sprite lilAxe;
|
||||
public static final Sprite haulArrow;
|
||||
public static final Sprite stockpile;
|
||||
|
||||
public static final SimpleShader flat;
|
||||
|
||||
|
|
@ -51,6 +52,7 @@ public class Assets {
|
|||
log = new Sprite(atlas, 48, 96, 16, 16);
|
||||
lilAxe = new Sprite(atlas, 64, 88, 16, 16);
|
||||
haulArrow = new Sprite(atlas, 80, 88, 16, 16);
|
||||
stockpile = new Sprite(atlas, 40, 64, 16, 16);
|
||||
|
||||
Map<Character, Sprite> charset = new HashMap<Character, Sprite>();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue