Commit 3a80b83f authored by Bastian's avatar Bastian
Browse files

Added AutoShoot

parent ba926490
......@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import biz.pavonis.hexameter.api.Hexagon;
import biz.pavonis.hexameter.api.HexagonOrientation;
......@@ -37,6 +38,7 @@ public class GameScreen implements Screen {
public Vector2 sPos;
public int score = 0;
public boolean placedBubbleThisRound = false;
float timer = 0;
}
Player p1 = new Player();
......@@ -53,6 +55,7 @@ public class GameScreen implements Screen {
Vector2 mapoffset;
private Rectangle m_Bounds;
float wWidth, wHeight;
float timerDefault = 5;
private Hexagon getCurrentHex(Bubble b) {
Vector2 p = b.getPos();
......@@ -91,6 +94,9 @@ 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;
}
@Override
......@@ -113,7 +119,6 @@ public class GameScreen implements Screen {
p.active.setSize(bubblradius * 2, bubblradius * 2);
p.active.setCenter(p.sPos.x, p.sPos.y);
System.out.println(p.active.getPos());
}
if (Gdx.input.justTouched()) {
......@@ -129,6 +134,7 @@ public class GameScreen implements Screen {
p.active.setForce(speed.scl(100));
p.active.isFlying = true;
FrozenNumbersGame.assets.get("snd/shot.mp3", Sound.class).play();
p.timer = timerDefault;
}
if (!p.active.isFlying && !lower && touchPoint.y > bound) {
Vector2 star = new Vector2(touchPoint.x, touchPoint.y);
......@@ -139,9 +145,40 @@ public class GameScreen implements Screen {
p.active.setForce(speed.scl(100));
p.active.isFlying = true;
FrozenNumbersGame.assets.get("snd/shot.mp3", Sound.class).play();
p.timer = timerDefault;
}
}
}
if(p.timer <= 0)
{
//(float) (wWidth/2.0),(float) (wHeight/2.0)
// Random rand = new Random();
float randomX = -2*wWidth + (new Random().nextFloat()*4*wWidth);
Vector2 touchPoint = new Vector2(randomX,(float) (wHeight/2.0));
if (p.active != null) {
if (!p.active.isFlying && lower && touchPoint.y <= bound) {
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));
p.active.setVel(speed.cpy().scl(100.0f));
p.active.setForce(speed.scl(100));
p.active.isFlying = true;
FrozenNumbersGame.assets.get("snd/shot.mp3", Sound.class).play();
}
if (!p.active.isFlying && !lower && touchPoint.y >= bound) {
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));
p.active.setVel(speed.cpy().scl(100.0f));
p.active.setForce(speed.scl(100));
p.active.isFlying = true;
FrozenNumbersGame.assets.get("snd/shot.mp3", Sound.class).play();
}
p.timer = timerDefault;
}
}
if (p.active != null) {
if (p.active.isFlying) {
......@@ -189,11 +226,13 @@ public class GameScreen implements Screen {
public void render(float delta) {
removes.clear();
p1.timer -= delta;
p2.timer -= delta;
playerlogic(p1, true);
playerlogic(p2, false);
//System.out.println(nachbarn.values().size());//nachbarn.keySet().size());
for (Hexagon h : nachbarn.keySet()) {
Bubble bu = nachbarn.get(h);
......@@ -251,7 +290,6 @@ public class GameScreen implements Screen {
iterator.remove();
}
}
System.out.println(frozenHexagons.size());
for(Hexagon h : nachbarn.keySet())
{
......
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