Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sae-2023-groupeH-Bouin-Belguebli-Decoster
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
Julien Bouin
sae-2023-groupeH-Bouin-Belguebli-Decoster
Commits
0eea5a6c
Commit
0eea5a6c
authored
1 year ago
by
Mathis Decoster
Browse files
Options
Downloads
Patches
Plain Diff
invincibilité et vie en plus opérationnelles en objet
parent
4cb2b7d8
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
client/src/avatar.js
+14
-3
14 additions, 3 deletions
client/src/avatar.js
client/src/bonus.js
+4
-2
4 additions, 2 deletions
client/src/bonus.js
client/src/main.js
+14
-8
14 additions, 8 deletions
client/src/main.js
client/src/timer.js
+1
-1
1 addition, 1 deletion
client/src/timer.js
with
33 additions
and
14 deletions
client/src/avatar.js
+
14
−
3
View file @
0eea5a6c
...
@@ -13,6 +13,7 @@ export class Avatar extends Entite {
...
@@ -13,6 +13,7 @@ export class Avatar extends Entite {
momentumX
;
momentumX
;
momentumY
;
momentumY
;
statut
;
statut
;
statutTime
;
constructor
(
nom
,
vitesse
)
{
constructor
(
nom
,
vitesse
)
{
super
(
0
,
0
,
new
Hitbox
(
68
,
145
,
0
,
0
),
null
);
super
(
0
,
0
,
new
Hitbox
(
68
,
145
,
0
,
0
),
null
);
...
@@ -28,6 +29,8 @@ export class Avatar extends Entite {
...
@@ -28,6 +29,8 @@ export class Avatar extends Entite {
this
.
inertie
=
0.95
;
this
.
inertie
=
0.95
;
this
.
momentumX
=
0
;
this
.
momentumX
=
0
;
this
.
momentumY
=
0
;
this
.
momentumY
=
0
;
this
.
statut
=
'
null
'
;
this
.
statutTime
=
null
;
}
}
incrementScore
(
nb
)
{
incrementScore
(
nb
)
{
...
@@ -54,6 +57,14 @@ export class Avatar extends Entite {
...
@@ -54,6 +57,14 @@ export class Avatar extends Entite {
});
});
}
}
getStatutTime
()
{
return
this
.
statutTime
;
}
setStatutTime
(
t
)
{
this
.
statutTime
=
t
;
}
setImageCanvas
(
image
,
canvas
)
{
setImageCanvas
(
image
,
canvas
)
{
super
.
image
=
image
;
super
.
image
=
image
;
this
.
canvas
=
canvas
;
this
.
canvas
=
canvas
;
...
@@ -75,12 +86,12 @@ export class Avatar extends Entite {
...
@@ -75,12 +86,12 @@ export class Avatar extends Entite {
return
this
.
click
;
return
this
.
click
;
}
}
setStatut
(
statu
s
)
{
setStatut
(
statu
t
)
{
this
.
statut
=
statu
s
;
this
.
statut
=
statu
t
;
}
}
getStatus
()
{
getStatus
()
{
return
this
.
statu
s
;
return
this
.
statu
t
;
}
}
colision
(
x
,
y
,
image
)
{
colision
(
x
,
y
,
image
)
{
...
...
This diff is collapsed.
Click to expand it.
client/src/bonus.js
+
4
−
2
View file @
0eea5a6c
import
Entite
from
'
./entite.js
'
;
import
Entite
from
'
./entite.js
'
;
import
{
Hitbox
}
from
'
./hitbox.js
'
;
import
{
Hitbox
}
from
'
./hitbox.js
'
;
import
{
bonusImages
}
from
'
./choixBonus.js
'
;
export
default
class
Bonus
extends
Entite
{
export
default
class
Bonus
extends
Entite
{
nom
;
nom
;
taille
;
taille
;
apparition
;
apparition
;
constructor
(
choix
,
taille
,
x
,
y
,
image
,
time
)
{
constructor
(
choix
,
taille
,
x
,
y
,
image
,
time
)
{
super
(
x
,
y
,
new
Hitbox
(
image
.
width
/
2
,
image
.
height
,
x
,
y
),
image
);
super
(
x
,
y
,
new
Hitbox
(
image
.
width
,
image
.
height
,
x
,
y
),
image
);
this
.
choix
=
choix
;
this
.
choix
=
choix
;
this
.
taille
=
taille
;
this
.
taille
=
taille
;
this
.
apparition
=
time
;
this
.
apparition
=
time
;
this
.
image
.
src
=
bonusImages
[
choix
];
}
}
estExpire
(
t
)
{
estExpire
(
t
)
{
return
t
-
this
.
apparition
>
=
60
;
return
t
-
this
.
apparition
=
=
60
;
}
}
getChoix
()
{
getChoix
()
{
...
...
This diff is collapsed.
Click to expand it.
client/src/main.js
+
14
−
8
View file @
0eea5a6c
...
@@ -104,22 +104,29 @@ document.addEventListener('keyup', event => {
...
@@ -104,22 +104,29 @@ document.addEventListener('keyup', event => {
avatar
.
changerClick
(
event
);
avatar
.
changerClick
(
event
);
});
});
setInterval
(
genererBonus
,
1000
);
setInterval
(
genererBonus
,
1
5
000
);
function
genererBonus
()
{
function
genererBonus
()
{
if
(
gameStarted
)
{
if
(
gameStarted
)
{
const
choix
=
Math
.
floor
(
Math
.
random
()
*
bonusNoms
.
length
);
const
choix
=
Math
.
floor
(
Math
.
random
()
*
bonusNoms
.
length
);
let
randomY
=
Math
.
floor
(
Math
.
random
()
*
canvas
.
height
);
let
randomY
=
Math
.
floor
(
Math
.
random
()
*
canvas
.
height
);
let
randomX
=
Math
.
floor
(
Math
.
random
()
*
canvas
.
width
);
let
randomX
=
Math
.
floor
(
Math
.
random
()
*
canvas
.
width
);
let
img
=
new
Image
();
let
img
=
new
Image
();
img
.
src
=
bonusImages
[
choix
];
img
.
width
=
75
;
img
.
width
=
100
;
img
.
height
=
75
;
img
.
height
=
100
;
const
bonus
=
new
Bonus
(
choix
,
1
,
randomX
,
randomY
,
img
,
t
.
getTotalTime
());
const
bonus
=
new
Bonus
(
choix
,
1
,
randomX
,
randomY
,
img
,
t
.
getTotalTime
());
bonusArray
.
push
(
bonus
);
bonusArray
.
push
(
bonus
);
}
}
}
}
setInterval
(()
=>
{
setInterval
(()
=>
{
console
.
log
(
t
.
getTotalTime
()
-
avatar
.
getStatutTime
()
==
15
);
console
.
log
(
t
.
getTotalTime
()
-
avatar
.
getStatutTime
());
if
(
avatar
.
getStatus
()
==
'
invincibilite
'
&&
t
.
getTotalTime
()
-
avatar
.
getStatutTime
()
==
15
)
{
avatar
.
setStatut
(
'
null
'
);
}
avatar
.
deplacer
();
avatar
.
deplacer
();
avatar
.
projectiles
.
forEach
(
projectile
=>
projectile
.
deplacer
());
avatar
.
projectiles
.
forEach
(
projectile
=>
projectile
.
deplacer
());
enemis
.
forEach
(
enemi
=>
{
enemis
.
forEach
(
enemi
=>
{
...
@@ -165,11 +172,12 @@ setInterval(() => {
...
@@ -165,11 +172,12 @@ setInterval(() => {
if
(
bonusNoms
[
bonus
.
getChoix
()]
==
'
vie
'
)
{
if
(
bonusNoms
[
bonus
.
getChoix
()]
==
'
vie
'
)
{
avatar
.
gagnerVie
();
avatar
.
gagnerVie
();
}
else
if
(
bonusNoms
[
bonus
.
getChoix
()]
==
'
invincibilite
'
)
{
}
else
if
(
bonusNoms
[
bonus
.
getChoix
()]
==
'
invincibilite
'
)
{
console
.
log
(
'
INVICIBILITE
'
);
avatar
.
setStatut
(
'
invincibilite
'
);
avatar
.
setStatut
(
'
invincibilite
'
);
avatar
.
setStatutTime
(
t
.
getTotalTime
());
}
}
bonusArray
.
splice
(
bonusArray
.
indexOf
(
bonus
),
1
);
bonusArray
.
splice
(
bonusArray
.
indexOf
(
bonus
),
1
);
}
else
if
(
bonus
.
estExpire
(
t
.
getTotalTime
()))
{
}
if
(
bonus
.
estExpire
(
t
.
getTotalTime
()))
{
bonusArray
.
splice
(
bonusArray
.
indexOf
(
bonus
),
1
);
bonusArray
.
splice
(
bonusArray
.
indexOf
(
bonus
),
1
);
}
}
});
});
...
@@ -221,7 +229,6 @@ function render() {
...
@@ -221,7 +229,6 @@ function render() {
});
});
}
}
bonusArray
.
forEach
(
bonus
=>
{
bonusArray
.
forEach
(
bonus
=>
{
console
.
log
(
bonus
);
if
(
if
(
bonus
.
x
<=
canvas
.
width
-
bonus
.
image
.
width
&&
bonus
.
x
<=
canvas
.
width
-
bonus
.
image
.
width
&&
bonus
.
y
<=
canvas
.
height
&&
bonus
.
y
<=
canvas
.
height
&&
...
@@ -235,7 +242,6 @@ function render() {
...
@@ -235,7 +242,6 @@ function render() {
});
});
enemis
.
forEach
(
enemi
=>
{
enemis
.
forEach
(
enemi
=>
{
console
.
log
(
enemi
.
getDifficulte
());
if
(
if
(
enemi
.
x
<=
canvas
.
width
-
enemi
.
image
.
width
&&
enemi
.
x
<=
canvas
.
width
-
enemi
.
image
.
width
&&
enemi
.
y
<=
canvas
.
height
&&
enemi
.
y
<=
canvas
.
height
&&
...
...
This diff is collapsed.
Click to expand it.
client/src/timer.js
+
1
−
1
View file @
0eea5a6c
...
@@ -17,7 +17,7 @@ export default class timer {
...
@@ -17,7 +17,7 @@ export default class timer {
}
}
getTotalTime
()
{
getTotalTime
()
{
return
3600
*
this
.
getHrs
()
+
60
*
this
.
getMin
()
+
this
.
getS
ec
;
return
3600
*
this
.
hrs
+
60
*
this
.
min
+
this
.
s
ec
;
}
}
getSec
()
{
getSec
()
{
...
...
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