Merge fertgi

master
Jonathan Hager 6 years ago
commit ed761caf79

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@ -14,6 +14,8 @@ import com.dungeoncrawler.view.View;
import com.dungeoncrawler.model.Dungeon;
import com.dungeoncrawler.model.DungeonGenerator;
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;
@ -21,8 +23,8 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
DungeonGenerator dg;
View v;
Player p;
float movementX = 0f;
float movementY = 0f;
Archer a;
Timer t;
@Override
public void create(){
@ -30,14 +32,27 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
v = new View();
p = new Player();
d = new Dungeon(p);
dg = new DungeonGenerator();
dg.ichWillSpielen();
p = new Player();
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(){
v.render(batch, movementX ,movementY);
v.render(batch, p , a);
}
@Override
@ -48,35 +63,46 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
@Override
public boolean keyDown(int keycode) {
if(keycode == Input.Keys.LEFT){
movementX = -3f;
v.render(batch, movementX, movementY);
p.setMovementX(-3);
}
if(keycode == Input.Keys.RIGHT){
movementX = 3f;
v.render(batch, movementX, movementY);
p.setMovementX(3);
}
if(keycode == Input.Keys.UP){
movementY = 4f;
v.render(batch, movementX, movementY);
p.setMovementY(3);
}
if(keycode == Input.Keys.DOWN){
movementY = -4f;
v.render(batch, movementX, movementY);
p.setMovementY(-3);
}
if(keycode == Input.Keys.W){
}
return true;
}
@Override
public boolean keyUp(int keycode) {
if(keycode == Input.Keys.LEFT || keycode == Input.Keys.RIGHT){
movementX = 0f;
if(keycode == Input.Keys.LEFT){
p.setMovementX(0);
v.tlinksstop();
}
if(keycode == Input.Keys.DOWN || keycode == Input.Keys.UP){
movementY = 0f;
if(keycode == Input.Keys.RIGHT){
p.setMovementX(0);
v.trechtsstop();
}
if(keycode == Input.Keys.DOWN){
p.setMovementY(0);
v.tuntenstop();
}
if(keycode == Input.Keys.UP){
p.setMovementY(0);
v.tobenstop();
}
return true;
}

@ -9,14 +9,19 @@ 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(){
}
@ -26,10 +31,33 @@ public abstract class Entity {
public void die(){
}
public void move(int movementX, int movementY){
public void move(){
xPos = xPos + movementX;
yPos = yPos + movementY;
}
public void rdmMove(){
switch((int) (Math.random() * 5)){
case 0: //left
setMovementX(-3);
move();
break;
case 1: //right
setMovementX(3);
move();
break;
case 2: //up
setMovementY(3);
move();
break;
case 3: //down
setMovementY(-3);
move();
break;
}
}
public int getxPos() {
return xPos;
@ -79,5 +107,19 @@ public abstract class Entity {
this.lvl = lvl;
}
public int getMovementX(){
return movementX;
}
public void setMovementX(int movementX){
this.movementX = movementX;
}
public int getMovementY(){
return movementY;
}
public void setMovementY(int movementY){
this.movementY = movementY;
}
}

@ -4,7 +4,7 @@ package com.dungeoncrawler.model;
public class Inventory {
Item items[][];
Item equip;
Inventory(int width, int height){
items = new Item[width][height];
@ -24,6 +24,14 @@ public class Inventory {
}
}
public void equipItem(int x, int y){
if(equip == null){
equip = items[x][y];
dropItem(x,y);
}
}
public void dropItem(int x, int y){
items[x][y] = null;
}

@ -5,8 +5,6 @@
*/
package com.dungeoncrawler.model;
import com.dungeoncrawler.model.Entity;
/**
*
* @author jonathan
@ -14,14 +12,18 @@ import com.dungeoncrawler.model.Entity;
public class Room {
private ItemContainer[] item;
private Entity[] enemies;
int lvl;
public Room(ItemContainer[] item, Entity[] enemies){
this.item = item;
this.enemies = enemies;
}
public void spawnEnemies(int xPos, int yPos){
// TODO: Zu Implementieren
public void spawnEnemies(int xPos, int yPos, Entity enemy){
enemy.setxPos(xPos);
enemy.setyPos(yPos);
}
public void spawnItem(int xPos, int yPos){
@ -57,4 +59,6 @@ public class Room {
}
}

@ -14,4 +14,8 @@ public class Archer extends Entity{
// TODO: Sinnvolle Werte finden
}
}

@ -24,4 +24,6 @@ public class Player extends Entity {
// TODO: Sinnvolle Werte finden
}
}

@ -24,4 +24,6 @@ public class Swordsman extends Entity {
// TODO: Sinnvolle Werte finden
}
}

@ -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

Loading…
Cancel
Save