Commit 8c14b3df authored by Fjen Undso's avatar Fjen Undso
Browse files

gamescreen: add next label to top player. score has now 2 rows

parent 96925c6e
......@@ -54,7 +54,7 @@ public class GameScreen implements Screen {
ShapeRenderer renderer = new ShapeRenderer();
float bound = 0;
Sprite bg, bgOverlay;
Sprite next;
Sprite nextTop, nextBottom;
Vector2 mapoffset;
private Rectangle m_Bounds;
float wWidth, wHeight;
......@@ -77,7 +77,7 @@ public class GameScreen implements Screen {
bubblradius = wWidth / 14;
m_Bounds = new Rectangle(0, bubblradius, (float) wWidth, (float) wHeight - bubblradius);
m_Bounds = new Rectangle(0, bubblradius, wWidth, wHeight - bubblradius);
bg = new Sprite(FrozenNumbersGame.assets.get("backgrounds/background.jpg", Texture.class));
float scaleX = wWidth / bg.getWidth();
......@@ -89,9 +89,14 @@ public class GameScreen implements Screen {
bgOverlay.setScale(scaleX, scaleY);
bgOverlay.setCenter(wWidth / 2.0f, wHeight / 2.0f);
next = new Sprite(FrozenNumbersGame.assets.get("sprites/btn_next.png", Texture.class));
next.setScale(scaleX, scaleY);
next.setCenter(wWidth / 4.0f, wHeight * 0.05f);
nextBottom = new Sprite(FrozenNumbersGame.assets.get("sprites/btn_next.png", Texture.class));
nextBottom.setScale(scaleX, scaleY);
nextBottom.setCenter(wWidth / 4.0f, wHeight * 0.05f);
nextTop = new Sprite(FrozenNumbersGame.assets.get("sprites/btn_next.png", Texture.class));
nextTop.setScale(scaleX, scaleY);
nextTop.rotate(180);
nextTop.setCenter(wWidth / 4.0f * 3.0f, wHeight * 0.95f);
hexbulder.setGridHeight(15);
hexbulder.setGridWidth(11);
......@@ -105,7 +110,7 @@ public class GameScreen implements Screen {
bound = wHeight / 2f;//float) map.getByGridCoordinate(0, 6 ).getCenterY();
p1.sPos = new Vector2(wWidth / 2.0f, 100 * scaleY);
p2.sPos = new Vector2(wWidth / 2.0f, wHeight - 100 * scaleY);
p1.timer = timerDefault;
p2.timer = timerDefault;
}
......@@ -231,7 +236,7 @@ public class GameScreen implements Screen {
}
}
//Moving falling Bubbles
for (Iterator<Bubble> iterator = fallingBubbles.iterator(); iterator.hasNext(); ) {
Bubble b = iterator.next();
......@@ -240,7 +245,7 @@ public class GameScreen implements Screen {
b.setForce(speed.scl(25));
b.isFlying = true;
b.Update(0.1f);
//Scoring and deleting Bubble
int points = 25;
float y = b.getPos().y;
......@@ -263,7 +268,7 @@ public class GameScreen implements Screen {
p1.timer -= delta;
p2.timer -= delta;
playerlogic(p1, true);
playerlogic(p2, false);
......@@ -327,7 +332,7 @@ public class GameScreen implements Screen {
checkLooseBubbles();
}
}
for(Hexagon h : nachbarn.keySet())
{
if(nachbarn.get(h)!=null)
......@@ -340,7 +345,7 @@ public class GameScreen implements Screen {
}
}
}
FrozenNumbersGame.viewport.apply(true);
......@@ -354,7 +359,8 @@ public class GameScreen implements Screen {
batch.begin();
bg.draw(batch);
bgOverlay.draw(batch);
next.draw(batch);
nextTop.draw(batch);
nextBottom.draw(batch);
if (p1.active != null) {
p1.active.draw(batch);
......@@ -370,31 +376,50 @@ public class GameScreen implements Screen {
bubble.draw(batch);
drawTextCentered(String.valueOf(bubble.getValue()), bubble.getPos().x, bubble.getPos().y, bubble.getColor());
}
for (Bubble bubble : fallingBubbles) {
bubble.draw(batch);
drawTextCentered(String.valueOf(bubble.getValue()), bubble.getPos().x, bubble.getPos().y, bubble.getColor());
}
FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class).draw(batch, lastpoint, 10, 40);
FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class).draw(batch, "Score " + String.valueOf(p1.score), wWidth - 140, 40);
Label p2ScoreLabel = new Label("Score " + String.valueOf(p2.score), new Label.LabelStyle(FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class), Color.WHITE));
// Player Scores
Table container = new Table();
Label scoreLabel = new Label("Score:", new Label.LabelStyle(FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class), Color.WHITE));
Label scorePoints = new Label(null, new Label.LabelStyle(FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class), Color.WHITE));
// Bottom Player
container.add(scoreLabel);
container.setPosition(wWidth * 0.8f, wHeight * 0.05f + 15);
container.draw(batch, 1);
container.clearChildren();
scorePoints.setText(String.valueOf(p1.score));
container.add(scorePoints);
container.setPosition(wWidth * 0.8f, wHeight * 0.05f - 15);
container.draw(batch, 1);
// Top Player
container.setTransform(true);
container.add(p2ScoreLabel);
container.setRotation(180);
container.setPosition(70, wHeight - 30);
container.clearChildren();
container.add(scoreLabel);
container.setPosition(wWidth * 0.2f, wHeight * 0.95f - 15);
container.draw(batch, 1);
container.clearChildren();
scorePoints.setText(String.valueOf(p2.score));
container.add(scorePoints);
container.setPosition(wWidth * 0.2f, wHeight * 0.95f + 15);
container.draw(batch, 1);
batch.end();
}
private void checkLooseBubbles() {
LinkedList<Hexagon> middleHexagons = new LinkedList<Hexagon>();
ArrayList<Hexagon> connectedHexagons = new ArrayList<Hexagon>();
// visitedHexagon
Rectangle MiddleRectangle = new Rectangle(0,(float) (wHeight/2.0 - 2*bubblradius),wWidth,4*bubblradius);
// Getting hexagons with bubbles connected to the middle
for (Hexagon h : nachbarn.keySet()) {
Bubble b = (nachbarn.get(h));
......@@ -418,7 +443,7 @@ public class GameScreen implements Screen {
for (Iterator<Hexagon> iterator = nachbarn.keySet().iterator(); iterator.hasNext(); ) {
Hexagon hex = iterator.next();
Bubble b = (nachbarn.get(hex));
if (b != null && !b.isFrozen() && !connectedHexagons.contains(hex)) {
if (b != null && !b.isFrozen() && !connectedHexagons.contains(hex)) {
Vector2 speed = new Vector2(0,(float) -(wHeight/2.0 - b.getPos().y)).nor();
b.setVel(speed.cpy().scl(50.0f));
b.setForce(speed.scl(50));
......@@ -428,8 +453,8 @@ public class GameScreen implements Screen {
iterator.remove();
}
}
}
private void drawTextCentered(String text, float x, float y, Color c) {
......@@ -438,20 +463,20 @@ public class GameScreen implements Screen {
Label myLabel2 = new Label(text, new Label.LabelStyle(FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class), c));
myLabel.setSize(bubblradius/2,bubblradius/4);
myLabel2.setSize(bubblradius/2,bubblradius/4);
myLabel2.setSize(bubblradius / 2, bubblradius / 4);
myLabel.setScale(0.5f);
myLabel2.setScale(0.5f);
myLabel2.setPosition(x-myLabel.getWidth()*0.5f,y-myLabel.getWidth());
myLabel2.setPosition(x - myLabel.getWidth() * 0.5f, y - myLabel.getWidth());
Group g = new Group();
rotaater = g;
g.addActor(myLabel);
g.setSize(bubblradius,bubblradius);
g.setPosition(x+myLabel.getWidth()*0.5f,y+myLabel.getWidth());
g.setSize(bubblradius, bubblradius);
g.setPosition(x + myLabel.getWidth() * 0.5f, y + myLabel.getWidth());
rotaater.setRotation(180);
g.draw(FrozenNumbersGame.batch,1);
g.draw(FrozenNumbersGame.batch, 1);
myLabel2.draw(FrozenNumbersGame.batch,1);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment