Skip to content

Commit c8c994d

Browse files
committed
got collision with blocks to work better (previously, had forgotten to account for the height of the player)
1 parent 06873d3 commit c8c994d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Player.as

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,26 @@ package
5555
if (dy < 0)
5656
{
5757
jumpHeight += -dy/8.0;//frameHeight;
58-
trace(jumpHeight);
58+
// trace(jumpHeight);
5959
}
6060
}
6161
}
6262

6363
public function canMove(dx:Number,dy:Number):Boolean
6464
{
65+
trace("doesn't overlap", doesNotOverlapAt(x+dx,y+dy,state.allBlocks));
66+
trace("not does overlap",!overlapsAt(x+dx,y+dy,state.allBlocks));
6567
//trace(y + dy <= FlxG.height - frameHeight);
6668
// Bound the block within the frame from left and right
6769
return x + dx >= 0
6870
&& x + dx <= FlxG.width - frameWidth
6971
&& y + dy <= FlxG.height - frameHeight
7072
&& y + dy >= 0
71-
&& doesNotOvelapAt(x + dx, y + dy, state.allBlocks);
73+
&& doesNotOverlapAt(x + dx, y + dy, state.allBlocks)
74+
&& doesNotOverlapAt(x + dx, y + dy + frameHeight/2, state.allBlocks);
7275
}
7376

74-
public function doesNotOvelapAt(X:Number,Y:Number,group:FlxGroup):Boolean
77+
public function doesNotOverlapAt(X:Number,Y:Number,group:FlxGroup):Boolean
7578
{
7679
var block:Block;
7780
for (var i:String in group.members)
@@ -104,7 +107,7 @@ package
104107
}
105108
else
106109
{
107-
trace("steady falling");
110+
// trace("steady falling");
108111
steadyFall();
109112
}
110113
}

0 commit comments

Comments
 (0)