C'est le jeu des tubes de couleur dans les pubs la
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sketch.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. function setup()
  2. {
  3. newGame();
  4. }
  5. function newGame() {
  6. let params = gatherMenuValues();
  7. this.game = new Game(params.TUBESNUMBERS, params.TUBESLEVELS);
  8. this.drawer = new Drawer(params.PADDING);
  9. this.drawer.setTubesParams(params.TUBESNUMBERS, params.TUBESLEVELS, params.TUBESIZE);
  10. this.needUpdate = true;
  11. }
  12. function mousePressed(e)
  13. {
  14. let tubeId = this.drawer.getTubeIdAt(mouseX, mouseY);
  15. if (tubeId != -1)
  16. {
  17. this.game.selectTube(tubeId);
  18. }
  19. this.needUpdate = true;
  20. }
  21. function gatherMenuValues()
  22. {
  23. let inputTubesNumbers = parseInt(document.getElementById("tbNumber").value);
  24. let inputTubesLevels = parseInt(document.getElementById("tbLevel").value);
  25. let inputTubeSize = parseInt(document.getElementById("tbSize").value);
  26. let inputPadding = parseInt(document.getElementById("padding").value);
  27. return {
  28. TUBESNUMBERS: inputTubesNumbers,
  29. TUBESLEVELS: inputTubesLevels,
  30. TUBESIZE: inputTubeSize,
  31. PADDING: inputPadding
  32. };
  33. }
  34. function draw()
  35. {
  36. if (!this.needUpdate) return;
  37. this.drawer.draw(this.game);
  38. this.needUpdate = false;
  39. }