Browse Source

Fix some rendering issues and cleaning up safari

Thomas Dy 11 years ago
parent
commit
7678d43101
2 changed files with 22 additions and 8 deletions
  1. 11 8
      scripts/games/safari.js
  2. 11 0
      scripts/util.js

+ 11 - 8
scripts/games/safari.js

@@ -12,8 +12,6 @@ function SoundSafari(beatInfo, endless) {
   var METER_SPEED = 10;
   var PLAYER_SPEED = 50;
   var STAGE_SPEED = 25;
-  var RIPPLE_SIZE = 10;
-  var RIPPLE_SPEED = 10;
   var DOT_SIZE = 3;
   var DOT_DISTANCE = 4 * 5;
 
@@ -82,10 +80,6 @@ function SoundSafari(beatInfo, endless) {
       ctx.fill();
     }
 
-    function drawPlayer(point) {
-      drawCircle(point, RADIUS, 5, "#FFFFFF");
-    }
-
     function drawSpectrum() {
       var barHeight = 30;
       var barWidth = 6;
@@ -330,6 +324,11 @@ function SoundSafari(beatInfo, endless) {
     dx: PLAYER_SPEED
   };
 
+  var reference = {
+    x: canvas.width / 2,
+    y: canvas.height - 20
+  };
+
   var meter = new Meter();
 
   var points;
@@ -434,8 +433,12 @@ function SoundSafari(beatInfo, endless) {
       entities.map(function(elem) {
         elem.draw();
       });
-      drawPlayer(translatePoints(player));
+
+      // player
+      drawCircle(reference, RADIUS, 3, 'white');
+
       meter.draw();
+
       ctx.fillStyle = "white";
       ctx.fillText(points+"", 5, 15);
 
@@ -523,4 +526,4 @@ function SoundSafari(beatInfo, endless) {
   };
 }
 
-SoundSafari.prototype = new Scene();
+SoundSafari.prototype = new Scene();

+ 11 - 0
scripts/util.js

@@ -25,11 +25,22 @@ function drawCircle(point, r, w, color) {
   var ctx = Game.context;
   ctx.beginPath();
   ctx.arc(point.x, point.y, r, 0, 2*Math.PI, false);
+  ctx.closePath();
   ctx.lineWidth = w;
   ctx.strokeStyle = color;
   ctx.stroke();
 }
 
+function drawBG() {
+  var ctx = Game.context;
+  ctx.fillStyle = 'black';
+  ctx.fillRect(0, 0, Game.canvas.width, Game.canvas.height);
+}
+
+function clamp(n, low, high) {
+  return Math.max(Math.min(n, high), low);
+}
+
 function sign(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; }
 
 function lerp(from, to, p) {