Browse files

Pulsar drawing code, largely a stub otherwise.

  • Loading branch information...
1 parent 9684b56 commit 78d7b3b9351f3113d0b1058eba820ce1b7758210 @stephank committed Jul 3, 2010
Showing with 49 additions and 0 deletions.
  1. +1 −0 arashi.html
  2. +48 −0 src/enemies/pulsar.js
View
1 arashi.html
@@ -25,6 +25,7 @@
<script src="src/enemies/plasma.js"></script>
<script src="src/enemies/spiker.js"></script>
<script src="src/enemies/spikes.js"></script>
+<script src="src/enemies/pulsar.js"></script>
<script>
$(document).ready(function () {
View
48 src/enemies/pulsar.js
@@ -0,0 +1,48 @@
+var Pulsar = function(lane) {
+ this.lane = lane;
+ this.depth = C.depth;
+ this.rotation = 0;
+ this.power = 0;
+};
+
+Pulsar.prototype.update = function() {
+ // FIXME: Speed should be a level variable.
+ this.depth -= 2;
+ if (this.depth < 0) { this.depth = 0 };
+
+ // FIXME: Flip and pulse.
+};
+
+Pulsar.prototype.draw = function() {
+ c.save();
+ var ex = Math.cos(this.rotation) / 2;
+ var ey = -Math.sin(this.rotation) / 2;
+ var dx = ex - (this.power * ex) / 32;
+ var dy = ey - (this.power * ex) / 32;
+ var bx = dx / 3;
+ var by = dy / 3;
+ var normx = (-dy*this.power) / 16;
+ var normy = ( dx*this.power) / 16;
+ c.moveTo(ex+dx, ey+dy);
+ c.lineTo(ex+dx-bx+normx, ey+dy-by+normy);
+ c.lineTo(ex+bx-normx, ey+by-normy);
+ c.lineTo(ex+normx, ey+normy);
+ c.lineTo(ex-bx-normx, ey-by-normy);
+ c.lineTo(ex-dx+bx+normx, ey-dy+by+normy);
+ c.lineTo(ex-dx, ey-dy);
+ c.restore();
+};
+
+Pulsar.prototype.paint = function() {
+ c.save();
+ grid.laneTranslation(this.lane, this.depth);
+
+ c.lineWidth = 0.02;
+ // FIXME
+ c.strokeStyle = 'yellow';
+
+ c.beginPath();
+ this.draw();
+ c.stroke();
+ c.restore();
+};

0 comments on commit 78d7b3b

Please sign in to comment.