Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Pulsar drawing code, largely a stub otherwise.

  • Loading branch information...
commit 78d7b3b9351f3113d0b1058eba820ce1b7758210 1 parent 9684b56
Stéphan Kochen authored July 03, 2010
1  arashi.html
@@ -25,6 +25,7 @@
25 25
 <script src="src/enemies/plasma.js"></script>
26 26
 <script src="src/enemies/spiker.js"></script>
27 27
 <script src="src/enemies/spikes.js"></script>
  28
+<script src="src/enemies/pulsar.js"></script>
28 29
 
29 30
 <script>
30 31
 $(document).ready(function () {
48  src/enemies/pulsar.js
... ...
@@ -0,0 +1,48 @@
  1
+var Pulsar = function(lane) {
  2
+  this.lane = lane;
  3
+  this.depth = C.depth;
  4
+  this.rotation = 0;
  5
+  this.power = 0;
  6
+};
  7
+
  8
+Pulsar.prototype.update = function() {
  9
+  // FIXME: Speed should be a level variable.
  10
+  this.depth -= 2;
  11
+  if (this.depth < 0) { this.depth = 0 };
  12
+
  13
+  // FIXME: Flip and pulse.
  14
+};
  15
+
  16
+Pulsar.prototype.draw = function() {
  17
+  c.save();
  18
+    var ex = Math.cos(this.rotation) / 2;
  19
+    var ey = -Math.sin(this.rotation) / 2;
  20
+    var dx = ex - (this.power * ex) / 32;
  21
+    var dy = ey - (this.power * ex) / 32;
  22
+    var bx = dx / 3;
  23
+    var by = dy / 3;
  24
+    var normx = (-dy*this.power) / 16;
  25
+    var normy = ( dx*this.power) / 16;
  26
+    c.moveTo(ex+dx,           ey+dy);
  27
+    c.lineTo(ex+dx-bx+normx,  ey+dy-by+normy);
  28
+    c.lineTo(ex+bx-normx,     ey+by-normy);
  29
+    c.lineTo(ex+normx,        ey+normy);
  30
+    c.lineTo(ex-bx-normx,     ey-by-normy);
  31
+    c.lineTo(ex-dx+bx+normx,  ey-dy+by+normy);
  32
+    c.lineTo(ex-dx,           ey-dy);
  33
+  c.restore();
  34
+};
  35
+
  36
+Pulsar.prototype.paint = function() {
  37
+  c.save();
  38
+    grid.laneTranslation(this.lane, this.depth);
  39
+
  40
+    c.lineWidth = 0.02;
  41
+    // FIXME
  42
+    c.strokeStyle = 'yellow';
  43
+
  44
+    c.beginPath();
  45
+      this.draw();
  46
+    c.stroke();
  47
+  c.restore();
  48
+};

0 notes on commit 78d7b3b

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