===================================================================
--- original.js
+++ change.js
@@ -176,9 +176,9 @@
****/
/****
* GAME DESCRIPTION:
* Game Principle:
- * NAME: COCO MONKEY V1.0 by Dalhem 2024
+ * NAME: COCO MONKEY V1.1 by Dalhem 2024
* -There is beach where people are enjoying the sun by the shadow of palm trees.
* -Above them, three palm trees are growing coconuts.
* -In the trees, a monkey is throwing coconuts from the top of the trees, thus three points of departure.
* -The player controls a guy who holding a parasol to protect everyone from the coconuts.
@@ -386,9 +386,9 @@
// Choisir aléatoirement un point de départ
var randomIndex = Math.floor(Math.random() * startPoints.length);
var randomDeltaX = Math.floor(Math.random() * 100) - 50;
var randomDeltaY = Math.floor(Math.random() * 100) - 50;
- var typeTrajectory = -1; //Trajectoire statique
+ var typeTrajectory = 0; //Trajectoire linéaire
var X1 = startPoints[randomIndex] + randomDeltaX;
var X2 = X1;
var Y0 = monkeyLevel + randomDeltaY;
var Yh = Y0;
@@ -406,67 +406,8 @@
for (var i = 0; i < coconutsInTree.length; i++) {
game.addChild(coconutsInTree[i]);
}
} //fin setCocoInTree
-//Fonction chooseNextStartPoint: choisit aléatoirement un point de départ d'un coconut
-//Renvoie un objet Coconut
-function chooseNextStartPoint() {
- var newCoconut = new Coconut();
- // Choisir aléatoirement un point de départ
- var randomIndex = Math.floor(Math.random() * startPoints.length);
- var typeTrajectory = 0;
- newCoconut.isFalling = true;
- var X1 = startPoints[randomIndex]; //X1 est l'abscisse de départ du coconut
- var X2 = X1; //X2 est l'abscisse d'arrivée du coconut
- var Y0 = groundLevel;
- var Yh = monkeyLevel;
- if (wave < 2) {
- //Trajectoires rectilignes
- X2 = X1;
- newCoconut.trajectory.setParameters(typeTrajectory, X1, X2, Y0, Yh, nbTicksToFall); //Définit la trajectoire du coconut de type linéaire de la wave 1 à 10
- } else {
- //Trajectoires rectilignes ou parabolique (à implémenter)
- //Si X1 = XL alors X2 = XL (trajectoire linéaire) ou XC (trajectoire parabolique),
- //si X1 = XC alors X2 = XL (trajectoire parabolique) ou XC (trajectoire linéaire) ou XR (trajectoire parabolique),
- //si X1 = XR alors X2 = XC (trajectoire parabolique) ou XR (trajectoire linéaire)
- var randomIndex = Math.floor(Math.random() * 2);
- if (X1 == XL) {
- if (randomIndex == 0) {
- X2 = XL;
- }
- if (randomIndex == 1) {
- X2 = XC;
- typeTrajectory = 1;
- }
- }
- if (X1 == XC) {
- if (randomIndex == 0) {
- X2 = XL;
- typeTrajectory = 1;
- }
- if (randomIndex == 1) {
- X2 = XC;
- }
- if (randomIndex == 2) {
- X2 = XR;
- typeTrajectory = 1;
- }
- }
- if (X1 == XR) {
- if (randomIndex == 0) {
- X2 = XC;
- typeTrajectory = 1;
- }
- if (randomIndex == 1) {
- X2 = XR;
- }
- }
- newCoconut.trajectory.setParameters(typeTrajectory, X1, X2, Y0, Yh, nbTicksToFall); //Définit la trajectoire du coconut de type linéaire ou parabolique de la wave 11 à 20
- }
- coconuts.push(newCoconut);
- moveMonkeyToStartPoint(X1, monkeyLevel);
- return newCoconut;
-} //fin chooseNextStartPoint
//Fonction chooseNextCoconut: choisit aléatoirement un coconut dans les arbres
//Renvoie un objet Coconut
function chooseNextCoconut() {
var randomIndex = Math.floor(Math.random() * coconutsInTree.length);
@@ -477,9 +418,17 @@
var X1 = newCoconut.x;
var X2 = X1;
var Y0 = groundLevel;
var Yh = newCoconut.y;
- newCoconut.trajectory.setParameters(typeTrajectory, X1, X2, Y0, Yh, nbTicksToFall);
+ //Après la wave 10, la vitesse de chute accelère de X par wave
+ var randNbTicksToFall = nbTicksToFall;
+ if (wave > 10) {
+ randNbTicksToFall = nbTicksToFall - 10 * (wave - 10);
+ if (randNbTicksToFall <= 20) {
+ randNbTicksToFall = 20;
+ }
+ }
+ newCoconut.trajectory.setParameters(typeTrajectory, X1, X2, Y0, Yh, randNbTicksToFall);
coconuts.push(newCoconut);
return newCoconut;
} //fin chooseNextCoconut
//Fonction moveMoveMonkeyToCoconut: déplace le monkey au point de depart du coconut