fPQsjgiohsghioshigsgse

master
Fouque Dimitri 2017-12-09 04:14:40 +01:00 committed by GitHub
parent 3d1f5facc6
commit 3b7452eb85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 14 deletions

View File

@ -5,6 +5,8 @@ var maxY = document.querySelectorAll('.line').length;
var x = 1;
var y = 5;
var cibleValue = 0;
var score = 0;
var controls = {
up: 'z',
@ -27,13 +29,10 @@ var bulletX = 0;
var bulletY = 0;
var bulletDir = direction;
var cibleValue = 0;
function setPosition (posX, posY, dir) {
gridX = x;
gridY = y;
var grid = document.querySelector('.line-'+posY+' .col-'+posX);
if(grid.classList.contains('cible')){
@ -123,6 +122,22 @@ setInterval(function(){
var newY = bulletY;
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){
case rotation.up:
newY--;
@ -155,8 +170,10 @@ setInterval(function(){
var bulletDestination = document.querySelector('.line-'+newY+' .col-'+newX);
if(bulletDestination.classList.contains('cible')){
cibleValue -= 1;
bulletDestination.classList.remove('cible');
cibleValue = cibleValue - 1;
score = score + 100 ;
console.log(score);
bulletDestination.classList.add('cible-touchee');
bulletX = 0;
bulletY = 0;
@ -175,17 +192,15 @@ setInterval(function(){
grid.style.backgroundPosition = bulletDir;
}, 32.12);
setInterval(function(){
x2 = Math.floor(Math.random() * 10) + 1;
var ntm = setInterval(function(){
x2 = Math.floor(Math.random() * 11);
if (x2 == x){
x2 = x+1;
}
y2 = Math.floor(Math.random() * 20) + 1;
y2 = Math.floor(Math.random() * 21);
if (y2 == y){
y2 = y+1;
}
var ciblex = x2,
cibley = y2
if(ciblex < maxX && cibley < maxY){
console.log(ciblex+' pour '+maxX);
@ -193,13 +208,16 @@ setInterval(function(){
emplacement.classList.add('cible');
}
var ciblex = x2,
cibley = y2,
emplacement = document.querySelector(".line-"+ciblex+" .col-"+cibley);
emplacement.classList.add('cible');
cibleValue = cibleValue + 1;
if (cibleValue>=3){
console.log("TAS PERDU");
// TODO
if (cibleValue>=3){
alert("TAS PERDU");
clearInterval(ntm);
}
}, 3000);
}, 1000);
document.addEventListener('keydown', move, false);
setPosition(x, y, direction);