Permalink
Browse files

Adding Venn and Bee

Making chasers a bit slower.

Roughing in venn detection.

Futzing around with changing skins.

Futzing around with changing skins.

Rigged early skin transforms on Venn trigger.

Changing skin of player to Bee when venn activated.
  • Loading branch information...
1 parent e363282 commit 6f420c755d8530cc1ba13ace28b4de6f391ef583 @presstube committed Nov 2, 2011
View
@@ -35,8 +35,9 @@
<script src="src/hunted/ScaleStage.js"></script>
<script src="src/hunted/TrackingStage.js"></script>
<script src="src/hunted/ParallaxScroller.js"></script>
- <script src="src/hunted/GravityWellRepelBubble.js"></script>
+ <script src="src/hunted/Bubble.js"></script>
<script src="src/hunted/Boost.js"></script>
+ <script src="src/hunted/Boom.js"></script>
<script src="src/hunted/ItemScroller.js"></script>
<script src="src/hunted/ShipControlsKeyboard.js"></script>
<script src="src/hunted/ExhaustPipe.js"></script>
@@ -46,6 +47,7 @@
<script src="src/hunted/ForceAbility.js"></script>
<script src="src/hunted/ShipSkinGeneric.js"></script>
<script src="src/hunted/ShipSkinGoon.js"></script>
+ <script src="src/hunted/ShipSkinBee.js"></script>
<script src="src/hunted/ShipControlsAIWander.js"></script>
<script src="src/hunted/ShipControlsAIChase.js"></script>
<script src="src/hunted/ShipControlsAIChaseDynamic.js"></script>
@@ -54,6 +56,7 @@
<script src="src/hunted/LauncherHeatSeeker.js"></script>
<script src="src/hunted/LauncherPeePants.js"></script>
<script src="src/hunted/PTUtils.js"></script>
+ <script src="src/hunted/Venn.js"></script>
</head>
View
@@ -0,0 +1,9 @@
+(function(window){
+
+ var Boom = function() {
+
+ };
+
+ window.Boom = Boom;
+
+}(window));
View
@@ -15,22 +15,25 @@
p.initialize = function(props) {
+ this.Container_initialize();
+
var _p = props;
_p.boostThrust = _p.boostThrust || 5;
_p.boostFuelLimit = _p.boostFuelLimit || 20;
_p.boostRegenerateFrequency = _p.boostRegenerateFrequency || 5;
- var boostFuel = _p.boostFuelLimit,
+ var boost = this,
+ boostFuel = _p.boostFuelLimit,
width = 20,
- skin = PTUtils.makeTriangle("fff", width, width),
+ skin,
ship = _p.ship,
controls = ship.controls,
tickCount = 0,
- force = new Point();
+ force = new Point(),
+ name = Math.random();
- skin.y = -10;
- this.addChild(skin);
+ setSkin(PTUtils.makeTriangle("fff", width, width));
this.tick = function() {
if(controls.boost && boostFuel > 0) {
@@ -43,7 +46,8 @@
// app.stage.y += Math.random()*shudder*mult - Math.random()*shudder*mult;
app.stage.x += Math.random()*shudder - Math.random()*shudder;
app.stage.y += Math.random()*shudder - Math.random()*shudder;
- var boostChunk = PTUtils.makeTriangle('#fff', width*mult, width*mult);
+ var boostChunk = skin.clone();
+ // var boostChunk = PTUtils.makeTriangle('#fff', width*mult, width*mult);
boostChunk.x = ship.x;
boostChunk.y = ship.y;
boostChunk.rotation = ship.rotation;
@@ -57,13 +61,24 @@
}
}
tickCount++;
-
- skin.scaleX = skin.scaleY = (boostFuel / _p.boostFuelLimit);
+ // skin.scaleX =
+ skin.scaleY = (boostFuel / _p.boostFuelLimit);
};
this.setBoostFuel = function(fuel) {
boostFuel = fuel;
};
+
+ function setSkin(newSkin) {
+ if(skin) boost.removeChild(skin);
+ boost.addChild(skin = newSkin);
+ }
+
+ this.setSkin = setSkin;
+
+ this.kill = function() {
+
+ };
};
@@ -6,15 +6,21 @@
}
*/
- var GravityWellRepelBubble = function(props) {this.initialize(props);};
- var p = GravityWellRepelBubble.prototype = new Container();
+ var Bubble = function(props) {this.initialize(props);};
+ var p = Bubble.prototype = new Container();
p.Container_initialize = p.initialize;
p.initialize = function(props) {
this.Container_initialize();
+ var _p = this.props = props;
+
+ Bubble.VACATED = "VACATED";
+ Bubble.OCCUPIED = "OCCUPIED";
+
var gravityWell = this,
app = props.app,
+ state = Bubble.VACATED,
maxPushPerimeter = 300,
minPushPerimeter = 150,
multPushPerimeter = maxPushPerimeter - minPushPerimeter,
@@ -29,13 +35,34 @@
playerDist = 0;
- this.addChild(PTUtils.makeCircle('#FFF', maxPushPerimeter));
+ _.extend(this, Backbone.Events);
+
+ // this.bind(Bubble.VACATED, function(msg) { console.log("VACATED: " + msg); });
+ // this.bind(Bubble.OCCUPIED, function(msg) { console.log("OCCUPIED: " + msg); });
+
+ var outer = PTUtils.makeCircle('#FFF', maxPushPerimeter);
+ outer.alpha = 0.2;
+
+ this.addChild(outer);
this.addChild(PTUtils.makeCircle('#FFF', minPushPerimeter));
- this.alpha = 0.2;
+ this.alpha = 0.1;
// there is some ugliness here that needs to be sorted, perhaps a register/unregisterTarget(target)
+ function setState(newState) {
+
+ state = newState;
+
+ if (state === Bubble.VACATED) {
+ gravityWell.trigger(Bubble.VACATED, gravityWell);
+
+ } else if (state === Bubble.OCCUPIED) {
+ gravityWell.trigger(Bubble.OCCUPIED, gravityWell);
+
+ }
+ }
+
this.tick = function() {
var globalTargetPos = app.player.localToGlobal(0,0);
playerDist = PTUtils.distance(new Point(0, 0), gravityWell.globalToLocal(globalTargetPos.x, globalTargetPos.y));
@@ -62,6 +89,7 @@
}
if (dist < maxPullPerimeter) {
+ if (state === Bubble.VACATED && target === app.player) { setState(Bubble.OCCUPIED); }
multPullPerimeter = (dist - minPullPerimeter)/(maxPullPerimeter - minPullPerimeter);
multPullPerimeter = (multPullPerimeter>maxPullPerimeter) ? maxPullPerimeter : multPullPerimeter;
multPullPerimeter = (multPullPerimeter<0) ? 0 : multPullPerimeter;
@@ -70,6 +98,7 @@
target.addForce(PTUtils.polarDegrees(force, degrees));
} else if (dist < maxPushPerimeter) {
+ if (state === Bubble.OCCUPIED && target === app.player) { setState(Bubble.VACATED); }
multPushPerimeter = (dist - minPushPerimeter)/(maxPushPerimeter - minPushPerimeter);
multPushPerimeter = (multPushPerimeter>maxPushPerimeter) ? maxPushPerimeter : multPushPerimeter;
multPushPerimeter = (multPushPerimeter<0) ? 0 : multPushPerimeter;
@@ -80,6 +109,11 @@
}
};
- window.GravityWellRepelBubble = GravityWellRepelBubble;
+ Bubble.prototype.toString = function() {
+ return "[Bubble]";
+ };
+
+
+ window.Bubble = Bubble;
}(window));
View
@@ -9,9 +9,10 @@
scaleStage = new ScaleStage(),
trackingStage = new TrackingStage(),
nav = new Nav(scaleStage),
+ venn = new Venn({app: app}),
drag = 0.95,
wrapRadius = 3000,
- boostFuelLimit = 40, // shouldnt be here
+ boostFuelLimit = 20, // shouldnt be here
chasers = [],
projectiles = [],
@@ -27,18 +28,20 @@
numItems: 50
}),
+
player = new Ship({
app: app,
- name: "hero",
+ name: "player",
controlsClass: ShipControlsKeyboard,
+ // skinClass: ShipSkinBee,
skinClass: ShipSkinGeneric,
engineClass: ShipEngineGeneric,
// for the engine
thrustLimit: 2,
// for the booster
- boostThrust: 5,
+ boostThrust: 3,
boostFuelLimit: boostFuelLimit,
boostRegenerateFrequency: 4,
@@ -63,6 +66,9 @@
wrapRadius: wrapRadius
});
+
+
+
stage.addChild(fpsLabel, levelText, scaleStage);
levelText.x = 10; levelText.y = 40;
@@ -91,6 +97,8 @@
rigPauseKey();
resize();
+ venn.addGroup(itemScroller.getItems());
+
start();
@@ -136,9 +144,10 @@
}
numChasersToSpawn = 1; // would kick you back to level 1
if (numChasersToSpawn > 1) numChasersToSpawn--;
+ player.setSkin(new ShipSkinGeneric(player.props));
trackingStage.addChild(player);
spawnChasers();
- player.skin.boost.setBoostFuel(boostFuelLimit);
+ // player.skin.boost.setBoostFuel(boostFuelLimit);
}
function gameOver() {
@@ -34,7 +34,7 @@
var item,
spawnPoint = PTUtils.polarDegrees(((Math.random()*(wrapRadius-500)))+500, Math.random() * 360);
- item = new GravityWellRepelBubble({app: app});
+ item = new Bubble({app: app, name: Math.random()});
item.x = spawnPoint.x;
item.y = spawnPoint.y;
items.push(item);
@@ -63,6 +63,10 @@
}
}
};
+
+ this.getItems = function() {
+ return items;
+ };
};
window.ItemScroller = ItemScroller;
View
@@ -20,6 +20,13 @@
drawCircle(0, 0, radius);
return triangle;
};
+
+ PTUtils.makeRect = function(color, x, y, w, h) {
+ var rect = new Shape();
+ rect.graphics.beginFill(color).
+ drawRect(x, y, w, h);
+ return rect;
+ };
PTUtils.populateBits = function(container, numBits) {
View
@@ -77,14 +77,22 @@
};
p.makeSkin = function() {
- if ( this.props.skinClass){
- this.skin = new this.props.skinClass(this.props);
+ if (this.props.skinClass){
+ this.setSkin(new this.props.skinClass(this.props));
+ // this.skin = new this.props.skinClass(this.props);
} else {
- this.skin = new ShipSkinGeneric(this.props);
+ this.setSkin(new ShipSkinGeneric(this.props));
+ // this.skin = new ShipSkinGeneric(this.props);
}
this.addChild(this.skin);
};
+ p.setSkin = function(newSkin) {
+ if (this.skin) this.skin.kill();
+ this.skin = newSkin;
+ this.addChild(newSkin);
+ };
+
p.kill = function() {
this.parent.removeChild(this);
};
Oops, something went wrong.

0 comments on commit 6f420c7

Please sign in to comment.