Skip to content

Commit

Permalink
instance boxes et une decrementation de vision color
Browse files Browse the repository at this point in the history
  • Loading branch information
KuhlMatthis committed Mar 17, 2022
1 parent 4b15266 commit 8626b33
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8">
<link rel="stylesheet" href="css/default.css">
<script src="lib/babylon.max.js"></script>
<script src="lib/cannon.js"></script>
<script type="module" src="js/main.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion js/Chemin.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class Chemin {
}

copyBox(mypos){
this.boxes[this.boxes.length+1] = this.box.clone();
this.boxes[this.boxes.length+1] = this.box.createInstance("copyCheminbox");
this.boxes[this.boxes.length-1].position.x = mypos[0]*10;
this.boxes[this.boxes.length-1].position.z = mypos[1]*10;
}
Expand Down
2 changes: 2 additions & 0 deletions js/Dude.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export default class Dude {
this.dudeMesh.rotation.y += 0.06;
this.dudeMesh.frontVector = new BABYLON.Vector3(Math.sin(this.dudeMesh.rotation.y), 0, Math.cos(this.dudeMesh.rotation.y));
}


if(inputStates.up || inputStates.down || inputStates.left || inputStates.right){
this.animation(scene,1);
}else{
Expand Down
6 changes: 3 additions & 3 deletions js/Sale.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ export default class Sale {
for(let z = 0; z < this.width; z++){
if(x==0 || x==this.length-1 || z==0 || z==this.width-1){
if(this.porte[0]<=x && x<=this.porte[2] && this.porte[1]<=z && z<=this.porte[3]){
boxes[nb] = box1.clone();
boxes[nb] = box1.createInstance("copySalebox"+nb);
boxes[nb].position.x += x*this.taille;
boxes[nb].position.z += z*this.taille;
nb+=1;
}else{
for(let y = 0; y < this.height; y++){
boxes[nb] = box2.clone();
boxes[nb] = box2.createInstance("copySalebox"+nb);
boxes[nb].position.x += x*this.taille;
boxes[nb].position.z += z*this.taille;
boxes[nb].position.y += y*this.taille;
nb+=1;
}
}
}else{
boxes[nb] = box1.clone();
boxes[nb] = box1.createInstance("copySalebox"+nb);
boxes[nb].position.x += x*this.taille;
boxes[nb].position.z += z*this.taille;
nb+=1;
Expand Down
25 changes: 22 additions & 3 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function startGame() {
engine = new BABYLON.Engine(canvas, true);
scene = createScene();
modifySettings();

// main animation loop 60 times/s
engine.runRenderLoop(() => {
let picatchu = scene.getMeshByName("mypicatchu");
Expand All @@ -34,8 +35,11 @@ function createScene() {
let groundMatrial = new BABYLON.StandardMaterial("mat", scene);
var texture = new BABYLON.Texture("img/sole1.jpg", scene);
groundMatrial.diffuseTexture = texture;

ground.material = groundMatrial;
scene.fogMode = BABYLON.Scene.FOGMODE_EXP;
scene.fogColor = new BABYLON.Color3(0, 0, 0);
scene.fogDensity = 0.01;

//var skybox = BABYLON.Mesh.CreateBox("BackgroundSkybox", 500, scene, undefined, BABYLON.Mesh.BACKSIDE);

// Create and tweak the background material.
Expand Down Expand Up @@ -232,7 +236,14 @@ function modifySettings() {
inputStates.right = true;
} else if ((event.key === "ArrowDown")|| (event.key === "s")|| (event.key === "S")) {
inputStates.down = true;
} else if (event.key === " ") {
}else if (event.key === "f") {
inputStates.fire1 = true;
}else if (event.key === "g"){
inputStates.fire2 = true;
}else if(event.key === "h"){
inputStates.fight = true;
}
else if (event.key === " ") {
inputStates.space = true;
}
}, false);
Expand All @@ -247,7 +258,15 @@ function modifySettings() {
inputStates.right = false;
} else if ((event.key === "ArrowDown")|| (event.key === "s")|| (event.key === "S")) {
inputStates.down = false;
} else if (event.key === " ") {
}else if (event.key === "f") {
inputStates.fire1 = false;
}else if (event.key === "g"){
inputStates.fire2 = false;
}else if(event.key === "h"){
inputStates.fight = false;
}else if (event.key === " ") {
inputStates.space = false;
}else if (event.key === " ") {
inputStates.space = false;
}
}, false);
Expand Down

0 comments on commit 8626b33

Please sign in to comment.