master
GammelJan 6 years ago
parent 7e130888ed
commit 6cf4512df2

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 737 B

@ -8,17 +8,20 @@ import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import controller.Controller; import controller.Controller;
import model.Level;
import view.Levelscreen; import view.Levelscreen;
import view.Titlescreen; import view.Titlescreen;
public class Main extends Game implements InputProcessor{ public class Main extends Game implements InputProcessor{
//Controller c; int screenId;
Controller c;
Level level;
@Override @Override
public void create () { public void create () {
//c = new Controller(); c = new Controller();
screenId = 0;
setScreen(new Titlescreen(this)); setScreen(new Titlescreen(this));
} }
@ -48,7 +51,8 @@ public class Main extends Game implements InputProcessor{
} }
@Override @Override
public boolean touchDown(int i, int i1, int i2, int i3) { public boolean touchDown(int x, int y, int i2, int i3) {
//screen.touchDown(x,y);
return true; return true;
} }
@ -71,4 +75,8 @@ public class Main extends Game implements InputProcessor{
public boolean scrolled(int i) { public boolean scrolled(int i) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
} }
public void createLvl(){
}
} }

@ -10,7 +10,7 @@ public class Projectile {
private double vY; private double vY;
private final int type; private final int type;
Projectile(int xPos, int yPos, int type){ public Projectile(int xPos, int yPos, int type){
this.xPos = xPos; this.xPos = xPos;
this.yPos = yPos; this.yPos = yPos;
this.type = type; this.type = type;

@ -47,4 +47,9 @@ public class AbstractScreen implements Screen{
public void dispose() { public void dispose() {
} }
public void touch(int x, int y){
}
} }

@ -9,8 +9,13 @@ import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Rectangle;
import model.Goal;
import model.Projectile;
/** /**
* *
@ -18,8 +23,29 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
*/ */
public class Gamescreen extends AbstractScreen{ public class Gamescreen extends AbstractScreen{
Goal g;
Projectile p;
SpriteBatch batch;
Sprite projectile;
Rectangle goalLeft;
Rectangle goalRight;
Rectangle goalBottom;
public Gamescreen(Game game){ public Gamescreen(Game game){
super(game); super(game);
g = new Goal(800,400,200,150);
p = new Projectile(250, 250, 0);
projectile = new Sprite(new Texture("projectile.png"));
projectile.setPosition(p.getxPos(), p.getyPos());
goalLeft = new Rectangle(g.getxPos(), g.getyPos(), 0.1f * g.getSizeX(), g.getSizeY());
goalBottom = new Rectangle(g.getxPos() + goalLeft.getWidth(), g.getyPos(), 0.8f * g.getSizeX(),0.2f * g.getSizeY());
goalRight = new Rectangle(g.getxPos() + goalLeft.getWidth() + goalBottom.getWidth(), g.getyPos(), 0.1f * g.getSizeX(),g.getSizeY());
batch = new SpriteBatch();
} }
@Override @Override
@ -30,19 +56,15 @@ public class Gamescreen extends AbstractScreen{
public void render(float f) { public void render(float f) {
Gdx.gl.glClearColor(1f, 1f, 1f, 1f); Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
BitmapFont font = new BitmapFont();
font.setColor(Color.RED);
SpriteBatch batch = new SpriteBatch();
batch.begin(); batch.begin();
font.draw(batch, "GAMESCREEN", 250, 250); projectile.draw(batch);
batch.end(); batch.end();
if(Gdx.input.justTouched()){ if(Gdx.input.justTouched()){
game.setScreen(new Levelscreen(game)); game.setScreen(new Levelscreen(game));
} }
} }
@Override @Override
public void resize(int i, int i1) { public void resize(int i, int i1) {
} }

@ -52,7 +52,7 @@ public class Levelscreen extends AbstractScreen{
if(buttonLeft.getX() <= 0){ if(buttonLeft.getX() <= 0){
movement = true; movement = true;
} }
if(buttonLeft.getX() + buttonLeft.getWidth() > Gdx.graphics.getWidth() * 0.2){ if(buttonLeft.getX() + buttonLeft.getWidth() > Gdx.graphics.getWidth() * 0.12){
movement = false; movement = false;
} }
if(movement){ if(movement){
@ -64,9 +64,10 @@ public class Levelscreen extends AbstractScreen{
buttonLeft.setX(buttonLeft.getX() - 2); buttonLeft.setX(buttonLeft.getX() - 2);
} }
} }
},0 , 0.04f); },0 , 0.045f);
} }
@Override @Override
public void show() { public void show() {
} }
@ -90,11 +91,11 @@ public class Levelscreen extends AbstractScreen{
batch.end(); batch.end();
if(Gdx.input.justTouched()){ if(Gdx.input.justTouched()){
if(Gdx.input.getX() < Gdx.graphics.getWidth() * 0.2){ if(Gdx.input.getX() < Gdx.graphics.getWidth() * 0.15){
if(selectedLevel > 0) if(selectedLevel > 0)
selectedLevel --; selectedLevel --;
} }
else if(Gdx.input.getX() > Gdx.graphics.getWidth() * 0.8){ else if(Gdx.input.getX() > Gdx.graphics.getWidth() * 0.85){
if(selectedLevel < levelPreview.length) if(selectedLevel < levelPreview.length)
selectedLevel ++; selectedLevel ++;
} }

Loading…
Cancel
Save