Permalink
Browse files

Some basic spike code.

  • Loading branch information...
1 parent c36f1a0 commit bdcce6fd67a261bbabee483d95cd46cf2712344b @stephank committed Jun 14, 2010
Showing with 60 additions and 0 deletions.
  1. +2 −0 arashi.html
  2. +54 −0 src/enemies/spikes.js
  3. +2 −0 src/gamestates/game.js
  4. +2 −0 testing.template.html
View
@@ -22,6 +22,8 @@
<script src="src/vakit/lightning.js"></script>
<script src="src/gamestates/title.js"></script>
<script src="src/gamestates/game.js"></script>
+<script src="src/enemies/plasma.js"></script>
+<script src="src/enemies/spikes.js"></script>
<script>
$(document).ready(function () {
View
@@ -0,0 +1,54 @@
+var Spike = function(lane, top) {
+ this.lane = lane;
+ if (top) {
+ this.top = top;
+ }
+ else {
+ this.top = C.depth;
+ }
+};
+
+Spike.prototype.draw = function() {
+ c.save();
+ grid.laneTranslation(this.lane, this.top);
+ c.moveTo(0, 0);
+ c.restore();
+
+ c.save();
+ grid.laneTranslation(this.lane, C.depth);
+ c.lineTo(0, 0);
+ c.restore();
+};
+
+Spike.prototype.paint = function() {
+ c.lineWidth = 0.01;
+ // FIXME
+ c.strokeStyle = 'white';
+
+ c.beginPath();
+ this.draw();
+ c.stroke();
+};
+
+
+var spikes = [];
+
+spikes.init = function() {
+ // Truncate array.
+ spikes.length = 0;
+
+ // Create new spikes for each lane.
+ var i;
+ spikes[grid.numLanes - 1] = null; // Initialize array size.
+ for (i = 0; i < grid.numLanes; i++) {
+ // FIXME: Spike starting depth should be a level variable.
+ spikes[i] = new Spike(i, 80);
+ }
+};
+
+spikes.paint = function() {
+ var i;
+ for (i = 0; i < grid.numLanes; i++) {
+ spikes[i].paint();
+ }
+};
View
@@ -4,6 +4,7 @@ GameMachine = {
enter_start: function() {
grid = Grids.Circle16;
Starfield.color = grid.color = [0,0,255];
+ spikes.init();
Engine.transition('flyInStars');
},
@@ -32,6 +33,7 @@ GameMachine = {
c.save();
grid.screenTranslation();
grid.paint();
+ spikes.paint();
c.restore();
},
View
@@ -43,6 +43,8 @@
<script src="src/vakit/lightning.js"></script>
<script src="src/gamestates/title.js"></script>
<script src="src/gamestates/game.js"></script>
+<script src="src/enemies/plasma.js"></script>
+<script src="src/enemies/spikes.js"></script>
<!-- Bootstrap code -->
<script>

0 comments on commit bdcce6f

Please sign in to comment.