|
|
@ -45,10 +45,7 @@ namespace SemiColinGames { |
|
|
|
Rectangle oldBbox = Bbox(oldPosition); |
|
|
|
Rectangle playerBbox = Bbox(position); |
|
|
|
bool standingOnGround = false; |
|
|
|
// TODO: implement https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
|
|
|
|
// e.g. http://members.chello.at/~easyfilter/bresenham.html
|
|
|
|
// TODO: currently player doesn't fall through a gap one tile wide; presumably this will
|
|
|
|
// be fixed by switching to a line-rasterization approach.
|
|
|
|
|
|
|
|
foreach (var rect in collisionTargets) { |
|
|
|
playerBbox = Bbox(position); |
|
|
|
|
|
|
@ -100,9 +97,6 @@ namespace SemiColinGames { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: refactor input to have a virtual "which directions & buttons were being pressed"
|
|
|
|
// instead of complicated if-statements in this function.
|
|
|
|
// TODO: refactor to use a state-machine.
|
|
|
|
void UpdateFromInput( |
|
|
|
GameTime time, History<GamePadState> gamePad, History<KeyboardState> keyboard) { |
|
|
|
if ((gamePad[0].IsButtonDown(Buttons.A) && gamePad[1].IsButtonUp(Buttons.A) || |
|
|
@ -124,8 +118,6 @@ namespace SemiColinGames { |
|
|
|
} |
|
|
|
|
|
|
|
Vector2 leftStick = gamePad[0].ThumbSticks.Left; |
|
|
|
// TODO: have keyboard directions cancel each other out if mutually-incompatible keys are
|
|
|
|
// held down?
|
|
|
|
if (gamePad[0].IsButtonDown(Buttons.DPadLeft) || leftStick.X < -0.5 || |
|
|
|
keyboard[0].IsKeyDown(Keys.A)) { |
|
|
|
facing = Facing.Left; |
|
|
@ -162,7 +154,6 @@ namespace SemiColinGames { |
|
|
|
pose = Pose.Jumping; |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: also bound player position by the right edge of the World?
|
|
|
|
position.X = Math.Max(position.X, 0 + spriteWidth); |
|
|
|
} |
|
|
|
|
|
|
@ -201,7 +192,6 @@ namespace SemiColinGames { |
|
|
|
} |
|
|
|
|
|
|
|
public void Draw(SpriteBatch spriteBatch, Camera camera, GameTime time) { |
|
|
|
// TODO: don't create so many "new" things that could be cached / precomputed.
|
|
|
|
int index = spritePosition(pose, time); |
|
|
|
Rectangle textureSource = new Rectangle(index * spriteSize, 0, spriteSize, spriteSize); |
|
|
|
Vector2 spriteCenter = new Vector2(spriteSize / 2, spriteSize / 2); |
|
|
|