11486 sujets

JavaScript, DOM et API Web HTML5

Bonjour mes amis ! J'ai un projet de JS à réaliser pour mon école ; alors l'idée est de réaliser un jeux clik genre CookiesClikers. J'ai développé un clock

Alors je voudrais que lorsque l'utilisateur clik sur une image et qu' au moment où le compteur arrive à 30 qu'il m'ajoute une image
Aidez-moi s'il vous plaît je serais ravie ; je vous laisse également mon code HTML

Merci d'avance



<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">


    <link rel="stylesheet" href="https://npmcdn.com/bulma@0.0.4/css/bulma.min.css">
    <link rel="stylesheet" href="css/style.css">
    <title>Clock</title>
</head>
<body>


<div id="clock">
    ...
</div>
<div class="columns">
    <div class="column">
        First column
    </div>

    <div class="column">
        Second column
    </div>


    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
            integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g=" crossorigin="anonymous"></script>
    <script src="class/Cookie.js"></script>
    <script src="class/Clock.js"></script>
    <script src="class/Controller.js"></script>


</body>
</html>



'use strict';

class Clock {
  constructor(game, container) {

    // Clock properties
    this.container = container;
    this.day = 20;
    this.month = 12;
    this.year = new Date().getFullYear();
    this.play = false;
  }

  init() {
    console.log(game.pouet);
    this.tick();
  }

  updateUI() {
    var day = (this.day < 10) ? `0${this.day}` : this.day,
        month =  (this.month < 10) ? `0${this.month}` : this.month;

    this.container.html(`${day}/${month}/${this.year}`);
  }

  tick() {
    this.updateUI();
    game.cookie.count(10);
    setTimeout(() => this.engine(), 1000);
  }

  engine() {
    if(this.day < 28) {
      ++this.day;
      this.tick();
      return;
    }

    switch(this.month) {
      default:
        if(this.day === 31) {this.newMonth(); break;}
        ++this.day;
        break;

      case 4:
      case 6:
      case 9:
      case 11:
        if(this.day === 30) {this.newMonth(); break;}
        ++this.day;
        break;

      case 2:
        if(this.day === 29 || ((this.year % 4 !== 0 || this.year % 100 === 0) && this.year % 400 !== 0)) {this.newMonth(); break;}
        ++this.day;
        break;

      case 12:
        if(this.day === 31) {this.month = 0; this.newMonth(); this.newYear(); break;}
        ++this.day;
        break;
    }

    this.tick();
  }

  newMonth() {
    ++this.month;
    this.day = 1;
    return;
  }

  newYear() {
    ++this.year;
    return;
  }
}



Modifié par DiegoGaby (08 Jan 2018 - 10:18)
Salut les amis c'est juste que je voudrais que vous m'aidiez pour ce projet que je dois rendre jeudi prochain svp merci d'avance