Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 38 lines (33 sloc) 1.079 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
class Title {
  HTMLCanvasElement canvas;
  CanvasRenderingContext2D ctx;
  HTMLImageElement img;
  HTMLAudioElement audio;
  
  Title(){
    canvas = window.document.getElementById('canvas');
    ctx = canvas.getContext('2d');
    img = window.document.createElement('img');
    img.src = "images/intro.png";
    img.onload = (e){
      ctx.drawImage(img, 0 , 0);
      canvas.onmousedown = clickListener;
      audio = window.document.createElement('audio');
      audio.loop = true;
      audio.src = 'sounds/background.mp3';
      audio.autoplay = true;
    };
  }

  

  void clickListener(MouseEvent e){
    if(e.offsetX >= 152 && e.offsetX <= (152+183) && e.offsetY >= 540 && e.offsetY <= (540+89)){
      ctx.clearRect(0,0,canvas.width, canvas.height);
      canvas.onmousedown = (e){};
      audio.pause();
      new Game();
    }
    else if(e.offsetX >= 442 && e.offsetX <= (442+186) && e.offsetY >= 529 && e.offsetY <= (529+116)){
      ctx.clearRect(0,0,canvas.width, canvas.height);
      new Introduction(audio);
      canvas.onmousedown = (e){};
    }
    
  }
}
Something went wrong with that request. Please try again.