Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Arcade mode features

  • Loading branch information...
commit bcea5fcd5b6bfa383928e42318e2cd4923272825 1 parent 537b0be
@rogerbraun rogerbraun authored
View
78 Arcade.as
@@ -12,6 +12,8 @@ package {
super();
_levelWidth = 990;
_levelHeight = 900;
+ _startPosition.x = 20;
+ _startPosition.y = 20;
}
override public function create():void {
@@ -31,6 +33,12 @@ package {
_timeLeft = 3 * 60;
_spawnRotten = true;
+
+ // Spawn 6 food (adds to spawnFoods in LevelState).
+ spawnFoods(3);
+
+ // Visible obstacles for debugging
+ // add(_obstacles);
}
override public function update():void {
@@ -46,12 +54,82 @@ package {
}
override protected function addObstacles():void {
+ var obstacle:AxSprite;
+ obstacle = new AxSprite(0, 0);
+ obstacle.create(165, _levelHeight, 0x9900ff00);
+ _obstacles.add(obstacle);
+
+ obstacle = new AxSprite(840, 0);
+ obstacle.create(_levelWidth - 840, _levelHeight, 0x9900ff00);
+ _obstacles.add(obstacle);
+
+ var down:Array = [
+ [165, 615, 30],
+ [195, 630, 15],
+ [210, 645, 45],
+ [255, 660, 15],
+ [270, 675, 45],
+ [315, 690, 15],
+ [330, 750, 90],
+ [420, 765, 15],
+ [435, 780, 15],
+ [450, 795, 15 * 7],
+ [555, 780, 15 * 2],
+ [585, 765, 15 * 2],
+ [615, 750, 15 * 2],
+ [645, 735, 15 * 11],
+ [810, 525, 15 * 1],
+ [825, 510, 15 * 1]
+
+ ];
+
+ for each(var el:Array in down) {
+ obstacle = new AxSprite(el[0], el[1]);
+ obstacle.create(el[2], _levelHeight - obstacle.y, 0x9900ff00);
+ _obstacles.add(obstacle);
+ }
+
+ var up:Array = [
+ [165, 570, 15],
+ [180, 555, 15],
+ [195, 330, 15],
+ [210, 300, 15],
+ [225, 285, 15],
+ [240, 210, 15 * 8],
+ [360, 195, 15 * 10],
+ [510, 180, 15 * 9],
+ [645, 150, 4 * 15],
+ [705, 180, 7 * 15],
+ [810, 420, 2 * 15]
+
+ ];
+
+ for each(var el:Array in up) {
+ obstacle = new AxSprite(el[0], 0);
+ obstacle.create(el[2], el[1], 0x9900ff00);
+ _obstacles.add(obstacle);
+ }
+
+ var special:Array = [
+ [780, 540, 2 * 15, 8 * 15],
+ [750, 255, 4 * 15, 9 * 15],
+ [765, 240, 15, 15],
+ [780, 225, 15 * 2, 15 * 2]
+ ];
+
+ for each(var el:Array in special) {
+ obstacle = new AxSprite(el[0], el[1]);
+ obstacle.create(el[2], el[3], 0x9900ff00);
+ _obstacles.add(obstacle);
+ }
+
}
override protected function addHud():void {
_hud = new Hud(["lives", "time", "score"]);
add(_hud);
}
+
override protected function updateHud():void {
_hud.livesText = String(_snake.lives);
_hud.timeText = String(_timeLeft.toFixed(1));
View
2  GoldenCombo.as
@@ -2,7 +2,7 @@ package {
public class GoldenCombo extends Combo {
public function GoldenCombo() {
super();
- repeat = true;
+ repeat = false;
trigger = [EggTypes.EGGB, EggTypes.EGGA, EggTypes.EGGC, EggTypes.EGGA, EggTypes.EGGC];
}
View
25 LevelState.as
@@ -1,5 +1,6 @@
package {
import org.axgl.*;
+ import org.axgl.collision.AxGrid;
import org.axgl.text.*;
import org.axgl.particle.*;
import org.axgl.render.*;
@@ -68,14 +69,21 @@ package {
protected var _spawnRotten:Boolean = false;
protected var _rottenEggs:AxGroup;
- protected var _rottenFrequency:Number = 2;
- protected var _rottenSpawnTimer:Number = 2;
-
+ protected var _rottenFrequency:Number = 10;
+ protected var _rottenSpawnTimer:Number = 10;
+
+ protected var _startPosition:AxPoint;
+
+ public function LevelState() {
+ super();
+ _startPosition = new AxPoint(10, 10);
+ }
+
override public function create():void {
super.create();
Ax.zoom = 1.5;
-
+
_tweens = new Vector.<GTween>;
_comboSet = new ComboSet();
@@ -101,7 +109,7 @@ package {
_particles.add(AxParticleSystem.register(effect));
_score = 0;
- _snake = new Snake(10);
+ _snake = new Snake(10, _startPosition);
Ax.camera.follow(_snake.followBox);
Ax.camera.bounds = new AxRect(0,0,_levelWidth,_levelHeight);
_food = new AxGroup();
@@ -276,7 +284,10 @@ package {
}
protected function collideObstacles():void {
- if(_snake.alive && Ax.overlap(_snake.head, _obstacles)) {
+ var spr:AxSprite = new AxSprite(_snake.head.tileX * 15, _snake.head.tileY * 15);
+ spr.width = 15;
+ spr.height = 15;
+ if (_snake.alive && Ax.overlap(spr, _obstacles, null, new AxGrid(_levelWidth, _levelHeight))) {
_snake.die();
}
}
@@ -581,7 +592,7 @@ package {
do {
egg.tileX = int(1 + (Math.random() * wTiles));
egg.tileY = int(6 + (Math.random() * hTiles));
- } while (Ax.overlap(egg, _unspawnable));
+ } while (Ax.overlap(egg, _unspawnable, null, new AxGrid(_levelWidth, _levelHeight)));
if (rotten) {
_rottenEggs.add(egg);
} else {
View
10 Snake.as
@@ -27,11 +27,15 @@ package {
private var _startMps:Number;
private var _emoLevel:int;
+
+ private var _startPosition:AxPoint;
- public function Snake(movesPerSecond:Number = 1) {
+ public function Snake(movesPerSecond:Number = 1, startPosition:AxPoint = null) {
super();
_startMps = movesPerSecond;
_timer = 0;
+
+ _startPosition = startPosition;
_head = new SmoothBlock(2, 2);
@@ -164,8 +168,8 @@ package {
}
private function resurrect():void {
- _head.tileX = 9;
- _head.tileY = 10;
+ _head.tileX = _startPosition.x;
+ _head.tileY = _startPosition.y;
_head.offset.x = 15;
_head.offset.y = 30;
_previousFacing = _head.facing;
View
4 tests/ComboTests.as
@@ -24,7 +24,7 @@ package tests {
new MockEgg(EggTypes.EGGA),
new MockEgg(EggTypes.EGGA)]
- var combo:Combo = new Combo();
+ var combo:Combo = new FasterCombo();
var comboSet:ComboSet = new ComboSet();
comboSet.addCombo(combo);
@@ -51,7 +51,7 @@ package tests {
var overlappingCombos = [new MockEgg(EggTypes.EGGC), new MockEgg(EggTypes.EGGB), new MockEgg(EggTypes.EGGC), new MockEgg(EggTypes.EGGB), new MockEgg(EggTypes.EGGA),new MockEgg(EggTypes.EGGA), new MockEgg(EggTypes.EGGA)];
var combo:Combo = new ShuffleCombo();
- var aaacombo:Combo = new Combo();
+ var aaacombo:Combo = new FasterCombo();
var comboSet:ComboSet = new ComboSet();
comboSet.addCombo(combo);
comboSet.addCombo(aaacombo);
Please sign in to comment.
Something went wrong with that request. Please try again.