Commit 4efcdf25 authored by Nils Hein's avatar Nils Hein
Browse files

Sprites in GameScreen hinzugefügt

parent 80fe95dc
......@@ -42,7 +42,7 @@ public class Bubble extends Sprite {
}
public Bubble(Vector2 pos) {
this((new Random()).nextInt(10), "data/Bubble.png", pos, new Sprite(FrozenNumbersGame.assets.get("Bubble.png", Texture.class)));
this((new Random()).nextInt(10), "data/sprites/bubble.png", pos, new Sprite(FrozenNumbersGame.assets.get("sprites/bubble.png", Texture.class)));
}
public Bubble(Bubble next) {
......@@ -50,7 +50,7 @@ public class Bubble extends Sprite {
}
public Bubble() {
this((new Random()).nextInt(10), "data/Bubble.png", null, new Sprite(FrozenNumbersGame.assets.get("Bubble.png", Texture.class)));
this((new Random()).nextInt(10), "data/sprites/bubble.png", null, new Sprite(FrozenNumbersGame.assets.get("sprites/bubble.png", Texture.class)));
}
public Bubble(int value, String name, Vector2 pos, Sprite sprite) {
......@@ -60,14 +60,13 @@ public class Bubble extends Sprite {
this.value = value;
this.vel = new Vector2(0, 0);
this.force = new Vector2(0, 0);
HSL c = new HSL(value * 0.1f, 1f, 0.5f, 1f);
HSL c = new HSL(value * 0.1f, 0.6f, 0.5f, 1f);
this.setColor(c.toRGB());
}
@Override
public void draw(Batch batch) {
super.draw(batch);
batch.draw(FrozenNumbersGame.assets.get("BubbleTop.png", Texture.class), this.getX(), getY(), getWidth(), getHeight());
}
public void Update(float dt) {
......@@ -111,7 +110,7 @@ public class Bubble extends Sprite {
}
public void setFrozen(float s) {
Color c = new Color(0, 0, 0, 1);
Color c = new Color(1, 1, 1, 1);
this.setColor(c.getRGB());
frozen = true;
frozen_s = s;
......
......@@ -52,7 +52,7 @@ public class GameScreen implements Screen {
Map<Hexagon, Bubble> nachbarn;
ShapeRenderer renderer = new ShapeRenderer();
float bound = 0;
//Sprite bg;
Sprite bg;
Sprite comb;
Vector2 mapoffset;
private Rectangle m_Bounds;
......@@ -76,20 +76,15 @@ public class GameScreen implements Screen {
bubblradius = wWidth / 14;
border = new Sprite(FrozenNumbersGame.assets.get("border2.png", Texture.class));
border.setX(0);
border.setSize(wWidth, 28);
panel = new Sprite(FrozenNumbersGame.assets.get("panel_blue.png", Texture.class));
panel.setX(0);
panel.setSize(wWidth, bubblradius * 2 + bubblradius);
m_Bounds = new Rectangle(0, bubblradius, (float) wWidth, (float) wHeight - bubblradius);
//bg = new Sprite(FrozenNumbersGame.assets.get("border.png", Texture.class));
bg = new Sprite(FrozenNumbersGame.assets.get("backgrounds/game-screen.png", Texture.class));
bg.setSize(wWidth, wHeight);
bg.setCenter(wWidth / 2.0f, wHeight / 2.0f);
//bg.setSize(wWidth, wHeight);
//bg.setCenter(wWidth / 2.0f, wHeight / 2.0f);
//bg.setColor(Color.LIGHT_GRAY);
comb = new Sprite(FrozenNumbersGame.assets.get("comb.png", Texture.class));
comb.setSize(bubblradius * 2, bubblradius * 2);
comb.setAlpha(0.0f);
......@@ -105,8 +100,8 @@ public class GameScreen implements Screen {
mapoffset = new Vector2(0, (wHeight / 2.0f) - (float) test.getCenterY());
bound = wHeight / 2f;//float) map.getByGridCoordinate(0, 6 ).getCenterY();
p1.sPos = new Vector2(new Vector2(wWidth / 2.0f, bubblradius * 2));
p2.sPos = new Vector2(new Vector2(wWidth / 2.0f, wHeight - (bubblradius * 2)));
p1.sPos = new Vector2(new Vector2(wWidth / 2.0f, bubblradius+5));
p2.sPos = new Vector2(new Vector2(wWidth / 2.0f, wHeight - (bubblradius+5)));
}
......@@ -274,112 +269,70 @@ public class GameScreen implements Screen {
FrozenNumbersGame.viewport.apply(true);
Gdx.gl.glClearColor(0.58f, 0.8f, 1f, 1f);
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderer.setProjectionMatrix(FrozenNumbersGame.viewport.getCamera().combined);
renderer.begin(ShapeType.Line);
renderer.setColor(0.48f, 0.7f, 0.9f, 1f);
Gdx.gl.glLineWidth(5);
for (Hexagon hexagon : map.getHexagons().values()) {
renderer.circle(getHexCenter(hexagon).x, getHexCenter(hexagon).y, bubblradius, 12);
}
renderer.end();
Batch batch = FrozenNumbersGame.batch;
batch.setProjectionMatrix(FrozenNumbersGame.viewport.getCamera().combined);
batch.begin();
// for (Hexagon hexagon : map.getHexagons().values()) {
// comb.setCenter((float)hexagon.getCenterX(), (float)hexagon.getCenterY());
// comb.draw(FrozenNumbersGame.batch);
// }
//bg.draw(FrozenNumbersGame.batch);
panel.setY(0);
panel.draw(batch);
//border.flip(false,true);
panel.setY(wHeight - panel.getHeight());
panel.draw(batch);
border.setRotation(0);
border.setScale(1, 1);
border.setCenterY(wHeight * 0.5f);
border.draw(batch);
border.setScale(1, 1);
border.setCenterY(p1.sPos.y + bubblradius);
border.draw(batch);
//border.flip(false,true);
border.setScale(1, -1);
border.setCenterY(p2.sPos.y - bubblradius);
border.draw(batch);
border.draw(batch);
bg.draw(batch);
if (p1.active != null) {
p1.active.draw(batch);
drawTextCentered(String.valueOf(p1.active.getValue()), p1.active.getPos().x, p1.active.getPos().y);
drawTextCentered(String.valueOf(p1.active.getValue()), p1.active.getPos().x, p1.active.getPos().y,p1.active.getColor());
}
if (p1.next != null) {
p1.next.draw(batch);
drawTextCentered(String.valueOf(p1.next.getValue()), p1.next.getPos().x, p1.next.getPos().y);
drawTextCentered(String.valueOf(p1.next.getValue()), p1.next.getPos().x, p1.next.getPos().y,p1.next.getColor());
}
if (p2.active != null) {
p2.active.draw(batch);
drawTextCentered(String.valueOf(p2.active.getValue()), p2.active.getPos().x, p2.active.getPos().y);
drawTextCentered(String.valueOf(p2.active.getValue()), p2.active.getPos().x, p2.active.getPos().y,p2.active.getColor());
}
if (p2.next != null) {
p2.next.draw(batch);
drawTextCentered(String.valueOf(p2.next.getValue()), p2.next.getPos().x, p2.next.getPos().y);
drawTextCentered(String.valueOf(p2.next.getValue()), p2.next.getPos().x, p2.next.getPos().y,p2.next.getColor());
}
for (Bubble bubble : nachbarn.values()) {
bubble.draw(batch);
drawTextCentered(String.valueOf(bubble.getValue()), bubble.getPos().x, bubble.getPos().y);
drawTextCentered(String.valueOf(bubble.getValue()), bubble.getPos().x, bubble.getPos().y,bubble.getColor());
}
FrozenNumbersGame.assets.get("size20.ttf", BitmapFont.class).draw(batch, lastpoint, 10, 40);
FrozenNumbersGame.assets.get("size20.ttf", BitmapFont.class).draw(batch, String.valueOf(p1.score), 60, 20);
Label p2ScoreLabel = new Label(String.valueOf(p2.score), new Label.LabelStyle(FrozenNumbersGame.assets.get("size20.ttf", BitmapFont.class), Color.WHITE));
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));
Table container = new Table();
container.setTransform(true);
container.add(p2ScoreLabel);
container.setRotation(180);
container.setPosition(wWidth - 60, wHeight - 10);
container.setPosition(70, wHeight - 30);
container.draw(batch, 1);
batch.end();
}
private void drawTextCentered(String text, float x, float y) {
private void drawTextCentered(String text, float x, float y, Color c ) {
GlyphLayout layout = new GlyphLayout();
layout.setText(FrozenNumbersGame.assets.get("size20.ttf", BitmapFont.class), text);
layout.setText(FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class), text);
Actor rotaater;
Label myLabel = new Label(text, new Label.LabelStyle(FrozenNumbersGame.assets.get("size20.ttf", BitmapFont.class), Color.WHITE));
Label myLabel = new Label(text, new Label.LabelStyle(FrozenNumbersGame.assets.get("size20.ttf", BitmapFont.class), c));
Table container = new Table();
container.setTransform(true);
container.add(myLabel);
rotaater = container;
rotaater.setPosition(x - rotaater.getWidth() / 2, (y - bubblradius / 4) + bubblradius / 2);
rotaater.setPosition(x - (rotaater.getWidth() / 2), (y - bubblradius / 4) + bubblradius / 2);
rotaater.setRotation(180);
rotaater.draw(FrozenNumbersGame.batch, 1);
myLabel.setPosition(x - myLabel.getWidth() / 2, (y - bubblradius / 4) - bubblradius / 2);
myLabel.setPosition(x - (myLabel.getWidth() / 2), (y - bubblradius / 4) - bubblradius / 2);
myLabel.draw(FrozenNumbersGame.batch, 1);
//FrozenNumbersGame.assets.get("size20.ttf", BitmapFont.class).draw(FrozenNumbersGame.batch, layout, x-layout.width/2, y+layout.height/2);
}
@Override
......
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