From 29d35fc1eb1699d9757d4528f00254ff06406263 Mon Sep 17 00:00:00 2001 From: Jonathan Hager Date: Fri, 1 May 2020 12:54:38 +0200 Subject: [PATCH 1/2] Gegner laufen auf Player zu --- .../dungeoncrawler/control/Controller.java | 5 +- core/src/com/dungeoncrawler/model/Entity.java | 48 +++++----------- .../dungeoncrawler/model/entities/Archer.java | 17 ++++-- .../dungeoncrawler/model/entities/Arrow.java | 5 ++ .../dungeoncrawler/model/entities/Player.java | 5 ++ .../model/entities/Swordsman.java | 55 +++++++++++++++++-- .../com/dungeoncrawler/view/GameScreen.java | 10 ++-- 7 files changed, 93 insertions(+), 52 deletions(-) diff --git a/core/src/com/dungeoncrawler/control/Controller.java b/core/src/com/dungeoncrawler/control/Controller.java index 921b460..4ee8893 100644 --- a/core/src/com/dungeoncrawler/control/Controller.java +++ b/core/src/com/dungeoncrawler/control/Controller.java @@ -104,11 +104,12 @@ public class Controller extends ApplicationAdapter implements InputProcessor{ public void run() { for(int i = 0; i < d.getCurrentEntities().length; i++){ if(d.getCurrentEntities()[i] != null){ - d.getCurrentEntities()[i].randomMove(roomX, roomY); + //d.getCurrentEntities()[i].randomMove(roomX, roomY); + d.getCurrentEntities()[i].move((int) d.getPlayer().getxPos(), (int) d.getPlayer().getyPos()); } } } - },0,1f); + },0, 0.03f); } diff --git a/core/src/com/dungeoncrawler/model/Entity.java b/core/src/com/dungeoncrawler/model/Entity.java index 3c68e4d..059a4b7 100644 --- a/core/src/com/dungeoncrawler/model/Entity.java +++ b/core/src/com/dungeoncrawler/model/Entity.java @@ -1,8 +1,5 @@ package com.dungeoncrawler.model; -import com.badlogic.gdx.utils.Timer; - - public abstract class Entity { protected float xPos; @@ -14,7 +11,7 @@ public abstract class Entity { protected float movementX; protected float movementY; protected int id; - protected int facing; + protected int direction; protected Inventory inv; @@ -25,16 +22,9 @@ public abstract class Entity { this.lvl = lvl; this.movementX = 0; this.movementY = 0; - this.facing = 2; - - - - - + this.direction = 2; } - - public void attack(){ } @@ -62,24 +52,13 @@ public abstract class Entity { movementY = 0; } - public void rdmMove(){ - - } - - public int direction(){ // returns direction the entity is facing depending on its movement - if(movementX == -3f){ // TIS IS SHIT - NEED REWORK - facing = 3; - } - else if(movementX == 3f){ - facing = 1; - } - else if(movementY == 3f){ - facing = 0; + public void updateDirection(){ + if(movementX > 1){ + direction = 1; } - else if(movementY == -3f){ - facing = 2; + else if(movementX < -1){ + direction = 0; } - return facing; } @@ -152,15 +131,18 @@ public abstract class Entity { return this.id; } - public int getFacing(){ - return facing; + public int getDirection(){ + return direction; } - public void setFacing(int facing){ - this.facing = facing; + + public void setDirection(int direction){ + this.direction = direction; } + public void randomMove(int x, int y){ + } - + abstract public void move(int xPosPlayer, int yPosPlayer); } \ No newline at end of file diff --git a/core/src/com/dungeoncrawler/model/entities/Archer.java b/core/src/com/dungeoncrawler/model/entities/Archer.java index 32490df..ee2bf25 100644 --- a/core/src/com/dungeoncrawler/model/entities/Archer.java +++ b/core/src/com/dungeoncrawler/model/entities/Archer.java @@ -17,7 +17,7 @@ public class Archer extends Entity{ this.maxhp = 5*lvl; this.hp = this.maxhp; - this.facing = 2; + this.direction = 2; this.dmg = 3*lvl; this.id = 0; // TODO: Sinnvolle Werte finden @@ -28,12 +28,12 @@ public class Archer extends Entity{ tleft = new Timer(); isRunning = false; timerRuns = 0; - facing = 2; + direction = 2; tup.scheduleTask(new Timer.Task() { @Override public void run() { - setFacing(0); + setDirection(0); setyPos(getyPos() + 1f); setTimerRuns(getTimerRuns() + 1); if(getTimerRuns() >= 48){ @@ -47,7 +47,7 @@ public class Archer extends Entity{ tright.scheduleTask(new Timer.Task() { @Override public void run() { - setFacing(1); + setDirection(1); setxPos(getxPos() + 1f); setTimerRuns(getTimerRuns() + 1); if(getTimerRuns() >= 48){ @@ -61,7 +61,7 @@ public class Archer extends Entity{ tdown.scheduleTask(new Timer.Task() { @Override public void run() { - setFacing(2); + setDirection(2); setyPos(getyPos() - 1f); setTimerRuns(getTimerRuns() + 1); if(getTimerRuns() >= 48){ @@ -75,7 +75,7 @@ public class Archer extends Entity{ tleft.scheduleTask(new Timer.Task() { @Override public void run() { - setFacing(3); + setDirection(3); setxPos(getxPos() - 1f); setTimerRuns(getTimerRuns() + 1); @@ -152,6 +152,11 @@ public class Archer extends Entity{ public void setTimerRuns(int n){ timerRuns = n; } + + @Override + public void move(int xPosPlayer, int yPosPlayer) { + // Nothing + } diff --git a/core/src/com/dungeoncrawler/model/entities/Arrow.java b/core/src/com/dungeoncrawler/model/entities/Arrow.java index a40ade0..698bacb 100644 --- a/core/src/com/dungeoncrawler/model/entities/Arrow.java +++ b/core/src/com/dungeoncrawler/model/entities/Arrow.java @@ -84,4 +84,9 @@ public class Arrow extends Entity{ public float getyStart(){ return yStart; } + + @Override + public void move(int xPosPlayer, int yPosPlayer) { + // Nothing + } } diff --git a/core/src/com/dungeoncrawler/model/entities/Player.java b/core/src/com/dungeoncrawler/model/entities/Player.java index 4e9c7d7..91f0359 100644 --- a/core/src/com/dungeoncrawler/model/entities/Player.java +++ b/core/src/com/dungeoncrawler/model/entities/Player.java @@ -34,5 +34,10 @@ public class Player extends Entity { public Inventory getInv(){ return inv; } + + @Override + public void move(int xPosPlayer, int yPosPlayer) { + // Nothing + } } diff --git a/core/src/com/dungeoncrawler/model/entities/Swordsman.java b/core/src/com/dungeoncrawler/model/entities/Swordsman.java index 4eaf03a..14e2ed2 100644 --- a/core/src/com/dungeoncrawler/model/entities/Swordsman.java +++ b/core/src/com/dungeoncrawler/model/entities/Swordsman.java @@ -16,7 +16,7 @@ public class Swordsman extends Entity { this.maxhp = 5*lvl; this.hp = this.maxhp; - this.facing = 2; + this.direction = 2; this.dmg = 3*lvl; this.id = 1; // TODO: Sinnvolle Werte finden @@ -26,13 +26,13 @@ public class Swordsman extends Entity { tleft = new Timer(); isRunning = false; timerRuns = 0; - facing = 2; + direction = 2; tup.scheduleTask(new Timer.Task() { @Override public void run() { - setFacing(0); + setDirection(0); setyPos(getyPos() + 1f); setTimerRuns(getTimerRuns() + 1); if(getTimerRuns() >= 48){ @@ -46,7 +46,7 @@ public class Swordsman extends Entity { tright.scheduleTask(new Timer.Task() { @Override public void run() { - setFacing(1); + setDirection(1); setxPos(getxPos() + 1f); setTimerRuns(getTimerRuns() + 1); if(getTimerRuns() >= 48){ @@ -60,7 +60,7 @@ public class Swordsman extends Entity { tdown.scheduleTask(new Timer.Task() { @Override public void run() { - setFacing(2); + setDirection(2); setyPos(getyPos() - 1f); setTimerRuns(getTimerRuns() + 1); if(getTimerRuns() >= 48){ @@ -74,7 +74,7 @@ public class Swordsman extends Entity { tleft.scheduleTask(new Timer.Task() { @Override public void run() { - setFacing(3); + setDirection(3); setxPos(getxPos() - 1f); setTimerRuns(getTimerRuns() + 1); @@ -148,5 +148,48 @@ public class Swordsman extends Entity { timerRuns = n; } + @Override + public void move(int xPosPlayer, int yPosPlayer){ + int deltaX = xPosPlayer - (int) xPos; + int deltaY = yPosPlayer - (int) yPos; + + double alpha; + if(deltaX == 0 && deltaY >= 0){ + alpha = Math.PI / 2; + } + else if(deltaX == 0 && deltaY < 0){ + alpha = Math.PI / -2; + } + else{ + alpha = Math.abs(Math.atan(deltaY / deltaX)); + + if(deltaX < 0 && deltaY < 0){ + alpha = Math.PI + alpha; + } + else if(deltaX < 0 && deltaY > 0){ + alpha = Math.PI - alpha; + } + else if(deltaX > 0 && deltaY < 0){ + alpha = 2*Math.PI - alpha; + } + } + + movementX = (int) (3 * Math.cos(alpha)); + movementY = (int) (3 * Math.sin(alpha)); + + /* + if(deltaX < 0 || deltaY < 0){ + movementX *= -1; + movementY *= -1; + } + else if(deltaY < 0){ + movementX *= -1; + } + */ + + xPos += movementX; + yPos += movementY; + } + } diff --git a/core/src/com/dungeoncrawler/view/GameScreen.java b/core/src/com/dungeoncrawler/view/GameScreen.java index bb0a98c..b048009 100644 --- a/core/src/com/dungeoncrawler/view/GameScreen.java +++ b/core/src/com/dungeoncrawler/view/GameScreen.java @@ -279,7 +279,7 @@ public class GameScreen { //DRAW'T JEDES ENTITY - prueft vorher ob vorhanden for(int i = 0; i < e.length; i++){ if(e[i] != null){ - switch(e[i].getFacing()){ + switch(e[i].getDirection()){ case -1: break; case 0: @@ -355,7 +355,7 @@ public class GameScreen { public Entity[] playerAttack(Entity e[], Player p, SpriteBatch batch){ - if(p.direction() == 0){ + if(p.getDirection() == 0){ Texture attackTexture = new Texture("sprites/AttackHori.png"); Sprite attackSprite = new Sprite(attackTexture); attackSprite.setX(p.getxPos() - 8f); @@ -376,7 +376,7 @@ public class GameScreen { } } } - else if(p.direction() == 1){ + else if(p.getDirection()== 1){ Texture attackTexture = new Texture("sprites/AttackVert.png"); Sprite attackSprite = new Sprite(attackTexture); attackSprite.setX(p.getxPos()+ 32f); @@ -396,7 +396,7 @@ public class GameScreen { } } } - else if(p.direction() == 2){ + else if(p.getDirection()== 2){ Texture attackTexture = new Texture("sprites/AttackHori.png"); Sprite attackSprite = new Sprite(attackTexture); attackSprite.setX(p.getxPos() - 8f); @@ -416,7 +416,7 @@ public class GameScreen { } } } - else if(p.direction() == 3){ + else if(p.getDirection()== 3){ Texture attackTexture = new Texture("sprites/AttackVert.png"); Sprite attackSprite = new Sprite(attackTexture); attackSprite.setX(p.getxPos() - 32f); From 5e4265151d2c986d103ceec38567aa470d24f811 Mon Sep 17 00:00:00 2001 From: Jonathan Hager Date: Fri, 1 May 2020 13:59:17 +0200 Subject: [PATCH 2/2] Gegner Kollisionen funktionieren --- .../dungeoncrawler/control/Controller.java | 39 ++++- core/src/com/dungeoncrawler/model/Entity.java | 11 +- .../dungeoncrawler/model/entities/Archer.java | 135 ---------------- .../dungeoncrawler/model/entities/Arrow.java | 57 +------ .../dungeoncrawler/model/entities/Player.java | 2 - .../model/entities/Swordsman.java | 145 +----------------- .../com/dungeoncrawler/view/GameScreen.java | 6 +- 7 files changed, 47 insertions(+), 348 deletions(-) diff --git a/core/src/com/dungeoncrawler/control/Controller.java b/core/src/com/dungeoncrawler/control/Controller.java index 4ee8893..a3bb610 100644 --- a/core/src/com/dungeoncrawler/control/Controller.java +++ b/core/src/com/dungeoncrawler/control/Controller.java @@ -13,6 +13,7 @@ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.maps.MapLayers; +import com.badlogic.gdx.maps.MapObject; import com.badlogic.gdx.maps.MapObjects; import com.badlogic.gdx.maps.objects.RectangleMapObject; import com.badlogic.gdx.math.Intersector; @@ -104,9 +105,41 @@ public class Controller extends ApplicationAdapter implements InputProcessor{ public void run() { for(int i = 0; i < d.getCurrentEntities().length; i++){ if(d.getCurrentEntities()[i] != null){ - //d.getCurrentEntities()[i].randomMove(roomX, roomY); - d.getCurrentEntities()[i].move((int) d.getPlayer().getxPos(), (int) d.getPlayer().getyPos()); - } + if(m != null){ + // Gets the collisions relevant sprites + MapObjects mapObjects = m.getM().getMaps()[level][roomPosX][roomPosY].getMap().getLayers().get(0).getObjects(); + Rectangle playerSprite = m.getPlayer().getCollisionSprite(); + + Entity temp = d.getCurrentEntities()[i]; + + int x = (int) temp.getxPos(); + int y = (int) temp.getyPos(); + + d.getCurrentEntities()[i].move((int) d.getPlayer().getxPos(), (int) d.getPlayer().getyPos()); + Sprite tempObject = m.entitySprites[i]; + + + boolean overlaps = false; + if(Intersector.overlaps(tempObject.getBoundingRectangle(), playerSprite)){ + overlaps = true; + } + else{ + for(RectangleMapObject rectangleObject : mapObjects.getByType(RectangleMapObject.class)){ + Rectangle rectangle = rectangleObject.getRectangle(); + + if(Intersector.overlaps(tempObject.getBoundingRectangle(), rectangle)){ + overlaps = true; + break; + } + } + } + + if(overlaps){ + d.getCurrentEntities()[i].setxPos(x); + d.getCurrentEntities()[i].setyPos(y); + } + } + } } } },0, 0.03f); diff --git a/core/src/com/dungeoncrawler/model/Entity.java b/core/src/com/dungeoncrawler/model/Entity.java index 059a4b7..80b4d17 100644 --- a/core/src/com/dungeoncrawler/model/Entity.java +++ b/core/src/com/dungeoncrawler/model/Entity.java @@ -1,5 +1,9 @@ package com.dungeoncrawler.model; +import com.badlogic.gdx.maps.MapObject; +import com.badlogic.gdx.maps.MapObjects; +import com.badlogic.gdx.math.Rectangle; + public abstract class Entity { protected float xPos; @@ -61,6 +65,7 @@ public abstract class Entity { } } + abstract public void move(int xPosPlayer, int yPosPlayer); // GETTER + SETTER public float getxPos() { @@ -139,10 +144,4 @@ public abstract class Entity { this.direction = direction; } - public void randomMove(int x, int y){ - - } - - abstract public void move(int xPosPlayer, int yPosPlayer); - } \ No newline at end of file diff --git a/core/src/com/dungeoncrawler/model/entities/Archer.java b/core/src/com/dungeoncrawler/model/entities/Archer.java index ee2bf25..f36509c 100644 --- a/core/src/com/dungeoncrawler/model/entities/Archer.java +++ b/core/src/com/dungeoncrawler/model/entities/Archer.java @@ -1,17 +1,9 @@ package com.dungeoncrawler.model.entities; import com.dungeoncrawler.model.Entity; -import com.badlogic.gdx.utils.Timer; public class Archer extends Entity{ - Timer tup; - Timer tright; - Timer tdown; - Timer tleft; - int timerRuns; - boolean isRunning; - public Archer(float xPos, float yPos, int lvl) { super(xPos, yPos, lvl); @@ -22,135 +14,8 @@ public class Archer extends Entity{ this.id = 0; // TODO: Sinnvolle Werte finden - tup = new Timer(); - tright = new Timer(); - tdown = new Timer(); - tleft = new Timer(); - isRunning = false; - timerRuns = 0; direction = 2; - tup.scheduleTask(new Timer.Task() { - @Override - public void run() { - setDirection(0); - setyPos(getyPos() + 1f); - setTimerRuns(getTimerRuns() + 1); - if(getTimerRuns() >= 48){ - setTimerRuns(0); - setIsRunning(false); - tup.stop(); - } - } - },0,0.015f); - tup.stop(); - tright.scheduleTask(new Timer.Task() { - @Override - public void run() { - setDirection(1); - setxPos(getxPos() + 1f); - setTimerRuns(getTimerRuns() + 1); - if(getTimerRuns() >= 48){ - setTimerRuns(0); - setIsRunning(false); - tright.stop(); - } - } - },0,0.015f); - tright.stop(); - tdown.scheduleTask(new Timer.Task() { - @Override - public void run() { - setDirection(2); - setyPos(getyPos() - 1f); - setTimerRuns(getTimerRuns() + 1); - if(getTimerRuns() >= 48){ - setTimerRuns(0); - setIsRunning(false); - tdown.stop(); - } - } - },0,0.015f); - tdown.stop(); - tleft.scheduleTask(new Timer.Task() { - @Override - public void run() { - setDirection(3); - setxPos(getxPos() - 1f); - setTimerRuns(getTimerRuns() + 1); - - if(getTimerRuns() >= 48){ - setTimerRuns(0); - setIsRunning(false); - tleft.stop(); - } - } - },0,0.015f); - tleft.stop(); - - } - - @Override - public void randomMove(int x, int y) { - double i = Math.random(); - if(i <= 0.2){ - if(isRunning == false){ - if(getyPos() >= (x-1) * 48f){ - } - else{ - setIsRunning(true); - tup.start(); - } - } - } - else if(i > 0.2 && i <= 0.4){ - if(isRunning == false){ - if(getxPos() >= (y-1) * 48f){ - } - else{ - setIsRunning(true); - tright.start(); - } - } - } - else if(i > 0.4 && i <= 0.6){ - if(isRunning == false){ - if(getyPos() <= 48f){ - } - else{ - setIsRunning(true); - tdown.start(); - } - } - } - else if(i > 0.6 && i <= 0.8){ - if(isRunning == false){ - if(getxPos() <= 48f){ - } - else{ - setIsRunning(true); - tleft.start(); - } - } - } - else{ - } - } - - - private void setIsRunning(boolean n){ - isRunning = n; - } - private boolean getIsRunning(){ - return isRunning; - } - - public int getTimerRuns(){ - return timerRuns; - } - - public void setTimerRuns(int n){ - timerRuns = n; } @Override diff --git a/core/src/com/dungeoncrawler/model/entities/Arrow.java b/core/src/com/dungeoncrawler/model/entities/Arrow.java index 698bacb..95b40e6 100644 --- a/core/src/com/dungeoncrawler/model/entities/Arrow.java +++ b/core/src/com/dungeoncrawler/model/entities/Arrow.java @@ -6,14 +6,9 @@ package com.dungeoncrawler.model.entities; import com.dungeoncrawler.model.Entity; -import com.badlogic.gdx.utils.Timer; public class Arrow extends Entity{ - Timer toben; - Timer tunten; - Timer trechts; - Timer tlinks; float xStart; float yStart; int direction; @@ -22,61 +17,11 @@ public class Arrow extends Entity{ super(xPos, yPos, lvl); xStart = xPos; yStart = yPos; - Timer toben = new Timer(); - Timer tunten = new Timer(); - Timer trechts = new Timer(); - Timer tlinks = new Timer(); this.direction = direction; this.dmg = 3*lvl; this.id = 2; - toben.scheduleTask(new Timer.Task() { - @Override - public void run() { - setyPos(getyPos() + 3f); - } - },0,0.1f); - toben.stop(); - tunten.scheduleTask(new Timer.Task() { - @Override - public void run() { - setyPos(getyPos() - 3f); - } - },0,0.1f); - tunten.stop(); - trechts.scheduleTask(new Timer.Task() { - @Override - public void run() { - setxPos(getxPos() + 3f); - } - },0,0.1f); - trechts.stop(); - tlinks.scheduleTask(new Timer.Task() { - @Override - public void run() { - setyPos(getxPos() - 3f); - } - },0,0.1f); - tlinks.stop(); - switch(direction){ - case 0: - toben.start(); - break; - case 1: - trechts.start(); - break; - case 2: - tunten.start(); - break; - case 3: - tlinks.start(); - break; - - } - - - } - + } public float getxStart(){ return xStart; diff --git a/core/src/com/dungeoncrawler/model/entities/Player.java b/core/src/com/dungeoncrawler/model/entities/Player.java index 91f0359..ca01b50 100644 --- a/core/src/com/dungeoncrawler/model/entities/Player.java +++ b/core/src/com/dungeoncrawler/model/entities/Player.java @@ -5,11 +5,9 @@ */ package com.dungeoncrawler.model.entities; - import com.dungeoncrawler.model.Entity; import com.dungeoncrawler.model.Inventory; import com.dungeoncrawler.model.Item; -import com.dungeoncrawler.model.ItemContainer; /** * * @author Jan diff --git a/core/src/com/dungeoncrawler/model/entities/Swordsman.java b/core/src/com/dungeoncrawler/model/entities/Swordsman.java index 14e2ed2..3baa52f 100644 --- a/core/src/com/dungeoncrawler/model/entities/Swordsman.java +++ b/core/src/com/dungeoncrawler/model/entities/Swordsman.java @@ -1,16 +1,9 @@ package com.dungeoncrawler.model.entities; -import com.badlogic.gdx.utils.Timer; + import com.dungeoncrawler.model.Entity; public class Swordsman extends Entity { - Timer tup; - Timer tright; - Timer tdown; - Timer tleft; - int timerRuns; - boolean isRunning; - public Swordsman(float xPos, float yPos, int lvl) { super(xPos, yPos, lvl); @@ -19,133 +12,9 @@ public class Swordsman extends Entity { this.direction = 2; this.dmg = 3*lvl; this.id = 1; + // TODO: Sinnvolle Werte finden - tup = new Timer(); - tright = new Timer(); - tdown = new Timer(); - tleft = new Timer(); - isRunning = false; - timerRuns = 0; direction = 2; - - - tup.scheduleTask(new Timer.Task() { - @Override - public void run() { - setDirection(0); - setyPos(getyPos() + 1f); - setTimerRuns(getTimerRuns() + 1); - if(getTimerRuns() >= 48){ - setTimerRuns(0); - setIsRunning(false); - tup.stop(); - } - } - },0,0.025f); - tup.stop(); - tright.scheduleTask(new Timer.Task() { - @Override - public void run() { - setDirection(1); - setxPos(getxPos() + 1f); - setTimerRuns(getTimerRuns() + 1); - if(getTimerRuns() >= 48){ - setTimerRuns(0); - setIsRunning(false); - tright.stop(); - } - } - },0,0.025f); - tright.stop(); - tdown.scheduleTask(new Timer.Task() { - @Override - public void run() { - setDirection(2); - setyPos(getyPos() - 1f); - setTimerRuns(getTimerRuns() + 1); - if(getTimerRuns() >= 48){ - setTimerRuns(0); - setIsRunning(false); - tdown.stop(); - } - } - },0,0.025f); - tdown.stop(); - tleft.scheduleTask(new Timer.Task() { - @Override - public void run() { - setDirection(3); - setxPos(getxPos() - 1f); - setTimerRuns(getTimerRuns() + 1); - - if(getTimerRuns() >= 48){ - setTimerRuns(0); - setIsRunning(false); - tleft.stop(); - } - } - },0,0.025f); - tleft.stop(); - } - - @Override - public void randomMove(int x, int y) { - double i = Math.random(); - if(i <= 0.25){ - if(isRunning == false){ - if(yPos >= (x-1) * 48f){ - } - else{ - setIsRunning(true); - tup.start(); - } - } - } - else if(i > 0.25 && i <= 0.5){ - if(isRunning == false){ - if(xPos >= (y-1) * 48f){ - } - else{ - setIsRunning(true); - tright.start(); - } - } - } - else if(i > 0.5 && i <= 0.75){ - if(isRunning == false){ - if(yPos <= 48f){ - } - else{ - setIsRunning(true); - tdown.start(); - } - } - } - else if(i > 0.75 && i <= 1){ - if(isRunning == false){ - if(xPos <= 48f){ - } - else{ - setIsRunning(true); - tleft.start(); - } - } - } - } - - private void setIsRunning(boolean n){ - isRunning = n; - } - private boolean getIsRunning(){ - return isRunning; - } - - public int getTimerRuns(){ - return timerRuns; - } - - public void setTimerRuns(int n){ - timerRuns = n; } @Override @@ -177,16 +46,6 @@ public class Swordsman extends Entity { movementX = (int) (3 * Math.cos(alpha)); movementY = (int) (3 * Math.sin(alpha)); - /* - if(deltaX < 0 || deltaY < 0){ - movementX *= -1; - movementY *= -1; - } - else if(deltaY < 0){ - movementX *= -1; - } - */ - xPos += movementX; yPos += movementY; } diff --git a/core/src/com/dungeoncrawler/view/GameScreen.java b/core/src/com/dungeoncrawler/view/GameScreen.java index b048009..0264f75 100644 --- a/core/src/com/dungeoncrawler/view/GameScreen.java +++ b/core/src/com/dungeoncrawler/view/GameScreen.java @@ -28,7 +28,7 @@ public class GameScreen { //ENTITIES Texture[] entityTextures; - Sprite[] entitySprites; + public Sprite[] entitySprites; TextureRegion[][] archerRegions; Texture archerTexture; TextureRegion[][] swordsmanRegions; @@ -43,8 +43,8 @@ public class GameScreen { TiledMapRenderer tmr; TiledMap tm; OrthographicCamera camera; - ArrayList objects; - ArrayList mapItems; + public ArrayList objects; + public ArrayList mapItems; Timer animations; Timer animatePlayer;