Skip to content

Commit

Permalink
Squashed annoying semicolon bug in guns
Browse files Browse the repository at this point in the history
  • Loading branch information
presstube committed Oct 29, 2011
1 parent 7dadf8c commit 3c91b2c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ Hunted

Why?
----
- Because making a crappy game is as fun as playing a good one.
- Because making a crappy game more fun than playing a good one.
- I am a JS noob and want to get my code reviewed by others who know what they are doing.

Dependencies
------------
- Grant Skinner's Easel.js to ease me into JS with some handy AS-like objects and a much needed display list for canvas.
- Underscore.js b/c it is handy, and Backbone.js for its Event system.
- Underscore.js b/c it is mighty handy.
- jQuery hotkeys plugin (slightly modified to fit my purposes) for reliable keyboard input.
2 changes: 1 addition & 1 deletion src/hunted/HuntedApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
projectileThrust: 40,
shotsPerLaunch: 1,
projectileLife: 20,
projectileLimit: 20,
projectileLimit: 200,
targetFunc: nav.getTarget,
trackingStage: trackingStage,
projectiles: projectiles
Expand Down
4 changes: 2 additions & 2 deletions src/hunted/LauncherHeatSeeker.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
steeringLimit: 20,
shipSkin: ShipSkinGoon,
controlsClass: ShipControlsAIChaseDynamic,
targetFunc: _p.targetFunc,
target: _p.ship
targetFunc: _p.targetFunc
// target: _p.ship
});
ship.scaleX = ship.scaleY = 0.2;
return ship;
Expand Down
12 changes: 9 additions & 3 deletions src/hunted/LauncherPeePants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@
p.initialize = function(props) {
this.Container_initialize();

console.log("props ", props);
var that = this,
_p = this.props = props || {},
skin = PTUtils.makeTriangle('#fff', 5, 5);

_p.projectileLimit = _p.projectileLimit || 10;

var spread = 5;
var ammoLifeSpan = 1000;

this.addChild(skin);

this.launch = function() {
_.times(5, fire);
// fire();
};

function fire() {
if (_p.projectiles.length < _p.projectileLimit) {
// that.rotation = 90;
that.rotation = Math.random()*spread - Math.random()*spread;
var projectile = that.makeProjectile();
var launchPos = that.localToLocal(0, 0, _p.ship.parent);
projectile.rotation = _p.ship.rotation + that.rotation;
Expand All @@ -30,10 +35,11 @@
_p.trackingStage.addChildAt(projectile, _p.trackingStage.getChildIndex(_p.ship));
projectile.addForce(_p.ship.getForce());
var adjProjThrust = _p.projectileThrust - (Math.random()*(_p.projectileThrust/4));
projectile.addForce(PTUtils.polarDegrees(adjProjThrust, projectile.rotation));
projectile.addForce(PTUtils.polarDegrees(adjProjThrust, _p.ship.rotation + that.rotation));
skin.y = +5;
_p.projectiles.push(projectile);
_.delay(killProjectile, 500, projectile);
_.delay(killProjectile, ammoLifeSpan, projectile);
// that.rotation = 0;
}

}
Expand Down
24 changes: 9 additions & 15 deletions src/hunted/ShipSkinGeneric.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
tail = new Container(),
exhaustPipe = new ExhaustPipe(props),
launcher = new Launcher(props),
heatSeekerLauncher = new LauncherHeatSeeker(props);
heatSeekerLauncher = new LauncherHeatSeeker(props),
peePants = new LauncherPeePants(props);

// defaults
Expand All @@ -32,13 +32,14 @@
this.addChild(launcher);
launcher.y = -40;

this.addChild(heatSeekerLauncher);
heatSeekerLauncher.y = -40;

this.addChild(peePants);
peePants.y = -40;

this.addChild(heatSeekerLauncher);
heatSeekerLauncher.y = -40;

this.props.ship.launcher = launcher;
// this.props.ship.launcher = launcher;

this.update = function() {
var controls = this.props.ship.controls;
Expand All @@ -59,20 +60,13 @@
exhaustPipe.engage();
}



if (controls.seeker) {
for (var i = 0; i < _p.shotsPerLaunch; i++) {
heatSeekerLauncher.launch();
}
heatSeekerLauncher.launch();
}

// if (controls.peePants) {
// for (var i = 0; i < _p.shotsPerLaunch; i++) {
// console.log("PPPEEE");
// peePants.launch();
// }
// }
if (controls.peePants) {
peePants.launch();
}

if (controls.launch) {
for (var i = 0; i < _p.shotsPerLaunch; i++) {
Expand Down

0 comments on commit 3c91b2c

Please sign in to comment.