Skip to content

Commit 1dc904d

Browse files
committed
grapple visualization
1 parent 6be8fe1 commit 1dc904d

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

src/Main.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ package
129129
FP.console.visible = false;
130130

131131
// player vars
132-
FP.console.watch("hSpeed", "vSpeed", "momentum", "radius", "canGrapple", "onGround", "active", "timeLeft", "coinsLeft", "endY", "startY", "counter", "thrust", "health");
132+
FP.console.watch("hSpeed", "vSpeed", "momentum", "radius", "canGrapple", "onGround", "active", "timeLeft", "coinsLeft", "endY", "startY", "counter", "thrust", "health", "grappleHSpeed", "grappleVSpeed");
133133
}
134134

135135
public static function submitFacebook() : void

src/game/Player.as

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ package game
131131
private var varJump:uint = 0;
132132

133133
private const C_FLIP:uint = 65535;
134+
135+
public var grappleHSpeed:Number = 0;
136+
public var grappleVSpeed:Number = 0;
134137

135138
public function Player(level:Level, x:int, y:int)
136139
{
@@ -193,6 +196,8 @@ package game
193196
this.hSpeed = FP.point2.x - FP.point.x;
194197
this.vSpeed = FP.point2.y - FP.point.y;
195198
this.momentum = 0;
199+
this.grappleHSpeed = 0;
200+
this.grappleVSpeed = 0;
196201
}
197202

198203
public function startWarp() : void
@@ -527,6 +532,12 @@ package game
527532
this.momentum = 0;
528533
}
529534
}
535+
536+
// cache expected h/v-speed on release for variable watch & display
537+
FP.angleXY(FP.point,FP.angle(this.grapple.x,this.grapple.y,x,y),this.radius);
538+
FP.angleXY(FP.point2,FP.angle(this.grapple.x,this.grapple.y,x,y) + this.momentum,this.radius);
539+
this.grappleHSpeed = FP.point2.x - FP.point.x;
540+
this.grappleVSpeed = FP.point2.y - FP.point.y;
530541
distance = FP.distance(x,y,this.grapple.x,this.grapple.y);
531542
if(distance > this.BREAK_RADIUS)
532543
{

src/net/flashpunk/debug/Console.as

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package net.flashpunk.debug
1616
import net.flashpunk.utils.Input;
1717
import net.flashpunk.utils.Key;
1818
import game.tas.TASUtility;
19+
import game.Player;
1920

2021
/**
2122
* FlashPunk debug console; can use to log information or pause the game and view/move Entities and step the frame.
@@ -618,6 +619,28 @@ package net.flashpunk.debug
618619
g.lineStyle(1, 0xFFFFFF);
619620
g.drawRect((e.x - FP.camera.x) * sx - 3, (e.y - FP.camera.y) * sy - 3, 6, 6);
620621
}
622+
623+
if (e is Player)
624+
{
625+
var p:Player = e as Player;
626+
var h:Number = p.hSpeed;
627+
var v:Number = p.vSpeed;
628+
629+
// calculate from what the h/v speed would be if you released grapple, if grappled
630+
if (p.grapple != null && p.grapple.latched != null)
631+
{
632+
h = p.grappleHSpeed;
633+
v = p.grappleVSpeed;
634+
}
635+
636+
// h-speed
637+
g.lineStyle(1, 0xFF0000);
638+
g.drawRect((e.x - FP.camera.x) * sx, (e.y - FP.camera.y) * sy, h * sx, 1);
639+
640+
// v-speed, tip to tail
641+
g.lineStyle(1, 0x0000FF)
642+
g.drawRect((e.x - FP.camera.x + h) * sx, (e.y - FP.camera.y) * sy, 1, v * sy);
643+
}
621644
}
622645
}
623646
}

0 commit comments

Comments
 (0)