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
97fad971
Commit
97fad971
authored
Jan 20, 2016
by
Nils Hein
Browse files
Fixed scoring system
parent
e70adb99
Changes
1
Hide whitespace changes
Inline
Side-by-side
core/src/org/milderjoghurt/frozennumbers/screens/GameScreen.java
View file @
97fad971
...
...
@@ -216,42 +216,44 @@ public class GameScreen implements Screen {
if
(
p
.
active
!=
null
)
{
if
(
p
.
active
.
isFlying
)
{
Hexagon
point
=
getCurrentHex
(
p
.
active
);
boolean
hit
=
false
;
for
(
Hexagon
h
:
map
.
getNeighborsOf
(
point
))
{
if
(
nachbarn
.
containsKey
(
h
))
{
if
(
p
.
active
.
getPos
().
dst
(
getHexCenter
(
h
))
<
2
*
(
bubblradius
*
0.9
))
{
p
.
active
.
isFlying
=
false
;
if
(!
nachbarn
.
containsKey
(
point
))
{
nachbarn
.
put
(
point
,
new
Bubble
(
p
.
active
));
}
p
.
active
=
null
;
hit
=
true
;
FrozenNumbersGame
.
assets
.
get
(
"snd/hit.mp3"
,
Sound
.
class
).
play
();
p
.
placedBubbleThisRound
=
true
;
break
;
}
}
}
if
(
p
.
active
!=
null
)
if
((
p
.
active
.
getPos
().
y
>
bound
-
bubblradius
/
2.0
&&
lower
)
||
(
p
.
active
.
getPos
().
y
<
bound
+
bubblradius
/
2.0
&&
!
lower
))
{
p
.
active
.
isFlying
=
false
;
p
.
active
.
setVel
(
new
Vector2
(
0
,
0
));
if
(!
nachbarn
.
containsKey
(
point
))
nachbarn
.
put
(
point
,
new
Bubble
(
p
.
active
));
p
.
active
=
null
;
FrozenNumbersGame
.
assets
.
get
(
"snd/hit.mp3"
,
Sound
.
class
).
play
();
p
.
placedBubbleThisRound
=
true
;
}
if
((
p
.
active
.
getPos
().
y
>
bound
-
bubblradius
/
2.0
&&
lower
)
||
(
p
.
active
.
getPos
().
y
<
bound
+
bubblradius
/
2.0
&&
!
lower
))
{
hit
=
true
;
FrozenNumbersGame
.
assets
.
get
(
"snd/hit.mp3"
,
Sound
.
class
).
play
();
}
}
if
(
p
.
active
!=
null
)
{
if
(
p
.
active
.
getPos
().
x
>
m_Bounds
.
getWidth
()
-
(
bubblradius
)
||
p
.
active
.
getPos
().
x
<
m_Bounds
.
getX
()
+
(
bubblradius
))
{
p
.
active
.
setVel
(
p
.
active
.
getVel
().
scl
(-
1
,
1
));
}
p
.
active
.
Update
(
0.1f
);
}
if
(
hit
)
{
p
.
active
.
isFlying
=
false
;
p
.
active
.
setVel
(
new
Vector2
(
0
,
0
));
if
(!
nachbarn
.
containsKey
(
point
))
nachbarn
.
put
(
point
,
new
Bubble
(
p
.
active
));
p
.
active
=
null
;
p
.
score
+=
checkScore
(
point
);
for
(
Hexagon
h
:
map
.
getNeighborsOf
(
point
))
{
if
(
nachbarn
.
containsKey
(
h
))
p
.
score
+=
checkScore
(
h
);
}
}
}
}
//Moving falling Bubbles
...
...
@@ -279,6 +281,27 @@ public class GameScreen implements Screen {
}
}
private
int
checkScore
(
Hexagon
h
)
{
int
sum
=
0
;
Bubble
active
=
nachbarn
.
get
(
h
);
List
<
Bubble
>
nei
=
new
ArrayList
<
Bubble
>();
for
(
Hexagon
n
:
map
.
getNeighborsOf
(
h
))
{
if
(
nachbarn
.
containsKey
(
n
))
{
sum
+=
1
;
nei
.
add
(
nachbarn
.
get
(
n
));
}
}
if
(
sum
%
10
==
active
.
getValue
()
&&
nei
.
size
()
>
1
)
{
if
(!
nachbarn
.
get
(
h
).
isFrozen
())
{
removes
.
add
(
h
);
removes
.
addAll
(
map
.
getNeighborsOf
(
h
));
}
return
sum
;
}
return
0
;
}
@Override
public
void
render
(
float
delta
)
{
removes
.
clear
();
...
...
@@ -299,28 +322,6 @@ public class GameScreen implements Screen {
bu
.
setForce
(
f
);
bu
.
isDamped
=
true
;
bu
.
Update
(
0.1f
);
float
sum
=
0
;
List
<
Bubble
>
nei
=
new
ArrayList
<
Bubble
>();
for
(
Hexagon
n
:
map
.
getNeighborsOf
(
h
))
{
if
(
nachbarn
.
containsKey
(
n
))
{
sum
+=
nachbarn
.
get
(
n
).
getValue
();
nei
.
add
(
nachbarn
.
get
(
n
));
}
}
if
(
sum
%
10
==
bu
.
getValue
()
&&
nei
.
size
()
>
1
)
{
if
(!
nachbarn
.
get
(
h
).
isFrozen
())
{
removes
.
add
(
h
);
removes
.
addAll
(
map
.
getNeighborsOf
(
h
));
if
(
p1
.
placedBubbleThisRound
)
{
p1
.
score
+=
sum
;
p1
.
placedBubbleThisRound
=
false
;
}
if
(
p2
.
placedBubbleThisRound
)
{
p2
.
score
+=
sum
;
p2
.
placedBubbleThisRound
=
false
;
}
}
}
}
//Freezing bubbles
...
...
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