coding inventory started

BUG FIXED - all entities moving
master
GammelJan 6 years ago
parent ea1b6bb81f
commit 0284dfee20

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 B

@ -45,7 +45,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
Sprite verticalAttackSprite;
Sprite horizontalAttackSprite;
Timer entityMovement;
@Override
public void create(){
@ -96,7 +96,18 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
Gdx.input.setInputProcessor(this);
entityMovement = new Timer();
entityMovement.scheduleTask(new Timer.Task() {
@Override
public void run() {
for(int i = 0; i <= 4; i++){
if(e[i] != null){
e[i].randomMove(roomX, roomY);
}
}
}
},0,1f);
}
@ -225,13 +236,11 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
switch(ent.getId()){
case 0:
e[i] = new Archer(x,y,lvl);
e[i].startT();
m.newEntity(i,ent,x,y);
i = 11;
break;
case 1:
e[i] = new Swordsman(x,y,lvl);
e[i].startT();
m.newEntity(i,ent,x,y);
i = 11;
break;
@ -297,7 +306,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(keycode == Input.Keys.E){
if(v != null){}
if(m != null){
m.PlayerAttack(e, d.getPlayer());
m.playerAttack(e, d.getPlayer());
}
}
return true;
@ -383,6 +392,10 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
return false;
}
public Entity[] getEntities(){
return e;
}

@ -157,7 +157,7 @@ public abstract class Entity {
public void setFacing(int facing){
this.facing = facing;
}
public void startT(){
public void randomMove(int x, int y){
}

@ -4,10 +4,11 @@ package com.dungeoncrawler.model;
public class Inventory {
Item items[][];
Item equip;
Item equipped[];
Inventory(int width, int height){
items = new Item[width][height];
equipped = new Item[2];
}
public void addItem(Item i)
@ -25,9 +26,12 @@ public class Inventory {
}
public void equipItem(int x, int y){
if(equip == null){
equip = items[x][y];
dropItem(x,y);
if(items[x][y] == null || items[x][y].getId() == 0){}
else{
int slot = items[x][y].getId() - 1;
Item temp = equipped[slot];
equipped[slot] = items[x][y];
items[x][y] = temp;
}
}

@ -10,25 +10,23 @@ package com.dungeoncrawler.model;
* @author jonathan
*/
public abstract class Item {
private int amount;
protected int dmg;
protected int heal;
protected int lvl;
protected int id;
public Item(int amount){
this.amount = amount;
public Item(int lvl){
this.lvl = lvl;
}
/**
* @return the amount
*/
public int getAmount() {
return amount;
public int getId(){
return this.id;
}
/**
* @param amount the amount to set
* @return the amount
*/
public void setAmount(int amount) {
this.amount = amount;
}
}

@ -5,7 +5,6 @@ import com.badlogic.gdx.utils.Timer;
public class Archer extends Entity{
Timer t;
Timer tup;
Timer tright;
Timer tdown;
@ -31,59 +30,10 @@ public class Archer extends Entity{
timerRuns = 0;
facing = 2;
t = new Timer();
t.scheduleTask(new Timer.Task() {
@Override
public void run() {
double i = Math.random();
if(i <= 0.2){
if(isRunning == false){
if(getyPos() == 240){
}
else{
tup.start();
}
}
}
else if(i > 0.2 && i <= 0.4){
if(isRunning == false){
if(getxPos() == 336){
}
else{
tright.start();
}
}
}
else if(i > 0.4 && i <= 0.6){
if(isRunning == false){
if(getyPos() == 48){
}
else{
tdown.start();
}
}
}
else if(i > 0.6 && i <= 0.8){
if(isRunning == false){
if(getxPos() == 48){
}
else{
tleft.start();
}
}
}
else{
//facing = 2;
}
}
},0,1f);
t.stop();
tup.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(0);
setIsRunning(true);
setyPos(getyPos() + 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
@ -92,13 +42,12 @@ public class Archer extends Entity{
tup.stop();
}
}
},0,0.02f);
},0,0.015f);
tup.stop();
tright.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(1);
setIsRunning(true);
setxPos(getxPos() + 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
@ -107,13 +56,12 @@ public class Archer extends Entity{
tright.stop();
}
}
},0,0.02f);
},0,0.015f);
tright.stop();
tdown.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(2);
setIsRunning(true);
setyPos(getyPos() - 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
@ -122,13 +70,12 @@ public class Archer extends Entity{
tdown.stop();
}
}
},0,0.02f);
},0,0.015f);
tdown.stop();
tleft.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(3);
setIsRunning(true);
setxPos(getxPos() - 1f);
setTimerRuns(getTimerRuns() + 1);
@ -138,11 +85,59 @@ public class Archer extends Entity{
tleft.stop();
}
}
},0,0.02f);
},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;
}
@ -157,10 +152,7 @@ public class Archer extends Entity{
public void setTimerRuns(int n){
timerRuns = n;
}
@Override
public void startT(){
t.start();
}
}

@ -4,7 +4,6 @@ import com.dungeoncrawler.model.Entity;
public class Swordsman extends Entity {
Timer t;
Timer tup;
Timer tright;
Timer tdown;
@ -29,58 +28,11 @@ public class Swordsman extends Entity {
timerRuns = 0;
facing = 2;
t = new Timer();
t.scheduleTask(new Timer.Task() {
@Override
public void run() {
double i = Math.random();
if(i <= 0.2){
if(isRunning == false){
if(getyPos() == 240){
}
else{
tup.start();
}
}
}
else if(i > 0.2 && i <= 0.4){
if(isRunning == false){
if(getxPos() == 336){
}
else{
tright.start();
}
}
}
else if(i > 0.4 && i <= 0.6){
if(isRunning == false){
if(getyPos() == 48){
}
else{
tdown.start();
}
}
}
else if(i > 0.6 && i <= 0.8){
if(isRunning == false){
if(getxPos() == 48){
}
else{
tleft.start();
}
}
}
else{
}
}
},0,1f);
t.stop();
tup.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(0);
setIsRunning(true);
setyPos(getyPos() + 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
@ -89,13 +41,12 @@ public class Swordsman extends Entity {
tup.stop();
}
}
},0,0.03f);
},0,0.025f);
tup.stop();
tright.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(1);
setIsRunning(true);
setxPos(getxPos() + 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
@ -104,13 +55,12 @@ public class Swordsman extends Entity {
tright.stop();
}
}
},0,0.03f);
},0,0.025f);
tright.stop();
tdown.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(2);
setIsRunning(true);
setyPos(getyPos() - 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
@ -119,13 +69,12 @@ public class Swordsman extends Entity {
tdown.stop();
}
}
},0,0.03f);
},0,0.025f);
tdown.stop();
tleft.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(3);
setIsRunning(true);
setxPos(getxPos() - 1f);
setTimerRuns(getTimerRuns() + 1);
@ -135,10 +84,55 @@ public class Swordsman extends Entity {
tleft.stop();
}
}
},0,0.03f);
},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;
}
@ -153,9 +147,6 @@ public class Swordsman extends Entity {
public void setTimerRuns(int n){
timerRuns = n;
}
@Override
public void startT(){
t.start();
}
}

@ -13,8 +13,9 @@ import com.dungeoncrawler.model.Item;
*/
public class Key extends Item {
public Key(int amount) {
super(amount);
public Key(int lvl) {
super(lvl);
this.id = 0;
}
}

@ -13,8 +13,10 @@ import com.dungeoncrawler.model.Item;
*/
public class Potion extends Item {
public Potion(int amount) {
super(amount);
public Potion(int lvl) {
super(lvl);
this.heal = lvl * 3;
this.id = 1;
}
}

@ -13,8 +13,9 @@ import com.dungeoncrawler.model.Item;
*/
public class Sword extends Item {
public Sword(int amount) {
super(amount);
public Sword(int lvl) {
super(lvl);
this.dmg = lvl * 4;
}
}

@ -219,7 +219,7 @@ public class GameScreen {
}
}
public void PlayerAttack(Entity e[], Player p){
public void playerAttack(Entity e[], Player p){
if(p.direction() == 0){
Texture verticalAttack = new Texture("AttackHori.png");
Sprite verticalAttackSprite = new Sprite(verticalAttack);

Loading…
Cancel
Save