Merge remote-tracking branch 'origin/master'

master
orphevs 2017-12-09 04:21:45 +01:00
commit 9eae7baf84
1 changed files with 41 additions and 5 deletions

View File

@ -5,6 +5,8 @@ var maxY = document.querySelectorAll('.line').length;
var x = 1; var x = 1;
var y = 5; var y = 5;
var cibleValue = 0;
var score = 0;
var controls = { var controls = {
up: 'z', up: 'z',
@ -31,6 +33,12 @@ function setPosition (posX, posY, dir) {
gridX = x; gridX = x;
gridY = y; gridY = y;
var grid = document.querySelector('.line-'+posY+' .col-'+posX);
if(grid.classList.contains('cible')){
return;
}
var grids = document.querySelectorAll('.col'); var grids = document.querySelectorAll('.col');
grids.forEach(function(e){ grids.forEach(function(e){
@ -38,8 +46,6 @@ function setPosition (posX, posY, dir) {
e.style.backgroundPosition = ''; e.style.backgroundPosition = '';
}); });
var grid = document.querySelector('.line-'+posY+' .col-'+posX);
direction = dir; direction = dir;
grid.style.background = 'url(./assets/img/tank_bg.png) no-repeat'; grid.style.background = 'url(./assets/img/tank_bg.png) no-repeat';
@ -117,6 +123,22 @@ setInterval(function(){
var newY = bulletY; var newY = bulletY;
var newX = bulletX; var newX = bulletX;
var bulletDestination = document.querySelector('.line-'+newY+' .col-'+newX);
if(bulletDestination.classList.contains('cible')){
bulletDestination.classList.remove('cible');
cibleValue = cibleValue - 1;
score = score + 100 ;
console.log(score);
bulletDestination.classList.add('cible-touchee');
bulletX = 0;
bulletY = 0;
setTimeout(function(){
bulletDestination.classList.remove('cible-touchee');
}, 1000);
return;
}
switch(bulletDir){ switch(bulletDir){
case rotation.up: case rotation.up:
newY--; newY--;
@ -150,6 +172,9 @@ setInterval(function(){
if(bulletDestination.classList.contains('cible')){ if(bulletDestination.classList.contains('cible')){
bulletDestination.classList.remove('cible'); bulletDestination.classList.remove('cible');
cibleValue = cibleValue - 1;
score = score + 100 ;
console.log(score);
bulletDestination.classList.add('cible-touchee'); bulletDestination.classList.add('cible-touchee');
bulletX = 0; bulletX = 0;
bulletY = 0; bulletY = 0;
@ -171,7 +196,7 @@ setInterval(function(){
document.addEventListener('keydown', move, false); document.addEventListener('keydown', move, false);
>>>>>>> Stashed changes >>>>>>> Stashed changes
setInterval(function(){ var ntm = setInterval(function(){
x2 = Math.floor(Math.random() * 11); x2 = Math.floor(Math.random() * 11);
if (x2 == x){ if (x2 == x){
x2 = x+1; x2 = x+1;
@ -180,12 +205,23 @@ setInterval(function(){
if (y2 == y){ if (y2 == y){
y2 = y+1; y2 = y+1;
} }
if(ciblex < maxX && cibley < maxY){
console.log(ciblex+' pour '+maxX);
emplacement = document.querySelector(".line-"+ciblex+" .col-"+cibley);
emplacement.classList.add('cible');
}
var ciblex = x2, var ciblex = x2,
cibley = y2, cibley = y2,
emplacement = document.querySelector(".line-"+ciblex+" .col-"+cibley); emplacement = document.querySelector(".line-"+ciblex+" .col-"+cibley);
emplacement.classList.add('cible'); emplacement.classList.add('cible');
<<<<<<< Updated upstream cibleValue = cibleValue + 1;
}, 3000); if (cibleValue>=3){
alert("TAS PERDU");
clearInterval(ntm);
}
}, 1000);
document.addEventListener('keydown', move, false); document.addEventListener('keydown', move, false);
setPosition(x, y, direction); setPosition(x, y, direction);