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
cb7e789d
Commit
cb7e789d
authored
3 years ago
by
timeo
Browse files
Options
Downloads
Patches
Plain Diff
au passage du panneau, 2s timer et destruction de tout les body
parent
f34f13b0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/src/etat/Play.java
+39
-13
39 additions, 13 deletions
core/src/etat/Play.java
with
39 additions
and
13 deletions
core/src/etat/Play.java
+
39
−
13
View file @
cb7e789d
...
...
@@ -32,8 +32,9 @@ public class Play extends GameState {
private
int
temps
;
private
ContactListenerPerso
cl
;
private
int
score
=
0
;
private
boolean
dead
=
false
;
private
float
totalTimeSinceDeath
=
0
;
private
float
totalTimeSinceAction
=
0
;
private
int
level
=
1
;
private
boolean
isChangingLevel
=
false
;
private
Body
player
;
...
...
@@ -46,8 +47,7 @@ public class Play extends GameState {
world
.
setContactListener
(
cl
);
b2dr
=
new
Box2DDebugRenderer
();
createWorld
(
"assets/level_001.txt"
);
loadLevel
(
level
);
createPlayer
();
//Init b2dCam
...
...
@@ -88,7 +88,19 @@ public class Play extends GameState {
}
joyauToRemove
.
clear
();
death
(
dt
);
// death(dt);
if
(!
isInside
()){
if
(
cl
.
isTriggerEndLevel
()){
isChangingLevel
=
true
;
}
else
{
death
(
dt
);
}
}
if
(
isChangingLevel
){
changeLevel
(
dt
);
}
// Bouger la caméra en x
if
(
player
.
getPosition
().
x
*
PPM
>
(
float
)
(
PlatVenture
.
largeur
/
2
)
&&
player
.
getPosition
().
y
*
PPM
<=
(
float
)
(
PlatVenture
.
hauteur
/
2
)
&&
largeur
>
16
)
{
...
...
@@ -219,18 +231,32 @@ public class Play extends GameState {
}
private
void
death
(
float
dt
){
if
(!
isInside
()
&&
!
cl
.
isTriggerEndLevel
()){
dead
=
true
;
}
if
(
dead
){
if
(
totalTimeSinceDeath
>
2
){
if
(
totalTimeSinceAction
>
2
){
player
.
setLinearVelocity
(
0
,
0
);
player
.
setTransform
(
15
/
PPM
,
20
/
PPM
,
0
);
dead
=
false
;
totalTimeSinceDeath
=
0
;
totalTimeSinceAction
=
0
;
}
else
{
totalTimeSince
Death
+=
dt
;
totalTimeSince
Action
+=
dt
;
}
}
private
void
loadLevel
(
int
current
){
String
path
=
"assets/level_00"
+
current
+
".txt"
;
createWorld
(
path
);
}
private
void
changeLevel
(
float
dt
){
if
(
totalTimeSinceAction
>
2
)
{
Array
<
Body
>
bodies
=
new
Array
<>();
world
.
getBodies
(
bodies
);
for
(
int
i
=
0
;
i
<
bodies
.
size
;
i
++)
{
if
(!
world
.
isLocked
())
world
.
destroyBody
(
bodies
.
get
(
i
));
}
isChangingLevel
=
false
;
}
else
{
totalTimeSinceAction
+=
dt
;
}
}
}
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