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
f34f13b0
Commit
f34f13b0
authored
3 years ago
by
timeo
Browse files
Options
Downloads
Patches
Plain Diff
mort si on sort du monde en x sans passer par un panneau
parent
242f2f1f
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/Panneau.java
+1
-1
1 addition, 1 deletion
core/src/body/Panneau.java
core/src/etat/Play.java
+29
-4
29 additions, 4 deletions
core/src/etat/Play.java
core/src/handlers/ContactListenerPerso.java
+12
-0
12 additions, 0 deletions
core/src/handlers/ContactListenerPerso.java
with
42 additions
and
5 deletions
core/src/body/Panneau.java
+
1
−
1
View file @
f34f13b0
...
...
@@ -33,7 +33,7 @@ public class Panneau {
fixtureDefStruct
.
isSensor
=
true
;
structBody
.
createFixture
(
fixtureDefStruct
);
structBody
.
createFixture
(
fixtureDefStruct
)
.
setUserData
(
"panneau"
)
;
shapeStruct
.
dispose
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
core/src/etat/Play.java
+
29
−
4
View file @
f34f13b0
...
...
@@ -5,9 +5,7 @@ import com.badlogic.gdx.Gdx;
import
com.badlogic.gdx.files.FileHandle
;
import
com.badlogic.gdx.graphics.GL20
;
import
com.badlogic.gdx.graphics.OrthographicCamera
;
import
com.badlogic.gdx.graphics.g2d.BitmapFont
;
import
com.badlogic.gdx.math.Vector2
;
import
com.badlogic.gdx.math.Vector3
;
import
com.badlogic.gdx.physics.box2d.Body
;
import
com.badlogic.gdx.physics.box2d.BodyDef
;
import
com.badlogic.gdx.physics.box2d.Box2DDebugRenderer
;
...
...
@@ -21,7 +19,6 @@ import com.mygdx.game.PlatVenture;
import
body.Joyau
;
import
body.Panneau
;
import
body.Platform
;
import
body.Water
;
import
handlers.ContactListenerPerso
;
import
handlers.GameStateManager
;
import
handlers.InputPerso
;
...
...
@@ -35,6 +32,8 @@ public class Play extends GameState {
private
int
temps
;
private
ContactListenerPerso
cl
;
private
int
score
=
0
;
private
boolean
dead
=
false
;
private
float
totalTimeSinceDeath
=
0
;
private
Body
player
;
...
...
@@ -48,7 +47,7 @@ public class Play extends GameState {
b2dr
=
new
Box2DDebugRenderer
();
createWorld
(
"assets/level_00
2
.txt"
);
createWorld
(
"assets/level_00
1
.txt"
);
createPlayer
();
//Init b2dCam
...
...
@@ -89,6 +88,7 @@ public class Play extends GameState {
}
joyauToRemove
.
clear
();
death
(
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
)
{
...
...
@@ -208,4 +208,29 @@ public class Play extends GameState {
player
.
createFixture
(
foot
).
setUserData
(
"foot"
);
}
private
boolean
isInside
(){
boolean
isinside
=
true
;
if
(
player
.
getPosition
().
x
<
-
5
/
PPM
){
// Si la totalité du corps du joueur sort
isinside
=
false
;
}
return
isinside
;
}
private
void
death
(
float
dt
){
if
(!
isInside
()
&&
!
cl
.
isTriggerEndLevel
()){
dead
=
true
;
}
if
(
dead
){
if
(
totalTimeSinceDeath
>
2
){
player
.
setLinearVelocity
(
0
,
0
);
player
.
setTransform
(
15
/
PPM
,
20
/
PPM
,
0
);
dead
=
false
;
totalTimeSinceDeath
=
0
;
}
else
{
totalTimeSinceDeath
+=
dt
;
}
}
}
}
This diff is collapsed.
Click to expand it.
core/src/handlers/ContactListenerPerso.java
+
12
−
0
View file @
f34f13b0
...
...
@@ -13,6 +13,7 @@ public class ContactListenerPerso implements ContactListener {
private
int
numPlayerOnGround
=
0
;
Array
<
Body
>
bodyToRemove
=
new
Array
<
Body
>();
private
int
score
=
0
;
private
boolean
triggerEndLevel
=
false
;
/**
* Appeler quand 2 fixtures rentre en collision
...
...
@@ -55,6 +56,13 @@ public class ContactListenerPerso implements ContactListener {
if
(
fb
.
getUserData
()
!=
null
&&
fb
.
getUserData
().
equals
(
"foot"
)
&&
fa
.
getUserData
()
!=
null
&&
fa
.
getUserData
().
equals
(
"platform"
)){
numPlayerOnGround
--;
}
if
(
fa
.
getUserData
()
!=
null
&&
fa
.
getUserData
().
equals
(
"panneau"
)
&&
fb
.
getUserData
()
!=
null
&&
fb
.
getUserData
().
equals
(
"body"
)){
triggerEndLevel
=
true
;
}
else
{
triggerEndLevel
=
false
;
}
}
/**
...
...
@@ -88,4 +96,8 @@ public class ContactListenerPerso implements ContactListener {
public
int
getScore
()
{
return
score
;
}
public
boolean
isTriggerEndLevel
()
{
return
triggerEndLevel
;
}
}
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