From 24278190fb36cac7fb700bd719c8d10a68041765 Mon Sep 17 00:00:00 2001 From: Kelly Howard Date: Tue, 3 Nov 2015 08:17:45 -0800 Subject: [PATCH 1/3] fixed width/height of sag --- index.html | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 1041d28..1f2fd69 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,24 @@ Javascript Box - OOP demo + @@ -11,7 +29,7 @@ { var html_id = html_id; this.info = { cx: cx, cy: cy }; - + //private function that generates a random number var randomNumberBetween = function(min, max){ return Math.random()*(max-min) + min; @@ -24,8 +42,8 @@ y: randomNumberBetween(-3,3) } - //create a circle - var circle = makeSVG('circle', + //create a circle + var circle = makeSVG('circle', { cx: this.info.cx, cy: this.info.cy, r: 10, @@ -98,8 +116,8 @@ document.onclick = function(e) { playground.createNewCircle(e.x,e.y); } - + - \ No newline at end of file + From ad38b96cc97d1d1667df70a29ffc621931c5f45c Mon Sep 17 00:00:00 2001 From: Kelly Howard Date: Tue, 3 Nov 2015 08:18:58 -0800 Subject: [PATCH 2/3] fixed ball bounce --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 1f2fd69..a293dd6 100644 --- a/index.html +++ b/index.html @@ -58,11 +58,11 @@ var el = document.getElementById(html_id); //see if the circle is going outside the browser. if it is, reverse the velocity - if( this.info.cx > document.body.clientWidth || this.info.cx < 0) + if( this.info.cx > document.body.clientWidth-10 || this.info.cx < 10) { this.info.velocity.x = this.info.velocity.x * -1; } - if( this.info.cy > document.body.clientHeight || this.info.cy < 0) + if( this.info.cy > document.body.clientHeight-10 || this.info.cy < 10) { this.info.velocity.y = this.info.velocity.y * -1; } From 4ddaf341edaa4201cbd8320bd216749338b66609 Mon Sep 17 00:00:00 2001 From: Kelly Howard Date: Tue, 3 Nov 2015 08:52:04 -0800 Subject: [PATCH 3/3] adding variation to radius based on mouse touch and re-adjusted bounce --- index.html | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index a293dd6..4b8cece 100644 --- a/index.html +++ b/index.html @@ -25,10 +25,29 @@