master
GammelJan 6 years ago
parent 6c76e6edbb
commit 7e130888ed

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: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

@ -39,7 +39,7 @@ public class Gamescreen extends AbstractScreen{
batch.end(); batch.end();
if(Gdx.input.justTouched()){ if(Gdx.input.justTouched()){
game.setScreen(new Titlescreen(game)); game.setScreen(new Levelscreen(game));
} }
} }

@ -10,8 +10,11 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input; import com.badlogic.gdx.Input;
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.utils.Timer;
/** /**
* *
@ -19,8 +22,49 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
*/ */
public class Levelscreen extends AbstractScreen{ public class Levelscreen extends AbstractScreen{
Sprite[] levelPreview;
Sprite buttonRight;
Sprite buttonLeft;
int selectedLevel;
BitmapFont font;
Timer t;
boolean movement;
public Levelscreen(Game game){ public Levelscreen(Game game){
super(game); super(game);
levelPreview = new Sprite[5];
buttonRight = new Sprite(new Texture("buttonRight.png"));
buttonRight.setY(Gdx.graphics.getHeight() / 2 - buttonRight.getHeight() / 2);
buttonRight.setX(Gdx.graphics.getWidth() - 10 - buttonRight.getWidth());
buttonLeft = new Sprite(new Texture("buttonLeft.png"));
buttonLeft.setY(Gdx.graphics.getHeight() / 2 - buttonLeft.getHeight() / 2);
buttonLeft.setX(10);
selectedLevel = 0;
font = new BitmapFont();
font.setColor(Color.BLACK);
t = new Timer();
t.scheduleTask(new Timer.Task() {
@Override
public void run() {
if(buttonLeft.getX() <= 0){
movement = true;
}
if(buttonLeft.getX() + buttonLeft.getWidth() > Gdx.graphics.getWidth() * 0.2){
movement = false;
}
if(movement){
buttonRight.setX(buttonRight.getX() - 2);
buttonLeft.setX(buttonLeft.getX() + 2);
}
else{
buttonRight.setX(buttonRight.getX() + 2);
buttonLeft.setX(buttonLeft.getX() - 2);
}
}
},0 , 0.04f);
} }
@Override @Override
@ -32,15 +76,32 @@ public class Levelscreen extends AbstractScreen{
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(); SpriteBatch batch = new SpriteBatch();
batch.begin(); batch.begin();
font.draw(batch, "LEVELSCREEN", 250, 250); if(selectedLevel > 0){
buttonLeft.draw(batch);
}
if(selectedLevel < levelPreview.length){
buttonRight.draw(batch);
}
font.draw(batch, "" + selectedLevel, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
batch.end(); batch.end();
if(Gdx.input.justTouched()){ if(Gdx.input.justTouched()){
game.setScreen(new Gamescreen(game)); if(Gdx.input.getX() < Gdx.graphics.getWidth() * 0.2){
if(selectedLevel > 0)
selectedLevel --;
}
else if(Gdx.input.getX() > Gdx.graphics.getWidth() * 0.8){
if(selectedLevel < levelPreview.length)
selectedLevel ++;
}
else{
dispose();
game.setScreen(new Gamescreen(game));
}
} }
} }
@ -62,6 +123,7 @@ public class Levelscreen extends AbstractScreen{
@Override @Override
public void dispose() { public void dispose() {
t.clear();
} }
} }

@ -14,6 +14,7 @@ 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.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Timer;
/** /**
* *
@ -23,16 +24,34 @@ public class Titlescreen extends AbstractScreen{
BitmapFont font; BitmapFont font;
SpriteBatch batch; SpriteBatch batch;
Timer t;
Sprite clicktostart; Sprite clicktostart;
boolean movement;
public Titlescreen(Game game){ public Titlescreen(Game game){
super(game); super(game);
movement = true;
batch = new SpriteBatch(); batch = new SpriteBatch();
clicktostart = new Sprite(new Texture(Gdx.files.internal("clicktostart.png"))); clicktostart = new Sprite(new Texture(Gdx.files.internal("clicktostart.png")));
clicktostart.setX(Gdx.graphics.getWidth() / 2 - clicktostart.getWidth() / 2); clicktostart.setX(Gdx.graphics.getWidth() / 2 - clicktostart.getWidth() / 2);
clicktostart.setY(Gdx.graphics.getHeight() / 2 - clicktostart.getHeight() / 2); clicktostart.setY(Gdx.graphics.getHeight() / 2 - clicktostart.getHeight() / 2);
t = new Timer();
t.scheduleTask(new Timer.Task() {
@Override
public void run() {
if(clicktostart.getY() < Gdx.graphics.getHeight() * 0.4)
movement = true;
else if(clicktostart.getY() > Gdx.graphics.getHeight() * 0.5)
movement = false;
if(movement)
clicktostart.setY(clicktostart.getY() + 3);
else
clicktostart.setY(clicktostart.getY() - 3);
}
},0 , 0.035f);
} }
@Override @Override
@ -45,9 +64,11 @@ public class Titlescreen extends AbstractScreen{
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin(); batch.begin();
clicktostart.draw(batch);
batch.end(); batch.end();
if(Gdx.input.justTouched()){ if(Gdx.input.justTouched()){
dispose();
game.setScreen(new Levelscreen(game)); game.setScreen(new Levelscreen(game));
} }
} }
@ -70,5 +91,6 @@ public class Titlescreen extends AbstractScreen{
@Override @Override
public void dispose() { public void dispose() {
t.clear();
} }
} }

Loading…
Cancel
Save