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
82468033
Commit
82468033
authored
3 years ago
by
timeo
Browse files
Options
Downloads
Patches
Plain Diff
mort dans l'eau
parent
cb7e789d
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/Water.java
+6
-3
6 additions, 3 deletions
core/src/body/Water.java
core/src/etat/Play.java
+17
-0
17 additions, 0 deletions
core/src/etat/Play.java
core/src/handlers/ContactListenerPerso.java
+11
-0
11 additions, 0 deletions
core/src/handlers/ContactListenerPerso.java
with
34 additions
and
3 deletions
core/src/body/Water.java
+
6
−
3
View file @
82468033
package
body
;
package
body
;
import
static
handlers
.
B2DVars
.
PPM
;
import
com.badlogic.gdx.math.Vector2
;
import
com.badlogic.gdx.math.Vector2
;
import
com.badlogic.gdx.physics.box2d.Body
;
import
com.badlogic.gdx.physics.box2d.Body
;
import
com.badlogic.gdx.physics.box2d.BodyDef
;
import
com.badlogic.gdx.physics.box2d.BodyDef
;
...
@@ -12,7 +14,8 @@ public class Water {
...
@@ -12,7 +14,8 @@ public class Water {
PolygonShape
shapeStruct
;
PolygonShape
shapeStruct
;
Vector2
[]
ptsStruct
;
Vector2
[]
ptsStruct
;
public
Water
(
int
x
,
int
y
,
World
world
){
/*TODO Rajouter des box en dessous pour éviter au perso de se casser la gueule*/
public
Water
(
float
x
,
float
y
,
World
world
){
BodyDef
bodyDef
=
new
BodyDef
();
BodyDef
bodyDef
=
new
BodyDef
();
bodyDef
.
type
=
BodyDef
.
BodyType
.
StaticBody
;
bodyDef
.
type
=
BodyDef
.
BodyType
.
StaticBody
;
...
@@ -23,14 +26,14 @@ public class Water {
...
@@ -23,14 +26,14 @@ public class Water {
FixtureDef
fixtureDefStruct
=
new
FixtureDef
();
FixtureDef
fixtureDefStruct
=
new
FixtureDef
();
shapeStruct
=
new
PolygonShape
();
shapeStruct
=
new
PolygonShape
();
ptsStruct
=
new
Vector2
[]{};
ptsStruct
=
new
Vector2
[]{
new
Vector2
(
0
,
0
),
new
Vector2
(
10
/
PPM
,
0
),
new
Vector2
(
10
/
PPM
,
10
/
PPM
),
new
Vector2
(
0
,
10
/
PPM
)
};
shapeStruct
.
set
(
ptsStruct
);
shapeStruct
.
set
(
ptsStruct
);
fixtureDefStruct
.
shape
=
shapeStruct
;
fixtureDefStruct
.
shape
=
shapeStruct
;
fixtureDefStruct
.
isSensor
=
true
;
//traversable
fixtureDefStruct
.
isSensor
=
true
;
//traversable
structBody
.
createFixture
(
fixtureDefStruct
);
structBody
.
createFixture
(
fixtureDefStruct
)
.
setUserData
(
"eau"
)
;
shapeStruct
.
dispose
();
shapeStruct
.
dispose
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
core/src/etat/Play.java
+
17
−
0
View file @
82468033
...
@@ -19,6 +19,7 @@ import com.mygdx.game.PlatVenture;
...
@@ -19,6 +19,7 @@ import com.mygdx.game.PlatVenture;
import
body.Joyau
;
import
body.Joyau
;
import
body.Panneau
;
import
body.Panneau
;
import
body.Platform
;
import
body.Platform
;
import
body.Water
;
import
handlers.ContactListenerPerso
;
import
handlers.ContactListenerPerso
;
import
handlers.GameStateManager
;
import
handlers.GameStateManager
;
import
handlers.InputPerso
;
import
handlers.InputPerso
;
...
@@ -98,6 +99,10 @@ public class Play extends GameState {
...
@@ -98,6 +99,10 @@ public class Play extends GameState {
}
}
}
}
if
(
cl
.
isTouchWater
()){
death
(
dt
);
}
if
(
isChangingLevel
){
if
(
isChangingLevel
){
changeLevel
(
dt
);
changeLevel
(
dt
);
}
}
...
@@ -180,6 +185,8 @@ public class Play extends GameState {
...
@@ -180,6 +185,8 @@ public class Play extends GameState {
break
;
break
;
case
'Z'
:
case
'Z'
:
new
Panneau
((
j
*
10
)/
PPM
,
((
hauteur
-
i
)
*
10
)/
PPM
,
world
);
new
Panneau
((
j
*
10
)/
PPM
,
((
hauteur
-
i
)
*
10
)/
PPM
,
world
);
case
'W'
:
new
Water
((
j
*
10
)/
PPM
,
((
hauteur
-
i
)
*
10
)/
PPM
,
world
);
}
}
}
}
...
@@ -234,9 +241,11 @@ public class Play extends GameState {
...
@@ -234,9 +241,11 @@ public class Play extends GameState {
if
(
totalTimeSinceAction
>
2
){
if
(
totalTimeSinceAction
>
2
){
player
.
setLinearVelocity
(
0
,
0
);
player
.
setLinearVelocity
(
0
,
0
);
player
.
setTransform
(
15
/
PPM
,
20
/
PPM
,
0
);
player
.
setTransform
(
15
/
PPM
,
20
/
PPM
,
0
);
score
=
0
;
// reset du score
totalTimeSinceAction
=
0
;
totalTimeSinceAction
=
0
;
}
else
{
}
else
{
totalTimeSinceAction
+=
dt
;
totalTimeSinceAction
+=
dt
;
player
.
setLinearVelocity
(
0
,
0
);
}
}
}
}
...
@@ -247,13 +256,21 @@ public class Play extends GameState {
...
@@ -247,13 +256,21 @@ public class Play extends GameState {
private
void
changeLevel
(
float
dt
){
private
void
changeLevel
(
float
dt
){
if
(
totalTimeSinceAction
>
2
)
{
if
(
totalTimeSinceAction
>
2
)
{
// Destruction de tout les body
Array
<
Body
>
bodies
=
new
Array
<>();
Array
<
Body
>
bodies
=
new
Array
<>();
world
.
getBodies
(
bodies
);
world
.
getBodies
(
bodies
);
for
(
int
i
=
0
;
i
<
bodies
.
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
bodies
.
size
;
i
++)
{
if
(!
world
.
isLocked
())
if
(!
world
.
isLocked
())
world
.
destroyBody
(
bodies
.
get
(
i
));
world
.
destroyBody
(
bodies
.
get
(
i
));
}
}
level
++;
// Incrémente le level
loadLevel
(
level
);
createPlayer
();
player
.
setLinearVelocity
(
0
,
0
);
// annule la vitesse linéaire du personnage
System
.
out
.
println
(
"changing level"
);
isChangingLevel
=
false
;
isChangingLevel
=
false
;
totalTimeSinceAction
=
0
;
}
}
else
{
else
{
totalTimeSinceAction
+=
dt
;
totalTimeSinceAction
+=
dt
;
...
...
This diff is collapsed.
Click to expand it.
core/src/handlers/ContactListenerPerso.java
+
11
−
0
View file @
82468033
...
@@ -14,6 +14,7 @@ public class ContactListenerPerso implements ContactListener {
...
@@ -14,6 +14,7 @@ public class ContactListenerPerso implements ContactListener {
Array
<
Body
>
bodyToRemove
=
new
Array
<
Body
>();
Array
<
Body
>
bodyToRemove
=
new
Array
<
Body
>();
private
int
score
=
0
;
private
int
score
=
0
;
private
boolean
triggerEndLevel
=
false
;
private
boolean
triggerEndLevel
=
false
;
private
boolean
touchWater
=
false
;
/**
/**
* Appeler quand 2 fixtures rentre en collision
* Appeler quand 2 fixtures rentre en collision
...
@@ -42,6 +43,12 @@ public class ContactListenerPerso implements ContactListener {
...
@@ -42,6 +43,12 @@ public class ContactListenerPerso implements ContactListener {
}
}
}
}
if
(
fa
.
getUserData
()
!=
null
&&
fa
.
getUserData
().
equals
(
"eau"
)){
touchWater
=
true
;
}
else
{
touchWater
=
false
;
}
}
}
/**
/**
...
@@ -100,4 +107,8 @@ public class ContactListenerPerso implements ContactListener {
...
@@ -100,4 +107,8 @@ public class ContactListenerPerso implements ContactListener {
public
boolean
isTriggerEndLevel
()
{
public
boolean
isTriggerEndLevel
()
{
return
triggerEndLevel
;
return
triggerEndLevel
;
}
}
public
boolean
isTouchWater
()
{
return
touchWater
;
}
}
}
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