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

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

parents 5ae29c12 8d231aea
......@@ -2,6 +2,7 @@ package org.milderjoghurt.frozennumbers.android;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
......@@ -11,6 +12,7 @@ public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new FrozenNumbersGame(), config);
}
......
......@@ -19,7 +19,6 @@ import com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import org.milderjoghurt.frozennumbers.screens.MainMenuScreen;
import java.util.HashMap;
......@@ -89,7 +88,7 @@ public class FrozenNumbersGame extends ApplicationAdapter {
// sounds
assets.load("snd/hit.mp3", Sound.class);
assets.load("snd/shot.mp3", Sound.class);
assets.load("snd/load.wav", Sound.class);
assets.load("snd/theme.ogg", Sound.class);
assets.load("snd/pop.mp3", Sound.class);
assets.finishLoading();
......
......@@ -9,6 +9,7 @@ import org.milderjoghurt.frozennumbers.FrozenNumbersGame;
import org.milderjoghurt.frozennumbers.util.HSL;
import com.badlogic.gdx.graphics.Color;
import java.util.Random;
public class Bubble extends Sprite {
......@@ -125,10 +126,10 @@ public class Bubble extends Sprite {
return (frozen_s <= 0);
}
public void setFalling() {
this.setColor(Color.GRAY);
falling = true;
}
public void setFalling() {
this.setColor(Color.GRAY);
falling = true;
}
}
package org.milderjoghurt.frozennumbers.screens;
import java.util.Map;
import org.milderjoghurt.frozennumbers.FrozenNumbersGame;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
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;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.math.Vector2;
public class GameOverScreen implements Screen {
Game game;
public static Map<String,Screen> m_Screens;
Sprite bg;
int p1 = 0;
int p2 = 0;
Sprite closeTop, closeBottom;
float wHeight;
float wWidth;
GlyphLayout glyphLayout = new GlyphLayout();
public GameOverScreen(int p1Score,int p2Score) {
p1 = p1Score;
p2 = p2Score;
wWidth = FrozenNumbersGame.viewport.getWorldWidth();
wHeight = FrozenNumbersGame.viewport.getWorldHeight();
game = FrozenNumbersGame.game;
m_Screens = FrozenNumbersGame.m_Screens;
//generating backround
bg = new Sprite(FrozenNumbersGame.assets.get("backgrounds/background.jpg", Texture.class));
float scaleX = wWidth / bg.getWidth();
float scaleY = wHeight / bg.getHeight();
bg.setScale(scaleX, scaleY);
bg.setCenter(wWidth / 2.0f, wHeight / 2.0f);
//generating Close button
closeBottom = new Sprite(FrozenNumbersGame.assets.get("sprites/btn_back.png", Texture.class));
closeBottom.setScale(scaleX, scaleY);
closeBottom.setCenter(wWidth / 4.0f, wHeight / 2.0f);
closeTop = new Sprite(FrozenNumbersGame.assets.get("sprites/btn_back.png", Texture.class));
closeTop.setScale(scaleX, scaleY);
closeTop.rotate(180);
closeTop.setCenter(wWidth / 4.0f * 3.0f, wHeight / 2.0f);
}
@Override
public void show() {
// TODO Auto-generated method stub
}
@Override
public void render(float delta) {
if (Gdx.input.justTouched()) {
Vector2 touchPoint = new Vector2();
FrozenNumbersGame.viewport.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY()));
//Clicking Close Button
if(closeBottom.getBoundingRectangle().contains(touchPoint.x, touchPoint.y) ||
closeTop.getBoundingRectangle().contains(touchPoint.x, touchPoint.y)) {
game.setScreen(m_Screens.get("MainMenu"));
}
}
// Drawing Stuff
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
Batch batch = FrozenNumbersGame.batch;
FrozenNumbersGame.viewport.apply(true);
batch.setProjectionMatrix(FrozenNumbersGame.viewport.getCamera().combined);
batch.begin();
bg.draw(batch);
closeBottom.draw(batch);
closeTop.draw(batch);
String p1String = new String();
String p2String = new String();
if(p1 > p2)
{
p1String = "WIN";
p2String = "LOSE";
}
if(p2 > p1)
{
p1String = "LOSE";
p2String = "WIN";
}
if(p2 == p1)
{
p1String = "DRAW";
p2String = "DRAW";
}
// Draw Players Results
Table container = new Table();
Label winLoose = new Label(null, new Label.LabelStyle(FrozenNumbersGame.assets.get("size60.ttf", BitmapFont.class), Color.WHITE));
Label points = new Label(null, new Label.LabelStyle(FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class), Color.WHITE));
// Bottom Player
winLoose.setText(p1String);
container.add(winLoose);
container.setPosition((wWidth / 2), wHeight / 4 + 30);
container.draw(batch, 1);
points.setText(p1 + " Points");
container.clearChildren();
container.add(points);
container.setPosition((wWidth / 2), wHeight / 4 - 30);
container.draw(batch, 1);
// Top Player
container.setTransform(true);
container.setRotation(180);
winLoose.setText(p2String);
container.clearChildren();
container.add(winLoose);
container.setPosition((wWidth / 2), wHeight / 4 * 3 - 30);
container.draw(batch, 1);
points.setText(p2 + " Points");
container.clearChildren();
container.add(points);
container.setPosition((wWidth / 2), wHeight / 4 * 3 + 30);
container.draw(batch, 1);
batch.end();
}
@Override
public void resize(int width, int height) {
wWidth = FrozenNumbersGame.viewport.getWorldWidth();
wHeight = FrozenNumbersGame.viewport.getWorldHeight();
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
@Override
public void hide() {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
}
package org.milderjoghurt.frozennumbers.screens;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
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;
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 java.util.Map;
public class GameOverScreen implements Screen {
Game game;
public static Map<String, Screen> m_Screens;
Sprite bg;
int p1 = 0;
int p2 = 0;
Sprite closeTop, closeBottom;
float wHeight;
float wWidth;
GlyphLayout glyphLayout = new GlyphLayout();
public GameOverScreen(int p1Score, int p2Score) {
p1 = p1Score;
p2 = p2Score;
wWidth = FrozenNumbersGame.viewport.getWorldWidth();
wHeight = FrozenNumbersGame.viewport.getWorldHeight();
game = FrozenNumbersGame.game;
m_Screens = FrozenNumbersGame.m_Screens;
//generating backround
bg = new Sprite(FrozenNumbersGame.assets.get("backgrounds/background.jpg", Texture.class));
float scaleX = wWidth / bg.getWidth();
float scaleY = wHeight / bg.getHeight();
bg.setScale(scaleX, scaleY);
bg.setCenter(wWidth / 2.0f, wHeight / 2.0f);
//generating Close button
closeBottom = new Sprite(FrozenNumbersGame.assets.get("sprites/btn_back.png", Texture.class));
closeBottom.setScale(scaleX, scaleY);
closeBottom.setCenter(wWidth / 4.0f, wHeight / 2.0f);
closeTop = new Sprite(FrozenNumbersGame.assets.get("sprites/btn_back.png", Texture.class));
closeTop.setScale(scaleX, scaleY);
closeTop.rotate(180);
closeTop.setCenter(wWidth / 4.0f * 3.0f, wHeight / 2.0f);
}
@Override
public void show() {
// TODO Auto-generated method stub
}
@Override
public void render(float delta) {
if (Gdx.input.justTouched()) {
Vector2 touchPoint = new Vector2();
FrozenNumbersGame.viewport.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY()));
//Clicking Close Button
if (closeBottom.getBoundingRectangle().contains(touchPoint.x, touchPoint.y) ||
closeTop.getBoundingRectangle().contains(touchPoint.x, touchPoint.y)) {
game.setScreen(m_Screens.get("MainMenu"));
}
}
// Drawing Stuff
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
Batch batch = FrozenNumbersGame.batch;
FrozenNumbersGame.viewport.apply(true);
batch.setProjectionMatrix(FrozenNumbersGame.viewport.getCamera().combined);
batch.begin();
bg.draw(batch);
closeBottom.draw(batch);
closeTop.draw(batch);
String p1String = new String();
String p2String = new String();
if (p1 > p2) {
p1String = "WIN";
p2String = "LOSE";
}
if (p2 > p1) {
p1String = "LOSE";
p2String = "WIN";
}
if (p2 == p1) {
p1String = "DRAW";
p2String = "DRAW";
}
// Draw Players Results
Table container = new Table();
Label winLoose = new Label(null, new Label.LabelStyle(FrozenNumbersGame.assets.get("size60.ttf", BitmapFont.class), Color.WHITE));
Label points = new Label(null, new Label.LabelStyle(FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class), Color.WHITE));
// Bottom Player
winLoose.setText(p1String);
container.add(winLoose);
container.setPosition((wWidth / 2), wHeight / 4 + 30);
container.draw(batch, 1);
points.setText(p1 + " Points");
container.clearChildren();
container.add(points);
container.setPosition((wWidth / 2), wHeight / 4 - 30);
container.draw(batch, 1);
// Top Player
container.setTransform(true);
container.setRotation(180);
winLoose.setText(p2String);
container.clearChildren();
container.add(winLoose);
container.setPosition((wWidth / 2), wHeight / 4 * 3 - 30);
container.draw(batch, 1);
points.setText(p2 + " Points");
container.clearChildren();
container.add(points);
container.setPosition((wWidth / 2), wHeight / 4 * 3 + 30);
container.draw(batch, 1);
batch.end();
}
@Override
public void resize(int width, int height) {
wWidth = FrozenNumbersGame.viewport.getWorldWidth();
wHeight = FrozenNumbersGame.viewport.getWorldHeight();
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
@Override
public void hide() {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
}
......@@ -128,6 +128,10 @@ public class GameScreen implements Screen {
p1.timer = timerDefault;
p2.timer = timerDefault;
FrozenNumbersGame.assets.get("snd/theme.ogg", Sound.class).play();
}
@Override
......@@ -184,7 +188,7 @@ public class GameScreen implements Screen {
{
//(float) (wWidth/2.0),(float) (wHeight/2.0)
// Random rand = new Random();
float randomX = -2*wWidth + (new Random().nextFloat()*4*wWidth);
float randomX = -0.2f*wWidth + (new Random().nextFloat()*1.4f*wWidth);
Vector2 touchPoint = new Vector2(randomX,(float) (wHeight/2.0));
if (p.active != null) {
if (!p.active.isFlying && lower && touchPoint.y <= bound) {
......@@ -445,7 +449,7 @@ public class GameScreen implements Screen {
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);
Rectangle MiddleRectangle = new Rectangle(0,(float) (wHeight/2.0 - bubblradius),wWidth,2*bubblradius);
// Getting hexagons with bubbles connected to the middle
for (Hexagon h : nachbarn.keySet()) {
......
......@@ -13,7 +13,6 @@ import com.badlogic.gdx.graphics.g2d.Sprite;
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 java.util.Map;
......@@ -137,13 +136,15 @@ public class MainMenuScreen implements Screen {
//Starting game if ready
if (p1_isready && p2_isready) {
m_Screens.put("Game", new GameScreen());
game.setScreen(m_Screens.get("Game"));
//reset for new Game
p1_isready = false;
p2_isready = false;
m_Screens.put("Game", new GameScreen());
p1_ready.setTexture(FrozenNumbersGame.assets.get("sprites/btn_ready_inactive.png", Texture.class));
p2_ready.setTexture(FrozenNumbersGame.assets.get("sprites/btn_ready_inactive.png", Texture.class));
p2_ready.setColor(1, 1, 1, 1);
p1_ready.setColor(1, 1, 1, 1);
p1_isready = false;
p2_isready = false;
game.setScreen(m_Screens.get("Game"));
}
}
......
......@@ -8,7 +8,6 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Vector2;
import org.milderjoghurt.frozennumbers.FrozenNumbersGame;
import java.util.Map;
......
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