diff --git a/core/src/com/dungeoncrawler/control/Controller.java b/core/src/com/dungeoncrawler/control/Controller.java index ddc3645..4732ca1 100644 --- a/core/src/com/dungeoncrawler/control/Controller.java +++ b/core/src/com/dungeoncrawler/control/Controller.java @@ -14,6 +14,7 @@ import com.dungeoncrawler.view.View; import com.dungeoncrawler.model.Dungeon; import com.dungeoncrawler.model.entities.Player; import com.dungeoncrawler.model.entities.Archer; +import com.badlogic.gdx.utils.Timer; public class Controller extends ApplicationAdapter implements InputProcessor{ SpriteBatch batch; @@ -23,7 +24,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{ Archer a; float movementX = 0f; float movementY = 0f; - + Timer t; @Override public void create(){ @@ -33,22 +34,18 @@ public class Controller extends ApplicationAdapter implements InputProcessor{ d = new Dungeon(p); a = new Archer(500, 200, 1); Gdx.input.setInputProcessor(this); + t = new Timer(); + t.scheduleTask(new Timer.Task() { + @Override + public void run() { + a.rdmMove(); + } + },0,0.1f); } @Override public void render(){ - switch((int) (Math.random() * 5)){ - case 0: //left - a.move(-3,0); - case 1: //right - a.move(3,0); - case 2: //up - a.move(0,3); - case 3: //down - a.move(0,-3); - } v.render(batch, movementX ,movementY, a.getxPos(), a.getyPos()); - } @Override diff --git a/core/src/com/dungeoncrawler/model/Entity.java b/core/src/com/dungeoncrawler/model/Entity.java index 9ac5004..2f9a255 100644 --- a/core/src/com/dungeoncrawler/model/Entity.java +++ b/core/src/com/dungeoncrawler/model/Entity.java @@ -1,7 +1,5 @@ package com.dungeoncrawler.model; -import com.dungeoncrawler.model.entities.Archer; -import com.dungeoncrawler.model.entities.Player; -import com.dungeoncrawler.model.entities.Swordsman; + public abstract class Entity { @@ -11,13 +9,18 @@ public abstract class Entity { protected int maxhp; protected int dmg; protected int lvl; + protected int movementX; + protected int movementY; public Entity(int xPos, int yPos, int lvl){ this.xPos = xPos; this.yPos = yPos; this.lvl = lvl; + this.movementX = 0; + this.movementY = 0; } + public void attack(){ @@ -33,8 +36,25 @@ public abstract class Entity { yPos = yPos + movementY; } + public void rdmMove(){ + + switch((int) (Math.random() * 5)){ + case 0: //left + move(-3 , 0); + break; + case 1: //right + move(3 , 0); + break; + case 2: //up + move(0 , 3); + break; + case 3: //down + move(0 , -3); + break; + } + } - + public int getxPos() { return xPos; } diff --git a/core/src/com/dungeoncrawler/view/Map.java b/core/src/com/dungeoncrawler/view/Map.java index 7d2ad04..7da0f30 100644 --- a/core/src/com/dungeoncrawler/view/Map.java +++ b/core/src/com/dungeoncrawler/view/Map.java @@ -14,7 +14,7 @@ import com.badlogic.gdx.maps.tiled.TiledMap; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; import com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile; - +import com.badlogic.gdx.utils.Timer; /** * * @author jonathan diff --git a/core/src/com/dungeoncrawler/view/View.java b/core/src/com/dungeoncrawler/view/View.java index dcc2216..7b93095 100644 --- a/core/src/com/dungeoncrawler/view/View.java +++ b/core/src/com/dungeoncrawler/view/View.java @@ -140,6 +140,7 @@ public class View { player.setY(player.getY()+y); archer.setX(archerX); archer.setY(archerY); + if(x == 3f){ trechts.start(); if(player.isFlipX() == true){