Merge branch 'Jan'

KURZ VOR MERGE
master
GammelJan 6 years ago
commit 5a3b1e0bf9

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 B

After

Width:  |  Height:  |  Size: 1002 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

@ -10,49 +10,72 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input; import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.dungeoncrawler.view.View; import com.dungeoncrawler.view.*;
import com.dungeoncrawler.model.Dungeon; import com.dungeoncrawler.model.Dungeon;
import com.dungeoncrawler.model.DungeonGenerator; import com.dungeoncrawler.model.DungeonGenerator;
import com.dungeoncrawler.model.entities.Player; import com.dungeoncrawler.model.entities.*;
import com.dungeoncrawler.model.entities.Archer; import com.dungeoncrawler.model.Entity;
import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.Timer;
public class Controller extends ApplicationAdapter implements InputProcessor{ public class Controller extends ApplicationAdapter implements InputProcessor{
SpriteBatch batch; SpriteBatch batch;
Dungeon d; Dungeon d;
DungeonGenerator dg; DungeonGenerator dg;
View v; MainMenu v;
Player p; Player p;
Archer a; Entity[] e;
Timer t; Timer t;
Map m;
@Override @Override
public void create(){ public void create(){
batch = new SpriteBatch(); batch = new SpriteBatch();
v = new View(); v = new MainMenu();
p = new Player(); p = new Player();
d = new Dungeon(p); d = new Dungeon(p);
dg = new DungeonGenerator(); dg = new DungeonGenerator();
dg.ichWillSpielen(); dg.ichWillSpielen();
e = new Entity[5];
p = new Player();
d = new Dungeon(p);
a = new Archer(500, 200, 1);
Gdx.input.setInputProcessor(this); Gdx.input.setInputProcessor(this);
t = new Timer(); t = new Timer();
t.scheduleTask(new Timer.Task() { t.scheduleTask(new Timer.Task() {
@Override @Override
public void run() { public void run() {
a.rdmMove(); for(int i = 0; i< e.length; i++){
if(e[i] == null){}
else{
e[i].rdmMove();
}
}
} }
},0,0.1f); },0,0.1f);
} }
public void newEntity(Entity ent, int x, int y, int lvl){
for(int i = 0; i < e.length ; i++){
if(e[i] == null){
switch(ent.getId()){
case 0:
e[i] = new Archer(x,y,lvl);
v.newEntity(i,ent,x,y);
i = 10;
break;
case 1:
e[i] = new Swordsman(x,y,lvl);
v.newEntity(i,ent,x,y);
i = 10;
break;
}
}
}
}
@Override @Override
public void render(){ public void render(){
v.render(batch, p , a); if(v != null){
v.render(batch, p , e);
}
} }
@Override @Override
@ -63,22 +86,50 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
@Override @Override
public boolean keyDown(int keycode) { public boolean keyDown(int keycode) {
if(keycode == Input.Keys.LEFT){ if(keycode == Input.Keys.LEFT){
p.setMovementX(-3); if(v != null){
v.moveCursor(3);
}
if(m != null){
p.setMovementX(-5);
}
} }
if(keycode == Input.Keys.RIGHT){ if(keycode == Input.Keys.RIGHT){
p.setMovementX(3); if(v != null){
} v.moveCursor(1);
}
if(keycode == Input.Keys.UP){ if(m != null){
p.setMovementY(3); p.setMovementX(5);
}
} }
if(keycode == Input.Keys.DOWN){ if(keycode == Input.Keys.DOWN){
p.setMovementY(-3); if(v != null){
v.moveCursor(2);
}
if(m != null){
p.setMovementY(-5);
}
} }
if(keycode == Input.Keys.W){
if(keycode == Input.Keys.UP){
if(v != null){
v.moveCursor(0);
}
if(m != null){
p.setMovementY(5);
}
}
if(keycode == Input.Keys.ENTER){
if(v != null){
if(v.click() == -1){}
else if(v.click() == 0){
v = null;
m = new Map();
System.out.println("NICE");
}
}
} }
return true; return true;
} }
@ -86,24 +137,40 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
@Override @Override
public boolean keyUp(int keycode) { public boolean keyUp(int keycode) {
if(keycode == Input.Keys.LEFT){ if(keycode == Input.Keys.LEFT){
if(v != null){
v.stopCursor(3);
}
if(m != null){
p.setMovementX(0); p.setMovementX(0);
v.tlinksstop(); }
} }
if(keycode == Input.Keys.RIGHT){ if(keycode == Input.Keys.RIGHT){
if(v != null){
v.stopCursor(1);
}
if(m != null){
p.setMovementX(0); p.setMovementX(0);
v.trechtsstop(); }
} }
if(keycode == Input.Keys.DOWN){ if(keycode == Input.Keys.DOWN){
if(v != null){
v.stopCursor(2);
}
if(m != null){
p.setMovementY(0); p.setMovementY(0);
v.tuntenstop(); }
} }
if(keycode == Input.Keys.UP){ if(keycode == Input.Keys.UP){
if(v != null){
v.stopCursor(0);
}
if(m != null){
p.setMovementY(0); p.setMovementY(0);
v.tobenstop(); }
} }
return true; return true;
} }
@ -113,9 +180,11 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
} }
@Override @Override
public boolean touchDown(int i, int i1, int i2, int i3) { public boolean touchDown(int screenX, int screenY, int pointer, int button)
return false; {
}
return false;
}
@Override @Override
public boolean touchUp(int i, int i1, int i2, int i3) { public boolean touchUp(int i, int i1, int i2, int i3) {

@ -37,11 +37,13 @@ public class DungeonGenerator {
System.out.println(roomAmount); System.out.println(roomAmount);
// TODO: Zufällig Türen setzen // TODO: Zufällig Türen setzen
//int xPos = roomAmount / 2; //int xPos = roomAmount / 2;
//int yPos = roomAmount / 2; //int yPos = roomAmount / 2;
int xPos = (int) (Math.random() * roomAmount); int xPos = (int) (Math.random() * roomAmount);
int yPos = (int) (Math.random() * roomAmount); int yPos = (int) (Math.random() * roomAmount);
tempLevel.setRoom(generateRoom(), xPos, yPos); tempLevel.setRoom(generateRoom(), xPos, yPos);
for(int i = 1; i < roomAmount;){ for(int i = 1; i < roomAmount;){

@ -11,6 +11,7 @@ public abstract class Entity {
protected int lvl; protected int lvl;
protected int movementX; protected int movementX;
protected int movementY; protected int movementY;
protected int id;
public Entity(int xPos, int yPos, int lvl){ public Entity(int xPos, int yPos, int lvl){
this.xPos = xPos; this.xPos = xPos;
@ -122,4 +123,8 @@ public abstract class Entity {
public void setMovementY(int movementY){ public void setMovementY(int movementY){
this.movementY = movementY; this.movementY = movementY;
} }
public int getId(){
return this.id;
}
} }

@ -10,12 +10,8 @@ public class Archer extends Entity{
this.hp = this.maxhp; this.hp = this.maxhp;
this.dmg = 3*lvl; this.dmg = 3*lvl;
this.id = 0;
// TODO: Sinnvolle Werte finden // TODO: Sinnvolle Werte finden
} }
} }

@ -20,7 +20,7 @@ public class Player extends Entity {
this.hp = this.maxhp; this.hp = this.maxhp;
this.dmg = 3*lvl; this.dmg = 3*lvl;
id = -1;
// TODO: Sinnvolle Werte finden // TODO: Sinnvolle Werte finden
} }

@ -1,16 +1,6 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.dungeoncrawler.model.entities; package com.dungeoncrawler.model.entities;
import com.dungeoncrawler.model.Entity; import com.dungeoncrawler.model.Entity;
/**
*
* @author Jan
*/
public class Swordsman extends Entity { public class Swordsman extends Entity {
public Swordsman(int xPos, int yPos, int lvl) { public Swordsman(int xPos, int yPos, int lvl) {
@ -20,10 +10,8 @@ public class Swordsman extends Entity {
this.hp = this.maxhp; this.hp = this.maxhp;
this.dmg = 3*lvl; this.dmg = 3*lvl;
this.id = 1;
// TODO: Sinnvolle Werte finden // TODO: Sinnvolle Werte finden
} }
} }

@ -0,0 +1,159 @@
package com.dungeoncrawler.view;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Rectangle;
import com.dungeoncrawler.model.entities.*;
import com.dungeoncrawler.model.Entity;
public class MainMenu{
//MENU-SCREEN
Texture b;
Texture t;
Sprite button;
Sprite title;
//ENTITIES
Texture[] entityTextures;
Sprite[] entitySprites;
//CURSOR
Texture c;
Sprite cursor;
float CursorMoveX;
float CursorMoveY;
/*
//PLAYER
Texture p;
Sprite player;
TextureRegion[][] regions;
*/
public MainMenu() {
//MENU-SCREEN
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
float wc = w/2;
b = new Texture("Button.png");
t = new Texture("Title.png");
button = new Sprite(b);
title = new Sprite(t);
title.setX(wc - (title.getWidth()/2));
title.setY(h - 200);
button.setX(wc - (button.getWidth()/2));
button.setY(400);
//ENTITIES
entityTextures = new Texture[5];
entitySprites = new Sprite[5];
//CURSOR
c = new Texture("cursor.png");
cursor = new Sprite(c);
cursor.setX((float) w/2);
cursor.setY((float) h/2);
CursorMoveX = 0f;
CursorMoveY = 0f;
//PLAYER
/*
p = new Texture("player.png");
regions = TextureRegion.split(p, 64, 64);
player = new Sprite(regions[0][0]);
player.setX(200);
player.setY(200);
*/
}
public void render (SpriteBatch batch, Player p, Entity[] a) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
cursor.setX(cursor.getX()+ CursorMoveX);
cursor.setY(cursor.getY()+ CursorMoveY);
/*
player.setX(player.getX()+ (float) p.getMovementX());
player.setY(player.getY()+ (float) p.getMovementY());
if(p.getMovementX() == 5){
player.setRegion(regions[0][1]);
}
if(p.getMovementX() == -5){
player.setRegion(regions[0][3]);
}
if(p.getMovementY() == 5){
player.setRegion(regions[0][0]);
}
if(p.getMovementY() == -5){
player.setRegion(regions[0][2]);
}
*/
batch.begin();
title.draw(batch);
button.draw(batch);
cursor.draw(batch);
if(entitySprites[0] != null){
entitySprites[0].draw(batch);
}
if(entitySprites[1] != null){
entitySprites[1].draw(batch);
}
batch.end();
}
public void newEntity(int i,Entity e, int x, int y){
if(e.getId() == 0){
entityTextures[i] = new Texture("archer.png");
entitySprites[i] = new Sprite(entityTextures[i]);
entitySprites[i].setX(x);
entitySprites[i].setY(y);
}
else if(e.getId() == 1){
entityTextures[i] = new Texture("Swordsman.png");
entitySprites[i] = new Sprite(entityTextures[i]);
entitySprites[i].setX(x);
entitySprites[i].setY(y);
}
}
public void moveCursor(int direction){
switch(direction){
case 0:
CursorMoveY = 10f; break;
case 1:
CursorMoveX = 10f; break;
case 2:
CursorMoveY = -10f; break;
case 3:
CursorMoveX = -10f; break;
}
}
public void stopCursor(int direction){
switch(direction){
case 0:
CursorMoveY = 0f; break;
case 1:
CursorMoveX = 0f; break;
case 2:
CursorMoveY = 0f; break;
case 3:
CursorMoveX = 0f; break;
}
}
public int click(){
Rectangle rectangleCursor = cursor.getBoundingRectangle();
Rectangle rectangleButton = button.getBoundingRectangle();
boolean overlapsPlay = rectangleCursor.overlaps(rectangleButton);
if(overlapsPlay == true){
return 0;
}
else{return -1;}
}
}

@ -14,7 +14,6 @@ import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell;
import com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile; import com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile;
import com.badlogic.gdx.utils.Timer;
/** /**
* *
* @author jonathan * @author jonathan

@ -1,195 +0,0 @@
package com.dungeoncrawler.view;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.dungeoncrawler.model.entities.*;
public class View {
Texture b;
Texture t;
Texture p;
Texture a;
Sprite button;
Sprite title;
Sprite player;
Sprite archer;
int PlayerFrame = 0;
int PlayerZeile = 0;
TextureRegion[][] regions;
Timer tunten;
Timer toben;
Timer tlinks;
Timer trechts;
public View() {
b = new Texture("Button.png");
t = new Texture("Title.png");
p = new Texture("animplay.png");
a = new Texture("Archer-64.png");
button = new Sprite(b);
title = new Sprite(t);
archer = new Sprite(a);
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
float wc = w/2;
title.setX(wc - (title.getWidth()/2));
title.setY(h - 200);
button.setX(wc - (button.getWidth()/2));
button.setY(400);
regions = TextureRegion.split(p, 32, 32);
player = new Sprite(regions[0][2]);
player.setX(200);
player.setY(200);
tunten = new Timer();
toben = new Timer();
tlinks = new Timer();
trechts = new Timer();
tunten.scheduleTask(new Timer.Task() {
@Override
public void run() {
PlayerZeile = 2;
if(PlayerFrame == 9){
PlayerFrame = 0;
}
else{
PlayerFrame++;
}
player.setRegion(regions[PlayerZeile][PlayerFrame]);
}
},0,1/5f);
tunten.stop();
toben.scheduleTask(new Timer.Task() {
@Override
public void run() {
PlayerZeile = 2;
if(PlayerFrame == 9){
PlayerFrame = 0;
}
else{
PlayerFrame++;
}
player.setRegion(regions[PlayerZeile][PlayerFrame]);
}
}, 0,1/5f);
toben.stop();
tlinks.scheduleTask(new Timer.Task() {
@Override
public void run() {
PlayerZeile = 2;
if(player.isFlipX() == true){
}
else{
player.flip(true, false);
}
if(PlayerFrame == 9){
PlayerFrame = 0;
}
else{
PlayerFrame++;
}
player.setRegion(regions[PlayerZeile][PlayerFrame]);
}
}, 0,1/5f);
tlinks.stop();
trechts.scheduleTask(new Timer.Task() {
@Override
public void run() {
PlayerZeile = 2;
if(player.isFlipX() == true){
player.flip(false, false);
}
if(PlayerFrame == 9){
PlayerFrame = 0;
}
else{
PlayerFrame++;
}
player.setRegion(regions[PlayerZeile][PlayerFrame]);
}
}, 0,1/5f);
trechts.stop();
}
public void render (SpriteBatch batch, Player p, Archer a) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
player.setX(player.getX()+ (float) p.getMovementX());
player.setY(player.getY()+ (float) p.getMovementY());
archer.setX((float)a.getxPos());
archer.setY((float)a.getyPos());
if(p.getMovementX() == 3){
trechts.start();
if(player.isFlipX() == true){
player.flip(false, false);
}
}
if(p.getMovementX() == -3){
tlinks.start();
if(player.isFlipX() == true){
}
else{
player.flip(true, false);
}
}
if(p.getMovementY() == 3){
toben.start();
}
if(p.getMovementY() == -3){
tunten.start();
}
batch.begin();
title.draw(batch);
button.draw(batch);
player.draw(batch);
archer.draw(batch);
batch.end();
}
public void tuntenstop(){
tunten.stop();
PlayerFrame = 0;
player.setRegion(regions[PlayerZeile][PlayerFrame]);}
public void tobenstop(){
toben.stop();
PlayerFrame = 0;
player.setRegion(regions[PlayerZeile][PlayerFrame]);}
public void tlinksstop(){
tlinks.stop();
PlayerFrame = 0;
player.setRegion(regions[PlayerZeile][PlayerFrame]);
player.flip(true, false);}
public void trechtsstop(){
trechts.stop();
PlayerFrame = 0;
player.setRegion(regions[PlayerZeile][PlayerFrame]);}
}
Loading…
Cancel
Save