Skip to content
Browse files

Breaking out boost and giving it a crude graphic representation.

  • Loading branch information...
1 parent 3c91b2c commit 66bf6723add2562647e4db1c8e8dcb8cce974daf @presstube committed
View
1 index.html
@@ -40,6 +40,7 @@
<script src="src/hunted/GravityWellBubble.js"></script>
<script src="src/hunted/GravityWellRepel.js"></script>
<script src="src/hunted/GravityWellRepelBubble.js"></script>
+ <script src="src/hunted/Boost.js"></script>
<script src="src/hunted/ItemScroller.js"></script>
<script src="src/hunted/ShipControlsKeyboard.js"></script>
<script src="src/hunted/ExhaustPipe.js"></script>
View
51 src/hunted/Boost.js
@@ -0,0 +1,51 @@
+(function(window){
+
+ var Boost = function(props) {this.initialize(props);};
+ var p = Boost.prototype = new Container();
+ p.Container_initialize = p.initialize;
+
+ p.initialize = function(props) {
+
+ var _p = props;
+
+ _p.boostThrust = _p.boostThrust || 5;
+ _p.boostFuelLimit = _p.boostFuelLimit || 20;
+ _p.boostRegenerateFrequency = _p.boostRegenerateFrequency || 5;
+
+ var boostFuel = _p.boostFuelLimit,
+ skin = PTUtils.makeTriangle("777", 20, 20),
+ ship = _p.ship,
+ controls = ship.controls,
+ tickCount = 0,
+ force = new Point();
+
+ // skin.rotation = 180;
+ skin.y = -10;
+ this.addChild(skin);
+
+ this.tick = function() {
+ if(controls.boost && boostFuel > 0) {
+ force = PTUtils.polarDegrees(_p.boostThrust, ship.rotation);
+ ship.addForce(force);
+ boostFuel--;
+ } else {
+ if (boostFuel < _p.boostFuelLimit && tickCount % _p.boostRegenerateFrequency === 0) {
+ boostFuel++;
+ }
+ }
+ tickCount++;
+
+ skin.scaleX = skin.scaleY = (boostFuel / _p.boostFuelLimit);
+
+ // console.log('boost mult: ' + (boostFuel / _p.boostFuelLimit));
+ };
+
+ this.setBoostFuel = function(fuel) {
+ boostFuel = fuel;
+ };
+
+ };
+
+ window.Boost = Boost;
+
+}(window));
View
6 src/hunted/HuntedApp.js
@@ -16,6 +16,7 @@
trackingStage = new TrackingStage(),
nav = new Nav(scaleStage),
levelText = new Text("-- fps","bold 20px Arial","#FFF"),
+ fuelLimit = 20,
parallaxScroller = new ParallaxScroller({
app: this,
@@ -32,7 +33,7 @@
drag: 0.95,
thrustLimit: 2,
boostThrust: 4,
- boostFuelLimit: 30,
+ boostFuelLimit: fuelLimit,
boostRegenerateFrequency: 10,
steeringResponse: 2,
steeringLimit: 10,
@@ -134,8 +135,6 @@
while (chasers.length > 0) {
chasers.pop().kill();
}
-
- console.log("prioj: "+projectiles );
while (projectiles.length > 0) {
projectiles.pop().kill();
}
@@ -143,6 +142,7 @@
if (numChasersToSpawn > 1) numChasersToSpawn--;
trackingStage.addChild(ship);
spawnChasers();
+ ship.skin.boost.setBoostFuel(fuelLimit);
}
function gameOver() {
View
3 src/hunted/Launcher.js
@@ -15,7 +15,6 @@
this.addChild(skin);
this.launch = function() {
- console.log("PPPPP: " , _p);
if (_p.projectiles.length < _p.projectileLimit) {
var projectile = this.makeProjectile();
var launchPos = this.localToLocal(0, 0, _p.ship.parent);
@@ -50,7 +49,7 @@
}
function makeDumbProjectile() {
- var dp = PTUtils.makeTriangle('#000', 5, 5);
+ var dp = PTUtils.makeTriangle('#ff0', 5, 5);
var dpForceAbility = new ForceAbility(dp);
dp.tick = function() { dpForceAbility.update(); };
View
3 src/hunted/LauncherPeePants.js
@@ -72,7 +72,8 @@
// return makeShipProjectile();
return makeDumbProjectile();
- };
+ }
+
this.makeProjectile = makeProjectile;
function killProjectile(projectile) {
View
42 src/hunted/ShipControlsKeyboard.js
@@ -4,8 +4,10 @@
var that = this;
- var upHeld, downHeld, leftHeld, rightHeld, spaceHeld, shiftHeld, sHeld, wHeld;
- upHeld = downHeld = leftHeld = rightHeld = spaceHeld = shiftHeld = sHeld = wHeld = false;
+ var upHeld, downHeld, leftHeld, rightHeld,
+ spaceHeld, shiftHeld;
+
+ upHeld = downHeld = leftHeld = rightHeld = spaceHeld = shiftHeld = false;
this.throttle = 0;
this.steering = 0;
@@ -21,19 +23,31 @@
$(document).bind('keydown', 'right',function (){ rightHeld = true; });
$(document).bind('keydown', 'up',function (){ upHeld = true; });
$(document).bind('keydown', 'down',function (){ downHeld = true; });
+
+ $(document).bind('keydown', 'a',function (){ leftHeld = true; });
+ $(document).bind('keydown', 'd',function (){ rightHeld = true; });
+ $(document).bind('keydown', 'w',function (){ upHeld = true; });
+ $(document).bind('keydown', 's',function (){ downHeld = true; });
+
$(document).bind('keydown', 'space',function (){ spaceHeld = true; });
$(document).bind('keydown', 'shift',function (){ shiftHeld = true; });
- $(document).bind('keydown', 's',function (){ sHeld = true; });
- $(document).bind('keydown', 'w',function (){ wHeld = true; });
+ // $(document).bind('keydown', 's',function (){ sHeld = true; });
+ // $(document).bind('keydown', 'w',function (){ wHeld = true; });
$(document).bind('keyup', 'left',function (){ leftHeld = false; });
$(document).bind('keyup', 'right',function (){ rightHeld = false; });
$(document).bind('keyup', 'up',function (){ upHeld = false; });
$(document).bind('keyup', 'down',function (){ downHeld = false; });
+
+ $(document).bind('keyup', 'a',function (){ leftHeld = false; });
+ $(document).bind('keyup', 'd',function (){ rightHeld = false; });
+ $(document).bind('keyup', 'w',function (){ upHeld = false; });
+ $(document).bind('keyup', 's',function (){ downHeld = false; });
+
$(document).bind('keyup', 'space',function (){ spaceHeld = false; });
$(document).bind('keyup', 'shift',function (){ shiftHeld = false; });
- $(document).bind('keyup', 's',function (){ sHeld = false; });
- $(document).bind('keyup', 'w',function (){ wHeld = false; });
+ // $(document).bind('keyup', 's',function (){ sHeld = false; });
+ // $(document).bind('keyup', 'w',function (){ wHeld = false; });
}
this.update = function () {
@@ -42,8 +56,8 @@
setSteering();
setBoost();
setFire();
- setSeeker();
- setPeePants();
+ // setSeeker();
+ // setPeePants();
function setThrottle() {
if (upHeld && !downHeld) {
@@ -73,13 +87,13 @@
that.launch = spaceHeld ? true : false;
}
- function setSeeker() {
- that.seeker = sHeld ? true : false;
- }
+ // function setSeeker() {
+ // that.seeker = sHeld ? true : false;
+ // }
- function setPeePants() {
- that.peePants = wHeld ? true : false;
- }
+ // function setPeePants() {
+ // that.peePants = wHeld ? true : false;
+ // }
};
};
View
21 src/hunted/ShipEngineGeneric.js
@@ -7,14 +7,9 @@
_p.steeringLimit = _p.steeringLimit || 7;
_p.steeringResponse = _p.steeringResponse || 2;
_p.thrustLimit = _p.thrustLimit || 1;
- _p.boostThrust = _p.boostThrust || 5;
- _p.boostFuelLimit = _p.boostFuelLimit || 20;
- _p.boostRegenerateFrequency = _p.boostRegenerateFrequency || 5;
- var boostFuel = _p.boostFuelLimit,
- torque = 0,
- thrust = 0,
- tickCount = 0;
+ var torque = 0,
+ thrust = 0;
this.update = function() {
@@ -28,19 +23,7 @@
thrust = controls.throttle * _p.thrustLimit;
force = PTUtils.polarDegrees(thrust, ship.rotation);
ship.addForce(force);
- if(controls.boost && boostFuel > 0) {
- force = PTUtils.polarDegrees(_p.boostThrust, ship.rotation);
- ship.addForce(force);
- boostFuel--;
- } else {
- if (boostFuel < _p.boostFuelLimit && tickCount % _p.boostRegenerateFrequency === 0) {
- boostFuel++;
- }
- }
- tickCount++;
-
};
-
};
window.ShipEngineGeneric = ShipEngineGeneric;
View
7 src/hunted/ShipSkinGeneric.js
@@ -13,6 +13,7 @@
tailSwingRange = 20,
tail = new Container(),
exhaustPipe = new ExhaustPipe(props),
+ boost = new Boost(props),
launcher = new Launcher(props),
heatSeekerLauncher = new LauncherHeatSeeker(props),
peePants = new LauncherPeePants(props);
@@ -22,6 +23,8 @@
_p.shotsPerLaunch = _p.shotsPerLaunch || 3;
this.addChild(PTUtils.makeTriangle('#222', 40, 40));
+
+
tail.addChild(PTUtils.makeTriangle('#222', 20, 20));
tail.y = -4;
tail.rotation = 180;
@@ -38,6 +41,8 @@
this.addChild(peePants);
peePants.y = -40;
+ boost.y = 5;
+ this.addChild(boost);
// this.props.ship.launcher = launcher;
@@ -77,6 +82,8 @@
launcher.rotation = 0;
}
};
+
+ this.boost = boost;
};
window.ShipSkinGeneric = ShipSkinGeneric;

0 comments on commit 66bf672

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