merge conflicts solved

master
GammelJAN 5 years ago
commit 5f2b06d6fb

@ -11,7 +11,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
*/ */
public class AnimatedSprite { public class AnimatedSprite {
private final static int[] rowLengths = {7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 6, 6, 6, 12, 12, 12, 12, 6}; private final static int[] ROWLENGTHS = {7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 6, 6, 6, 12, 12, 12, 12, 6};
private Sprite sprite; private Sprite sprite;
private TextureRegion[][] texture; private TextureRegion[][] texture;
@ -34,7 +34,7 @@ public class AnimatedSprite {
if(this.delta >= 0.1f) { if(this.delta >= 0.1f) {
this.delta = 0; this.delta = 0;
if(getFrame() >= rowLengths[getRow()] - 1){ if(getFrame() >= ROWLENGTHS[getRow()] - 1){
setFrame(0); setFrame(0);
} }
else{ else{

@ -10,6 +10,9 @@ public class Main extends Game{
/** /**
* TODO: set final Value for World * TODO: set final Value for World
*/ */
// 0: normal game world, 1: dialogue, 2: fight
public static int gamestate = 0;
@Override @Override
public void create () { public void create () {

@ -51,23 +51,31 @@ public class Player extends Actor{
@Override @Override
public void act(float delta) { public void act(float delta) {
if(Main.gamestate == 0) {
if(Gdx.input.isKeyPressed(Input.Keys.D)){ if(Gdx.input.isKeyPressed(Input.Keys.D)){
movementX = speed; movementX = speed;
facing = 3; facing = 3;
} }
if(Gdx.input.isKeyPressed(Input.Keys.A)){ if(Gdx.input.isKeyPressed(Input.Keys.A)){
movementX = -speed; movementX = -speed;
facing = 1; facing = 1;
} }
if(Gdx.input.isKeyPressed(Input.Keys.W)){ if(Gdx.input.isKeyPressed(Input.Keys.W)){
movementY = speed; movementY = speed;
facing = 0; facing = 0;
} }
if(Gdx.input.isKeyPressed(Input.Keys.S)){ if(Gdx.input.isKeyPressed(Input.Keys.S)){
movementY = -speed; movementY = -speed;
facing = 2; facing = 2;
} }
if(Gdx.input.isKeyJustPressed(Input.Keys.E)) {
Main.gamestate = 1;
getStage().addActor(new Textbox("Dies ist eine coole Test Textbox", "Feier ich", "Ehre"));
}
}
else if(Main.gamestate == 1) {
// Input handled by invoked textbox
}
/** /**
* return * return
* 0: only vertical movement available * 0: only vertical movement available

@ -103,8 +103,6 @@ public class Textbox extends Actor{
@Override @Override
public void draw(Batch batch, float parentAlpha) { public void draw(Batch batch, float parentAlpha) {
if(!batch.isDrawing()){
batch.begin();}
if(state == 0){ if(state == 0){
for(int i = 0; i < splitted.size(); i++){ for(int i = 0; i < splitted.size(); i++){
if(i == printLine){ if(i == printLine){
@ -130,7 +128,6 @@ public class Textbox extends Actor{
font.draw(batch, asw2, 0.6f * r.getWidth(), getX() + getHeight() - splitted.size() * 1.2f * getTextHeight("A")); font.draw(batch, asw2, 0.6f * r.getWidth(), getX() + getHeight() - splitted.size() * 1.2f * getTextHeight("A"));
font.setColor(Color.BLACK); font.setColor(Color.BLACK);
} }
batch.end();
super.draw(batch, parentAlpha); super.draw(batch, parentAlpha);
} }

@ -38,8 +38,6 @@ public abstract class AbstractScreen implements Screen{
Gdx.input.setInputProcessor(stage); Gdx.input.setInputProcessor(stage);
} }
public abstract void setTextbox(Textbox t);
@Override @Override
public abstract void show(); public abstract void show();

@ -20,6 +20,7 @@ import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.physics.box2d.BodyDef; import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.Group;
import com.trs.main.Main;
import com.trs.main.MapCollisionObject; import com.trs.main.MapCollisionObject;
import com.trs.main.Player; import com.trs.main.Player;
import com.trs.main.Textbox; import com.trs.main.Textbox;
@ -31,8 +32,6 @@ import java.util.ArrayList;
*/ */
public class GameScreen extends AbstractScreen{ public class GameScreen extends AbstractScreen{
boolean textbox = false;
TmxMapLoader maploader; TmxMapLoader maploader;
TiledMap map; TiledMap map;
@ -57,12 +56,6 @@ public class GameScreen extends AbstractScreen{
} }
} }
@Override
public void setTextbox(Textbox t) {
stage.addActor(t);
textbox = true;
}
@Override @Override
public void show() { public void show() {
} }
@ -75,21 +68,18 @@ public class GameScreen extends AbstractScreen{
renderer.render(); renderer.render();
if(!textbox){ stage.act(f);
stage.act(f); stage.draw();
stage.draw();
} if(Main.gamestate == 1) {
else{
Textbox t = null; Textbox t = null;
for(Actor a : stage.getActors()){ for(Actor a : stage.getActors()){
if(a.getName().equals("textbox")){ if(a.getName().equals("textbox")){
a.act(f);
a.draw(stage.getBatch(), CAMERA_WIDTH);
t = (Textbox)a; t = (Textbox)a;
if(t.getState() == 2){ if(t.getState() == 2){
a.remove(); a.remove();
Main.gamestate = 0;
t.getSelectedAsw(); // DO STUFF NICENICE t.getSelectedAsw(); // DO STUFF NICENICE
textbox = false;
} }
} }
} }

Loading…
Cancel
Save