Commit c97fe6a8 authored by Fjen Undso's avatar Fjen Undso
Browse files

gamescreen: fix shotangle and bounds

parent 66dd2436
......@@ -6,6 +6,7 @@ import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.Sprite;
......@@ -83,7 +84,7 @@ public class GameScreen implements Screen {
panel = new Sprite(FrozenNumbersGame.assets.get("panel_blue.png", Texture.class));
panel.setX(0);
panel.setSize(wWidth, bubblradius * 2 + bubblradius);
m_Bounds = new Rectangle(bubblradius, bubblradius, (float) wWidth - bubblradius, (float) wHeight - bubblradius);
m_Bounds = new Rectangle(0, bubblradius, (float) wWidth, (float) wHeight - bubblradius);
//bg = new Sprite(FrozenNumbersGame.assets.get("border.png", Texture.class));
......@@ -146,7 +147,7 @@ public class GameScreen implements Screen {
FrozenNumbersGame.viewport.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY()));
if (p.active != null) {
if (!p.active.isFlying && lower && touchPoint.y < bound) {
Vector2 star = new Vector2(touchPoint.x, wHeight - touchPoint.y);
Vector2 star = new Vector2(touchPoint.x, touchPoint.y);
Vector2 ssrc = new Vector2(wWidth / 2, bubblradius * 2);
Vector2 speed = star.cpy().sub(ssrc).nor();
speed.set(speed.x, Math.abs(speed.y));
......@@ -156,7 +157,7 @@ public class GameScreen implements Screen {
FrozenNumbersGame.assets.get("snd/shot.mp3", Sound.class).play();
}
if (!p.active.isFlying && !lower && touchPoint.y > bound) {
Vector2 star = new Vector2(touchPoint.x, wHeight - touchPoint.y);
Vector2 star = new Vector2(touchPoint.x, touchPoint.y);
Vector2 ssrc = new Vector2(wWidth / 2, wHeight - bubblradius * 2);
Vector2 speed = star.cpy().sub(ssrc).nor();
speed.set(speed.x, -1 * Math.abs(speed.y));
......@@ -291,7 +292,10 @@ public class GameScreen implements Screen {
}
renderer.end();
FrozenNumbersGame.batch.begin();
Batch batch = FrozenNumbersGame.batch;
FrozenNumbersGame.viewport.apply(true);
batch.setProjectionMatrix(FrozenNumbersGame.viewport.getCamera().combined);
batch.begin();
// for (Hexagon hexagon : map.getHexagons().values()) {
// comb.setCenter((float)hexagon.getCenterX(), (float)hexagon.getCenterY());
......@@ -300,65 +304,65 @@ public class GameScreen implements Screen {
//bg.draw(FrozenNumbersGame.batch);
panel.setY(0);
panel.draw(FrozenNumbersGame.batch);
panel.draw(batch);
//border.flip(false,true);
panel.setY(wHeight - panel.getHeight());
panel.draw(FrozenNumbersGame.batch);
panel.draw(batch);
border.setRotation(0);
border.setScale(1, 1);
border.setCenterY(wHeight * 0.5f);
border.draw(FrozenNumbersGame.batch);
border.draw(batch);
border.setScale(1, 1);
border.setCenterY(p1.sPos.y + bubblradius);
border.draw(FrozenNumbersGame.batch);
border.draw(batch);
//border.flip(false,true);
border.setScale(1, -1);
border.setCenterY(p2.sPos.y - bubblradius);
border.draw(FrozenNumbersGame.batch);
border.draw(batch);
border.draw(FrozenNumbersGame.batch);
border.draw(batch);
if (p1.active != null) {
p1.active.draw(FrozenNumbersGame.batch);
p1.active.draw(batch);
drawTextCentered(String.valueOf(p1.active.getValue()), p1.active.getPos().x, p1.active.getPos().y);
}
if (p1.next != null) {
p1.next.draw(FrozenNumbersGame.batch);
p1.next.draw(batch);
drawTextCentered(String.valueOf(p1.next.getValue()), p1.next.getPos().x, p1.next.getPos().y);
}
if (p2.active != null) {
p2.active.draw(FrozenNumbersGame.batch);
p2.active.draw(batch);
drawTextCentered(String.valueOf(p2.active.getValue()), p2.active.getPos().x, p2.active.getPos().y);
}
if (p2.next != null) {
p2.next.draw(FrozenNumbersGame.batch);
p2.next.draw(batch);
drawTextCentered(String.valueOf(p2.next.getValue()), p2.next.getPos().x, p2.next.getPos().y);
}
for (Bubble bubble : nachbarn.values()) {
bubble.draw(FrozenNumbersGame.batch);
bubble.draw(batch);
drawTextCentered(String.valueOf(bubble.getValue()), bubble.getPos().x, bubble.getPos().y);
}
FrozenNumbersGame.assets.get("size20.ttf", BitmapFont.class).draw(FrozenNumbersGame.batch, lastpoint, 10, 40);
FrozenNumbersGame.assets.get("size20.ttf", BitmapFont.class).draw(FrozenNumbersGame.batch, String.valueOf(p1.score), 60, 20);
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));
Table container = new Table();
container.setTransform(true);
container.add(p2ScoreLabel);
container.setRotation(180);
container.setPosition(Gdx.graphics.getWidth() - 60, Gdx.graphics.getHeight() - 10);
container.draw(FrozenNumbersGame.batch, 1);
FrozenNumbersGame.batch.end();
container.setPosition(wWidth - 60, wHeight - 10);
container.draw(batch, 1);
batch.end();
}
private void drawTextCentered(String text, float x, float y) {
......
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