Skip to content

Commit

Permalink
Ready: Check if mouse is inside arrow's rectangle
Browse files Browse the repository at this point in the history
  • Loading branch information
marianaviro committed May 2, 2018
1 parent 5cdce5f commit 1e062e6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sketch1.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ var firstPrinciple = function(s) {
var y;
var easing;
var bck;
var arrow;


s.setup = function() {
x = 0;
y = 0;
easing = 0.05;
bck = '#04E973';
arrow =
arrow =

//Canvas
s.createCanvas(s.displayWidth, s.displayHeight);
Expand Down Expand Up @@ -83,7 +82,14 @@ var firstPrinciple = function(s) {
}

s.mouseClicked = function() {
s.down();
//Check if the mouse is inside the arrow's rectangle
// var mx = s.windowWidth - x;
// var my = s.windowHeight - y;
var dx = Math.abs(s.mouseX - s.windowWidth + x);
var dy = Math.abs(s.mouseY - s.windowHeight + y);
if( dx < 20 && dy < 20) {
s.down();
}
}


Expand Down

0 comments on commit 1e062e6

Please sign in to comment.