Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MilderJoghurt
FrozenNumbers
Commits
a2067556
Commit
a2067556
authored
Jan 21, 2016
by
Nils Hein
Browse files
Scoring fixed, Music in all Screens
parent
97fad971
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/src/org/milderjoghurt/frozennumbers/screens/GameOverScreen.java
View file @
a2067556
...
...
@@ -56,15 +56,12 @@ public class GameOverScreen implements Screen {
closeTop
.
rotate
(
180
);
closeTop
.
setCenter
(
wWidth
/
4.0f
*
3.0f
,
wHeight
/
2.0f
);
Music
m
=
FrozenNumbersGame
.
assets
.
get
(
"snd/theme.ogg"
,
Music
.
class
);
m
.
setLooping
(
true
);
m
.
play
();
}
@Override
public
void
show
()
{
// TODO Auto-generated method stub
FrozenNumbersGame
.
assets
.
get
(
"snd/theme.ogg"
,
Music
.
class
).
setVolume
(
1
f
);
}
@Override
...
...
core/src/org/milderjoghurt/frozennumbers/screens/GameScreen.java
View file @
a2067556
...
...
@@ -2,6 +2,7 @@ package org.milderjoghurt.frozennumbers.screens;
import
com.badlogic.gdx.Gdx
;
import
com.badlogic.gdx.Screen
;
import
com.badlogic.gdx.audio.Music
;
import
com.badlogic.gdx.audio.Sound
;
import
com.badlogic.gdx.graphics.Color
;
import
com.badlogic.gdx.graphics.GL20
;
...
...
@@ -9,7 +10,6 @@ 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.Sprite
;
import
com.badlogic.gdx.graphics.g2d.TextureRegion
;
import
com.badlogic.gdx.graphics.glutils.ShapeRenderer
;
import
com.badlogic.gdx.math.Rectangle
;
import
com.badlogic.gdx.math.Vector2
;
...
...
@@ -39,7 +39,6 @@ public class GameScreen implements Screen {
public
Bubble
active
;
public
Vector2
sPos
;
public
int
score
=
0
;
public
boolean
placedBubbleThisRound
=
false
;
float
timer
=
0
;
}
...
...
@@ -48,8 +47,7 @@ public class GameScreen implements Screen {
List
<
Hexagon
>
removes
;
List
<
Hexagon
>
frozenHexagons
;
List
<
Bubble
>
fallingBubbles
;
float
bubblradius
=
32
;
String
lastpoint
=
""
;
float
bubbleradius
=
32
;
HexagonalGrid
map
;
Map
<
Hexagon
,
Bubble
>
nachbarn
;
ShapeRenderer
renderer
=
new
ShapeRenderer
();
...
...
@@ -76,9 +74,9 @@ public class GameScreen implements Screen {
fallingBubbles
=
new
ArrayList
<
Bubble
>();
HexagonalGridBuilder
hexbulder
=
new
HexagonalGridBuilder
();
bubblradius
=
wWidth
/
14
;
bubbl
e
radius
=
wWidth
/
14
;
m_Bounds
=
new
Rectangle
(
0
,
bubblradius
,
wWidth
,
wHeight
-
bubblradius
);
m_Bounds
=
new
Rectangle
(
0
,
bubbl
e
radius
,
wWidth
,
wHeight
-
bubbl
e
radius
);
bg
=
new
Sprite
(
FrozenNumbersGame
.
assets
.
get
(
"backgrounds/background.jpg"
,
Texture
.
class
));
float
scaleX
=
wWidth
/
bg
.
getWidth
();
...
...
@@ -115,7 +113,7 @@ public class GameScreen implements Screen {
hexbulder
.
setGridHeight
(
15
);
hexbulder
.
setGridWidth
(
11
);
hexbulder
.
setRadius
(
bubblradius
);
hexbulder
.
setRadius
(
bubbl
e
radius
);
hexbulder
.
setOrientation
(
HexagonOrientation
.
FLAT_TOP
);
map
=
hexbulder
.
build
();
...
...
@@ -129,13 +127,15 @@ public class GameScreen implements Screen {
p1
.
timer
=
timerDefault
;
p2
.
timer
=
timerDefault
;
//TODO: Main Game Sound
}
@Override
public
void
show
()
{
// TODO Auto-generated method stub
FrozenNumbersGame
.
assets
.
get
(
"snd/theme.ogg"
,
Music
.
class
).
setVolume
(
0.1f
);
}
private
Hexagon
getHexfromPixel
(
float
x
,
float
y
)
{
...
...
@@ -149,7 +149,7 @@ public class GameScreen implements Screen {
private
void
playerlogic
(
Player
p
,
boolean
lower
)
{
if
(
p
.
active
==
null
)
{
p
.
active
=
new
Bubble
(
p
.
sPos
.
cpy
());
p
.
active
.
setSize
(
bubblradius
*
2
,
bubblradius
*
2
);
p
.
active
.
setSize
(
bubbl
e
radius
*
2
,
bubbl
e
radius
*
2
);
p
.
active
.
setCenter
(
p
.
sPos
.
x
,
p
.
sPos
.
y
);
}
...
...
@@ -160,7 +160,7 @@ public class GameScreen implements Screen {
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
ssrc
=
new
Vector2
(
wWidth
/
2
,
bubbl
e
radius
*
2
);
Vector2
speed
=
star
.
cpy
().
sub
(
ssrc
).
nor
();
speed
.
set
(
speed
.
x
,
Math
.
abs
(
speed
.
y
));
p
.
active
.
setVel
(
speed
.
cpy
().
scl
(
100.0f
));
...
...
@@ -171,7 +171,7 @@ public class GameScreen implements Screen {
}
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
ssrc
=
new
Vector2
(
wWidth
/
2
,
wHeight
-
bubbl
e
radius
*
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
));
...
...
@@ -184,14 +184,12 @@ public class GameScreen implements Screen {
}
if
(
p
.
timer
<=
0
)
{
//(float) (wWidth/2.0),(float) (wHeight/2.0)
// Random rand = new Random();
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
)
{
Vector2
star
=
new
Vector2
(
touchPoint
.
x
,
touchPoint
.
y
);
Vector2
ssrc
=
new
Vector2
(
wWidth
/
2
,
bubblradius
*
2
);
Vector2
ssrc
=
new
Vector2
(
wWidth
/
2
,
bubbl
e
radius
*
2
);
Vector2
speed
=
star
.
cpy
().
sub
(
ssrc
).
nor
();
speed
.
set
(
speed
.
x
,
Math
.
abs
(
speed
.
y
));
p
.
active
.
setVel
(
speed
.
cpy
().
scl
(
100.0f
));
...
...
@@ -201,7 +199,7 @@ public class GameScreen implements Screen {
}
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
ssrc
=
new
Vector2
(
wWidth
/
2
,
wHeight
-
bubbl
e
radius
*
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
));
...
...
@@ -219,7 +217,7 @@ public class GameScreen implements Screen {
boolean
hit
=
false
;
for
(
Hexagon
h
:
map
.
getNeighborsOf
(
point
))
{
if
(
nachbarn
.
containsKey
(
h
))
{
if
(
p
.
active
.
getPos
().
dst
(
getHexCenter
(
h
))
<
2
*
(
bubblradius
*
0.
9
))
{
if
(
p
.
active
.
getPos
().
dst
(
getHexCenter
(
h
))
<
2
*
(
bubbl
e
radius
*
0.
85
))
{
hit
=
true
;
FrozenNumbersGame
.
assets
.
get
(
"snd/hit.mp3"
,
Sound
.
class
).
play
();
...
...
@@ -228,14 +226,14 @@ public class GameScreen implements Screen {
}
}
if
((
p
.
active
.
getPos
().
y
>
bound
-
bubblradius
/
2.0
&&
lower
)
||
(
p
.
active
.
getPos
().
y
<
bound
+
bubblradius
/
2.0
&&
!
lower
))
{
if
((
p
.
active
.
getPos
().
y
>
bound
-
bubbl
e
radius
/
2.0
&&
lower
)
||
(
p
.
active
.
getPos
().
y
<
bound
+
bubbl
e
radius
/
2.0
&&
!
lower
))
{
hit
=
true
;
FrozenNumbersGame
.
assets
.
get
(
"snd/hit.mp3"
,
Sound
.
class
).
play
();
}
if
(
p
.
active
.
getPos
().
x
>
m_Bounds
.
getWidth
()
-
(
bubblradius
)
||
p
.
active
.
getPos
().
x
<
m_Bounds
.
getX
()
+
(
bubblradius
))
{
if
(
p
.
active
.
getPos
().
x
>
m_Bounds
.
getWidth
()
-
(
bubbl
e
radius
)
||
p
.
active
.
getPos
().
x
<
m_Bounds
.
getX
()
+
(
bubbl
e
radius
))
{
p
.
active
.
setVel
(
p
.
active
.
getVel
().
scl
(-
1
,
1
));
}
p
.
active
.
Update
(
0.1f
);
...
...
@@ -266,14 +264,14 @@ public class GameScreen implements Screen {
b
.
Update
(
0.1f
);
//Scoring and deleting Bubble
int
points
=
2
5
;
int
points
=
5
;
float
y
=
b
.
getPos
().
y
;
if
(
y
<
3
*
bubblradius
&&
lower
)
if
(
y
<
3
*
bubbl
e
radius
&&
lower
)
{
p
.
score
+=
points
;
iterator
.
remove
();
}
if
(
y
>
wHeight
-
3
*
bubblradius
&&
!
lower
)
if
(
y
>
wHeight
-
3
*
bubbl
e
radius
&&
!
lower
)
{
p
.
score
+=
points
;
iterator
.
remove
();
...
...
@@ -287,7 +285,7 @@ public class GameScreen implements Screen {
List
<
Bubble
>
nei
=
new
ArrayList
<
Bubble
>();
for
(
Hexagon
n
:
map
.
getNeighborsOf
(
h
))
{
if
(
nachbarn
.
containsKey
(
n
))
{
sum
+=
1
;
sum
+=
nachbarn
.
get
(
n
).
getValue
()
;
nei
.
add
(
nachbarn
.
get
(
n
));
}
}
...
...
@@ -296,7 +294,7 @@ public class GameScreen implements Screen {
removes
.
add
(
h
);
removes
.
addAll
(
map
.
getNeighborsOf
(
h
));
}
return
sum
;
return
(
nei
.
size
()+
1
)*
10
;
}
return
0
;
}
...
...
@@ -356,11 +354,14 @@ public class GameScreen implements Screen {
if
(
nachbarn
.
get
(
h
)!=
null
)
{
double
y
=
h
.
getCenterY
();
if
(
y
>
wHeight
-
3
*
bubblradius
||
y
<
4
*
bubblradius
)
if
(
y
>
wHeight
-
3
*
bubbl
e
radius
)
{
FrozenNumbersGame
.
m_Screens
.
put
(
"GameOverScreen"
,
new
GameOverScreen
(
p1
.
score
,
p2
.
score
));
FrozenNumbersGame
.
m_Screens
.
put
(
"GameOverScreen"
,
new
GameOverScreen
(
p1
.
score
,
p2
.
score
/
2
));
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
));
FrozenNumbersGame
.
game
.
setScreen
(
FrozenNumbersGame
.
m_Screens
.
get
(
"GameOverScreen"
));
}
}
}
...
...
@@ -448,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
-
bubblradius
),
wWidth
,
2
*
bubblradius
);
Rectangle
MiddleRectangle
=
new
Rectangle
(
0
,(
float
)
(
wHeight
/
2.0
-
bubbl
e
radius
),
wWidth
,
2
*
bubbl
e
radius
);
// Getting hexagons with bubbles connected to the middle
for
(
Hexagon
h
:
nachbarn
.
keySet
())
{
...
...
@@ -492,8 +493,8 @@ public class GameScreen implements Screen {
Label
myLabel
=
new
Label
(
text
,
new
Label
.
LabelStyle
(
FrozenNumbersGame
.
assets
.
get
(
"size40.ttf"
,
BitmapFont
.
class
),
c
));
Label
myLabel2
=
new
Label
(
text
,
new
Label
.
LabelStyle
(
FrozenNumbersGame
.
assets
.
get
(
"size40.ttf"
,
BitmapFont
.
class
),
c
));
myLabel
.
setSize
(
bubblradius
/
2
,
bubblradius
/
4
);
myLabel2
.
setSize
(
bubblradius
/
2
,
bubblradius
/
4
);
myLabel
.
setSize
(
bubbl
e
radius
/
2
,
bubbl
e
radius
/
4
);
myLabel2
.
setSize
(
bubbl
e
radius
/
2
,
bubbl
e
radius
/
4
);
myLabel
.
setScale
(
0.5f
);
myLabel2
.
setScale
(
0.5f
);
...
...
@@ -502,7 +503,7 @@ public class GameScreen implements Screen {
Group
g
=
new
Group
();
rotaater
=
g
;
g
.
addActor
(
myLabel
);
g
.
setSize
(
bubblradius
,
bubblradius
);
g
.
setSize
(
bubbl
e
radius
,
bubbl
e
radius
);
g
.
setPosition
(
x
+
myLabel
.
getWidth
()
*
0.5f
,
y
+
myLabel
.
getWidth
());
rotaater
.
setRotation
(
180
);
...
...
core/src/org/milderjoghurt/frozennumbers/screens/MainMenuScreen.java
View file @
a2067556
...
...
@@ -144,7 +144,6 @@ public class MainMenuScreen implements Screen {
if
(
p1_isready
&&
p2_isready
)
{
//reset for new Game
m_Screens
.
put
(
"Game"
,
new
GameScreen
());
FrozenNumbersGame
.
assets
.
get
(
"snd/theme.ogg"
,
Music
.
class
).
stop
();
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
);
...
...
Fjen Undso
@fjen
mentioned in issue
#18 (closed)
·
Jan 21, 2016
mentioned in issue
#18 (closed)
mentioned in issue #18
Toggle commit list
Fjen Undso
@fjen
mentioned in issue
#4 (closed)
·
Jan 21, 2016
mentioned in issue
#4 (closed)
mentioned in issue #4
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment