Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PlatVenture
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JACQUIER Timeo
PlatVenture
Commits
c65b006d
Commit
c65b006d
authored
3 years ago
by
timeo
Browse files
Options
Downloads
Patches
Plain Diff
play connait le score actuel
parent
297e989f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/src/body/Joyau.java
+14
-2
14 additions, 2 deletions
core/src/body/Joyau.java
core/src/etat/Play.java
+14
-4
14 additions, 4 deletions
core/src/etat/Play.java
core/src/handlers/ContactListenerPerso.java
+14
-2
14 additions, 2 deletions
core/src/handlers/ContactListenerPerso.java
with
42 additions
and
8 deletions
core/src/body/Joyau.java
+
14
−
2
View file @
c65b006d
...
...
@@ -12,8 +12,9 @@ import com.badlogic.gdx.physics.box2d.World;
public
class
Joyau
{
CircleShape
shapeStruct
;
private
int
value
;
public
Joyau
(
float
x
,
float
y
,
World
world
){
public
Joyau
(
float
x
,
float
y
,
World
world
,
char
value
){
BodyDef
bodyDef
=
new
BodyDef
();
bodyDef
.
type
=
BodyDef
.
BodyType
.
StaticBody
;
bodyDef
.
position
.
set
(
x
,
y
);
...
...
@@ -29,8 +30,19 @@ public class Joyau {
fixtureDefStruct
.
isSensor
=
true
;
//traversable
this
.
value
=
Character
.
getNumericValue
(
value
);
structBody
.
createFixture
(
fixtureDefStruct
).
setUserData
(
"joyau"
);
if
(
this
.
value
==
1
){
structBody
.
createFixture
(
fixtureDefStruct
).
setUserData
(
"joyau1"
);
}
if
(
this
.
value
==
2
){
structBody
.
createFixture
(
fixtureDefStruct
).
setUserData
(
"joyau2"
);
}
shapeStruct
.
dispose
();
}
public
int
getValue
()
{
return
value
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
core/src/etat/Play.java
+
14
−
4
View file @
c65b006d
...
...
@@ -34,6 +34,7 @@ public class Play extends GameState {
private
int
hauteur
;
private
int
temps
;
private
ContactListenerPerso
cl
;
private
int
score
=
0
;
private
Body
player
;
...
...
@@ -81,16 +82,18 @@ public class Play extends GameState {
//dt => delta time
handleInput
();
/*TODO remettre à 1 quand j'aurai bien compris, on a pas besoin d'autant de précisions
*/
Array
<
Body
>
joyauToRemove
=
cl
.
getBodyToRemove
();
for
(
Body
b
:
joyauToRemove
){
world
.
destroyBody
(
b
);
score
=
cl
.
getScore
();
System
.
out
.
println
(
"score = "
+
score
);
}
joyauToRemove
.
clear
();
b2dCam
.
position
.
set
(
player
.
getPosition
(),
0
);
//
b2dCam.position.set(player.getPosition(), 0);
b2dCam
.
update
();
/*TODO remettre à 1 quand j'aurai bien compris, on a pas besoin d'autant de précisions
*/
world
.
step
(
dt
,
6
,
2
);
}
...
...
@@ -144,7 +147,7 @@ public class Play extends GameState {
break
;
case
'1'
:
case
'2'
:
new
Joyau
((
j
*
10
)/
PPM
,
((
hauteur
-
i
)
*
10
)/
PPM
,
world
);
new
Joyau
((
j
*
10
)/
PPM
,
((
hauteur
-
i
)
*
10
)/
PPM
,
world
,
current
);
break
;
case
'Z'
:
new
Panneau
((
j
*
10
)/
PPM
,
((
hauteur
-
i
)
*
10
)/
PPM
,
world
);
...
...
@@ -178,6 +181,13 @@ public class Play extends GameState {
foot
.
density
=
0.5f
;
foot
.
restitution
=
0.1f
;
foot
.
friction
=
0.25f
;
body
.
restitution
=
0.1f
;
body
.
density
=
0.5f
;
body
.
friction
=
0.25f
;
player
.
createFixture
(
foot
).
setUserData
(
"foot"
);
}
...
...
This diff is collapsed.
Click to expand it.
core/src/handlers/ContactListenerPerso.java
+
14
−
2
View file @
c65b006d
...
...
@@ -12,6 +12,7 @@ public class ContactListenerPerso implements ContactListener {
private
int
numPlayerOnGround
=
0
;
Array
<
Body
>
bodyToRemove
=
new
Array
<
Body
>();
private
int
score
=
0
;
/**
* Appeler quand 2 fixtures rentre en collision
...
...
@@ -26,10 +27,17 @@ public class ContactListenerPerso implements ContactListener {
numPlayerOnGround
++;
}
if
(
fb
.
getUserData
()
!=
null
&&
fb
.
getUserData
().
equals
(
"joyau"
)
&&
fa
.
getUserData
()
!=
null
&&
fa
.
getBody
().
getUserData
().
equals
(
"player"
)){
if
(
fb
.
getUserData
()
!=
null
&&
fb
.
getUserData
().
equals
(
"joyau
1
"
)
&&
fa
.
getUserData
()
!=
null
&&
fa
.
getBody
().
getUserData
().
equals
(
"player"
)){
if
(!
bodyToRemove
.
contains
(
fb
.
getBody
(),
false
)){
score
++;
bodyToRemove
.
add
(
fb
.
getBody
());
}
}
if
(
fb
.
getUserData
()
!=
null
&&
fb
.
getUserData
().
equals
(
"joyau2"
)
&&
fa
.
getUserData
()
!=
null
&&
fa
.
getBody
().
getUserData
().
equals
(
"player"
)){
if
(!
bodyToRemove
.
contains
(
fb
.
getBody
(),
false
)){
score
+=
2
;
bodyToRemove
.
add
(
fb
.
getBody
());
System
.
out
.
println
(
"à enlever"
);
}
}
...
...
@@ -76,4 +84,8 @@ public class ContactListenerPerso implements ContactListener {
public
Array
<
Body
>
getBodyToRemove
()
{
return
bodyToRemove
;
}
public
int
getScore
()
{
return
score
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment