Commit 9bb0ae59 authored by Nils Hein's avatar Nils Hein
Browse files

Merge branch 'master' of git.finf.uni-hannover.de:MilderJoghurt/FrozenNumbers

Conflicts:
	core/src/org/milderjoghurt/frozennumbers/screens/GameScreen.java
parents a2067556 6b66dad5
......@@ -91,6 +91,7 @@ public class FrozenNumbersGame extends ApplicationAdapter {
assets.load("snd/shot.mp3", Sound.class);
assets.load("snd/theme.ogg", Music.class);
assets.load("snd/pop.mp3", Sound.class);
assets.load("snd/pat.mp3", Sound.class);
assets.finishLoading();
......
......@@ -16,10 +16,13 @@ import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import org.milderjoghurt.frozennumbers.FrozenNumbersGame;
import org.milderjoghurt.frozennumbers.screens.GameScreen.Player;
import java.util.Map;
public class GameOverScreen implements Screen {
Player winner;
Game game;
public static Map<String, Screen> m_Screens;
Sprite bg;
......@@ -30,9 +33,10 @@ public class GameOverScreen implements Screen {
float wWidth;
GlyphLayout glyphLayout = new GlyphLayout();
public GameOverScreen(int p1Score, int p2Score) {
public GameOverScreen(int p1Score, int p2Score, Player winner) {
p1 = p1Score;
p2 = p2Score;
this.winner = winner;
wWidth = FrozenNumbersGame.viewport.getWorldWidth();
wHeight = FrozenNumbersGame.viewport.getWorldHeight();
......@@ -102,6 +106,13 @@ public class GameOverScreen implements Screen {
p1String = "DRAW";
p2String = "DRAW";
}
/*if (winner.lower){
p1String = "WIN";
p2String = "LOSE";
} else{
p2String = "WIN";
p1String = "LOSE";
}*/
// Draw Players Results
Table container = new Table();
......
......@@ -40,6 +40,7 @@ public class GameScreen implements Screen {
public Vector2 sPos;
public int score = 0;
float timer = 0;
boolean lower;
}
Player p1 = new Player();
......@@ -58,6 +59,8 @@ public class GameScreen implements Screen {
private Rectangle m_Bounds;
float wWidth, wHeight;
float timerDefault = 5;
boolean firstMoveP1 = true;
boolean firstMoveP2 = true;
private Hexagon getCurrentHex(Bubble b) {
Vector2 p = b.getPos();
......@@ -68,6 +71,9 @@ public class GameScreen implements Screen {
wWidth = FrozenNumbersGame.viewport.getWorldWidth();
wHeight = FrozenNumbersGame.viewport.getWorldHeight();
p1.lower = true;
p2.lower = false;
nachbarn = new HashMap<Hexagon, Bubble>();
removes = new ArrayList<Hexagon>();
frozenHexagons = new ArrayList<Hexagon>();
......@@ -151,7 +157,6 @@ public class GameScreen implements Screen {
p.active = new Bubble(p.sPos.cpy());
p.active.setSize(bubbleradius * 2, bubbleradius * 2);
p.active.setCenter(p.sPos.x, p.sPos.y);
}
if (Gdx.input.justTouched()) {
......@@ -270,11 +275,13 @@ public class GameScreen implements Screen {
{
p.score+=points;
iterator.remove();
p2.timer=0;
}
if(y > wHeight - 3* bubbleradius && !lower)
{
p.score+=points;
iterator.remove();
p1.timer=0;
}
}
}
......@@ -349,22 +356,39 @@ public class GameScreen implements Screen {
}
}
boolean checkForEmptyP1 = true;//lower
boolean checkForEmptyP2 = true;//upper
for(Hexagon h : nachbarn.keySet())
{
if(nachbarn.get(h)!=null)
{
double y = h.getCenterY();
if(y > wHeight-3* bubbleradius)
if(y > wHeight-3*bubbleradius)
{
FrozenNumbersGame.m_Screens.put("GameOverScreen", new GameOverScreen(p1.score, p2.score/2));
FrozenNumbersGame.m_Screens.put("GameOverScreen", new GameOverScreen(p1.score, p2.score/2, p1));
FrozenNumbersGame.game.setScreen(FrozenNumbersGame.m_Screens.get("GameOverScreen"));
} else if(y < 4* bubbleradius){
FrozenNumbersGame.m_Screens.put("GameOverScreen", new GameOverScreen(p1.score/2, p2.score));
}else if(y < 4*bubbleradius){
FrozenNumbersGame.m_Screens.put("GameOverScreen", new GameOverScreen(p1.score/2, p2.score, p2));
FrozenNumbersGame.game.setScreen(FrozenNumbersGame.m_Screens.get("GameOverScreen"));
}
}
/*if(h.getCenterY()< wHeight / 2.0f){
checkForEmptyP1 = false;
firstMoveP1 = false;
}
if((h.getCenterY()-20)> wHeight / 2.0f){
checkForEmptyP2 = false;
firstMoveP2 = false;
}*/
}
/*if(!firstMoveP1 && checkForEmptyP1) {
FrozenNumbersGame.m_Screens.put("GameOverScreen", new GameOverScreen(p1.score, p2.score, p1));
FrozenNumbersGame.game.setScreen(FrozenNumbersGame.m_Screens.get("GameOverScreen"));
}
if(!firstMoveP2 && checkForEmptyP2) {
FrozenNumbersGame.m_Screens.put("GameOverScreen", new GameOverScreen(p1.score, p2.score, p2));
FrozenNumbersGame.game.setScreen(FrozenNumbersGame.m_Screens.get("GameOverScreen"));
}*/
FrozenNumbersGame.viewport.apply(true);
......
......@@ -91,6 +91,7 @@ public class MainMenuScreen implements Screen {
p1_ready.setTexture(FrozenNumbersGame.assets.get("sprites/btn_ready_inactive.png", Texture.class));
p1_ready.setColor(1, 1, 1, 1);
}
FrozenNumbersGame.assets.get("snd/pat.mp3", Sound.class).play();
}
//Clicking Ready Button p2
if (p2_ready.getBoundingRectangle().contains(touchPoint.x, touchPoint.y)) {
......@@ -99,10 +100,12 @@ public class MainMenuScreen implements Screen {
if (p2_isready) {
p2_ready.setTexture(FrozenNumbersGame.assets.get("sprites/btn_ready_active.png", Texture.class));
p2_ready.setColor(0, 0.8f, 0, 1);
FrozenNumbersGame.assets.get("snd/pat.mp3", Sound.class).play();
} else {
p2_ready.setTexture(FrozenNumbersGame.assets.get("sprites/btn_ready_inactive.png", Texture.class));
p2_ready.setColor(1, 1, 1, 1);
}
FrozenNumbersGame.assets.get("snd/pat.mp3", Sound.class).play();
}
//clicking questionmark buttons
if ((p1_quest.getBoundingRectangle().contains(touchPoint.x, touchPoint.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