Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 1 file changed
  • 0 comments
  • 1 contributor

Showing 1 changed file with 22 additions and 8 deletions. Show diff stats Hide diff stats

  1. 30  365.js
30  365.js
@@ -298,7 +298,7 @@ Canvas365.registerDay('365', function(){
298 298
     };
299 299
 
300 300
     Shark.prototype.update = function(){
301  
-        this.t += 0.01
  301
+        this.t += 0.01;
302 302
         var dx = 50 * Math.cos(this.t);
303 303
         var dy = 30 * Math.sin(this.t);
304 304
         this.x = this.cx + dx;
@@ -468,12 +468,12 @@ Canvas365.registerDay('365', function(){
468 468
 
469 469
         ctx.fill();
470 470
         ctx.restore();
471  
-    }
  471
+    };
472 472
 
473 473
     Bird.prototype.update = function(){
474 474
         this.t += 0.1;
475 475
         this.m = 7 * (1 + Math.sin(this.t));
476  
-    }
  476
+    };
477 477
 
478 478
     var drawList = [];
479 479
     return {
@@ -486,16 +486,17 @@ Canvas365.registerDay('365', function(){
486 486
                 vx : 3,
487 487
                 vy : 0,
488 488
                 zIndex : 10,
489  
-                msg : ["Hello!", "Click anywhere and I'll go!"],
  489
+                msg : ["Hello!", "Click anywhere on the", "beach and I'll go!"],
490 490
                 scale : 0.8
491 491
             });
492 492
             drawList.push(stickman);
493 493
 
494  
-            drawList.push(new Beach(ctx, {
  494
+            var beach = new Beach(ctx, {
495 495
                 yWater : 250,
496 496
                 ySand  : 350,
497 497
                 zIndex : -1
498  
-            }));
  498
+            });
  499
+            drawList.push(beach);
499 500
 
500 501
             drawList.push(new Sun(ctx, {
501 502
                 x : 400,
@@ -538,8 +539,21 @@ Canvas365.registerDay('365', function(){
538 539
             });
539 540
 
540 541
             ctx.canvas.addEventListener('click', function(ev){
541  
-                console.log(ev.offsetX, stickman.y);
542  
-                stickman.goTo(ev.offsetX, stickman.y); // animated
  542
+                var x = ev.clientX - ctx.canvas.offsetLeft;
  543
+                var y = ev.clientY - ctx.canvas.offsetTop;
  544
+
  545
+                // add bird
  546
+                if(y < beach.config.yWater){
  547
+                    drawList.push(new Bird(ctx, {
  548
+                        x : x,
  549
+                        y : y,
  550
+                        scale : 0.2 + Math.random()
  551
+                    }));
  552
+                }
  553
+                // movement
  554
+                else {
  555
+                    stickman.goTo(x, stickman.y); // animated
  556
+                }
543 557
             }, false);
544 558
         },
545 559
         main : function(ctx){

No commit comments for this range

Something went wrong with that request. Please try again.