Button to save the earth with
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

save-the-earth.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. var img, imgMask;
  2. var earthVideo;
  3. var levelSound;
  4. var continueBut;
  5. var frameSize;
  6. var label = "Click to save the earth.";
  7. var f = 0;
  8. var bg = 0;
  9. var nullifyFill = 1;
  10. var rotator = 0;
  11. var clicked = false;
  12. function preload() {
  13. levelSound = loadSound('sound.ogg');
  14. img = loadImage('Golden-Round-Frame-PNG.png');
  15. imgMask = loadImage('mask.png');
  16. earthVideo = createVideo(['video.webm']);
  17. }
  18. function mouseClicked() {
  19. if(!clicked){
  20. clicked = true;
  21. levelSound.play();
  22. label = "Earth saved.";
  23. earthVideo.loop();
  24. }
  25. }
  26. function setup() {
  27. frameSize = min(window.innerWidth, window.innerHeight);
  28. //createCanvas(window.innerWidth,window.innerHeight);
  29. createCanvas(frameSize,frameSize);
  30. frameRate(30);
  31. textSize(frameSize/14);
  32. textStyle(BOLD);
  33. textAlign(CENTER);
  34. imageMode(CENTER);
  35. stroke(77);
  36. strokeWeight(1);
  37. earthVideo.hide();
  38. earthVideo.loop();
  39. }
  40. function draw() {
  41. clear();
  42. earthVideo.mask(imgMask);
  43. image(earthVideo,frameSize/2,frameSize/2,frameSize/1.777,frameSize/1.777);
  44. if(clicked){
  45. push();
  46. translate(frameSize/2,frameSize/2);
  47. rotate(rotator);
  48. image(img,0,0,frameSize,frameSize);
  49. pop()
  50. fill(250,230,80);
  51. rotator+=0.01;
  52. } else {
  53. fill(255);
  54. }
  55. text(label, frameSize/2,frameSize/2);
  56. }