Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

contrast up

  • Loading branch information...
commit 129e547b5521ee362d4cb66434571dab19c76e28 1 parent 0a4e723
chinchang authored

Showing 2 changed files with 12 additions and 4 deletions. Show diff stats Hide diff stats

  1. +3 3 game.js
  2. +9 1 index.html
6 game.js
@@ -21,7 +21,7 @@ function Ball(){
21 21 }
22 22
23 23 Ball.prototype.draw = function(context){
24   - context.strokeStyle = "#CCC";
  24 + context.strokeStyle = "#BBB";
25 25 context.fillStyle = "#FFF";
26 26 context.beginPath();
27 27 context.arc(0, 0, this.radius, 0, Math.PI*2, true);
@@ -48,7 +48,7 @@ Ball.prototype.update = function(dt){
48 48 if(cond1) this.x = canvas.width - this.radius;
49 49 if(cond2) this.x = this.radius;
50 50 if(cond1 || cond2)
51   - this.speed_x = -(this.speed_x/Math.abs(this.speed_x)) * (Math.round(Math.random() * 200) + 100);
  51 + this.speed_x = -this.speed_x;
52 52 if(this.y + this.radius + this.speed_y * dt > canvas.height){
53 53 score = 0;
54 54 this.speed_y = -this.speed_y * cor;
@@ -148,7 +148,7 @@ function onClick(e){
148 148 if(ball.containsPoint(e.offsetX, e.offsetY)){
149 149 score++;
150 150 ball.speed_y = -800;
151   - ball.speed_x = 500 - Math.random() * 1000;
  151 + ball.speed_x = 600 - Math.random() * 1200;
152 152 if(ball.is_on_floor) ball.is_on_floor = false;
153 153 }
154 154 }
10 index.html
@@ -14,10 +14,18 @@
14 14
15 15 <body>
16 16
17   -<canvas id="c" width="640" height="480" style="display: block; margin: 0 auto; border: 1px solid #CCC;"></canvas>
  17 +<div style="display: block; width: 650px; text-align: center; margin: 0 auto;">
  18 +
  19 +<canvas id="c" width="640" height="480" style=" border: 1px solid #BBB;"></canvas>
18 20
19 21 <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>
20 22
  23 +<p>
  24 + View the <a target="blank" href="https://github.com/chinchang/Bouncy_HTML5">source code</a>.
  25 +</p>
  26 +
  27 +</div>
  28 +
21 29 <script src="game.js"></script>
22 30 </body>
23 31

0 comments on commit 129e547

Please sign in to comment.
Something went wrong with that request. Please try again.