Permalink
Browse files

Min max mult to add gradient to gravity wells.

  • Loading branch information...
1 parent cd7cb28 commit 39f3778f4e1bb86fc101bfdcada10a4ced833893 @presstube committed Oct 26, 2011
View
@@ -7,20 +7,40 @@
p.initialize = function(target) {
this.Container_initialize();
- var radius = 100;
+ var maxPerimeter = 300,
+ minPerimeter = 0,
+ multPerimeter = maxPerimeter - minPerimeter,
+ maxForce = 5,
+ minForce = 0,
+ multForce = 1;
- this.addChild(PTUtils.makeCircle('#FFF', radius));
+ this.addChild(PTUtils.makeCircle('#FFF', maxPerimeter));
- this.alpha = 0.5;
+ this.alpha = 0.8
this.tick = function() {
var globalTargetPos = target.localToGlobal(0,0);
var dist = PTUtils.distance(new Point(0, 0), this.globalToLocal(globalTargetPos.x, globalTargetPos.y));
- if (dist < radius) {
+ if (dist < maxPerimeter) {
+
+ // console.log("perimeter: " + maxPerimeter);
+ // console.log("dist: " + dist);
+
+ multPerimeter = (dist - minPerimeter)/(maxPerimeter - minPerimeter);
+ multPerimeter = (multPerimeter>maxPerimeter) ? maxPerimeter : multPerimeter;
+ multPerimeter = (multPerimeter<0) ? 0 : multPerimeter;
+
+ // console.log("multPerimeter: " + multPerimeter);
+
+ // multForce = 1 - multForce;
+
var degrees = PTUtils.angleDegrees(target, this);
- target.addForce(PTUtils.polarDegrees(6, degrees));
+ target.addForce(PTUtils.polarDegrees(maxForce-(maxForce*multPerimeter), degrees/*+180*/)); // degrees+180 for a 'repulsion well'
+
+
+
// if (dist < 20) {
// target.kill(); // GAME OVER
// }
View
@@ -50,7 +50,7 @@
scaleStage: scaleStage,
trackingStage: trackingStage,
wrapRadius: wrapRadius,
- numItems: 50,
+ numItems: 70,
ship: ship
});
@@ -81,7 +81,7 @@
scaleStage.addChild(trackingStage);
scaleStage.addChildAt(parallaxScroller, 0);
- // scaleStage.setScaleMultiplier(1);
+ scaleStage.setScaleMultiplier(.2);
trackingStage.addChild(itemScroller);
trackingStage.addChild(ship);
@@ -33,7 +33,7 @@
var color = (i === 0) ? '#0F0' : '#0FF';
var item = new GravityWell(_p.ship);
// var item = PTUtils.makeCircle(color, 2);
- var spawnPoint = PTUtils.polarDegrees(((Math.random()*(wrapRadius-100)))+100, Math.random() * 360);
+ var spawnPoint = PTUtils.polarDegrees(((Math.random()*(wrapRadius-500)))+500, Math.random() * 360);
item.x = spawnPoint.x;
item.y = spawnPoint.y;
item.i = i;
@@ -42,7 +42,7 @@
}
};
- populate(100);
+ populate(10);
this.tick = function() {
globalScaleStageCenter = scaleStage.localToGlobal(0, 0);
View
@@ -49,7 +49,7 @@
}
function makeDumbProjectile() {
- var dp = PTUtils.makeTriangle('#ff0', 5, 5);
+ var dp = PTUtils.makeTriangle('#000', 5, 5);
var dpForceAbility = new ForceAbility(dp);
dp.tick = function() { dpForceAbility.update(); };
View
@@ -10,7 +10,7 @@
var that = this,
targetScale = 1,
- maxScale = 1,
+ maxScale = .8,
minScale = 0.35,
range = maxScale - minScale,
scaleSpeed = 10;
@@ -35,8 +35,8 @@
};
_p.ship.launcher = launcher;
- this.addChild(PTUtils.makeTriangle('#ccf', 40, 40));
- tail.addChild(PTUtils.makeTriangle('#ccf', 20, 20));
+ this.addChild(PTUtils.makeTriangle('#222', 40, 40));
+ tail.addChild(PTUtils.makeTriangle('#222', 20, 20));
tail.y = -4;
tail.rotation = 180;
this.addChild(tail);

0 comments on commit 39f3778

Please sign in to comment.