Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

contrast up

  • Loading branch information...
commit 129e547b5521ee362d4cb66434571dab19c76e28 1 parent 0a4e723
@chinchang authored
Showing with 12 additions and 4 deletions.
  1. +3 −3 game.js
  2. +9 −1 index.html
View
6 game.js
@@ -21,7 +21,7 @@ function Ball(){
}
Ball.prototype.draw = function(context){
- context.strokeStyle = "#CCC";
+ context.strokeStyle = "#BBB";
context.fillStyle = "#FFF";
context.beginPath();
context.arc(0, 0, this.radius, 0, Math.PI*2, true);
@@ -48,7 +48,7 @@ Ball.prototype.update = function(dt){
if(cond1) this.x = canvas.width - this.radius;
if(cond2) this.x = this.radius;
if(cond1 || cond2)
- this.speed_x = -(this.speed_x/Math.abs(this.speed_x)) * (Math.round(Math.random() * 200) + 100);
+ this.speed_x = -this.speed_x;
if(this.y + this.radius + this.speed_y * dt > canvas.height){
score = 0;
this.speed_y = -this.speed_y * cor;
@@ -148,7 +148,7 @@ function onClick(e){
if(ball.containsPoint(e.offsetX, e.offsetY)){
score++;
ball.speed_y = -800;
- ball.speed_x = 500 - Math.random() * 1000;
+ ball.speed_x = 600 - Math.random() * 1200;
if(ball.is_on_floor) ball.is_on_floor = false;
}
}
View
10 index.html
@@ -14,10 +14,18 @@
<body>
-<canvas id="c" width="640" height="480" style="display: block; margin: 0 auto; border: 1px solid #CCC;"></canvas>
+<div style="display: block; width: 650px; text-align: center; margin: 0 auto;">
+
+<canvas id="c" width="640" height="480" style=" border: 1px solid #BBB;"></canvas>
<a href="http://github.com/chinchang"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/7afbc8b248c68eb468279e8c17986ad46549fb71/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub"></a>
+<p>
+ View the <a target="blank" href="https://github.com/chinchang/Bouncy_HTML5">source code</a>.
+</p>
+
+</div>
+
<script src="game.js"></script>
</body>
Please sign in to comment.
Something went wrong with that request. Please try again.