move comment to appropriate place

GitOrigin-RevId: e0555ac9dde749b46c629218ebabc29a0cbce678
This commit is contained in:
Colin McMillen 2019-12-12 14:00:07 -05:00
parent 0b45e545a3
commit ba459a9738

View File

@ -13,7 +13,6 @@ namespace Jumpy {
private Texture2D texture; private Texture2D texture;
private const int spriteSize = 48; private const int spriteSize = 48;
private const int spriteWidth = 7; private const int spriteWidth = 7;
private const int bottomPadding = 1;
private const int moveSpeed = 150; private const int moveSpeed = 150;
private const int jumpSpeed = 500; private const int jumpSpeed = 500;
private const int gravity = 1500; private const int gravity = 1500;
@ -30,23 +29,18 @@ namespace Jumpy {
this.texture = texture; this.texture = texture;
} }
// TODO: refactor input to have a virtual "which directions & buttons were being pressed"
// instead of complicated if-statements in this function.
public void Update( public void Update(
GameTime time, History<GamePadState> gamePad, List<Rectangle> collisionTargets) { GameTime time, History<GamePadState> gamePad, List<Rectangle> collisionTargets) {
Point oldPosition = position; Point oldPosition = position;
AirState oldAirState = airState; AirState oldAirState = airState;
UpdateFromGamePad(time, gamePad); UpdateFromGamePad(time, gamePad);
bool someIntersection = false;
Rectangle playerBbox = new Rectangle(position.X - spriteWidth, position.Y - 8, spriteWidth * 2, 27); Rectangle playerBbox = new Rectangle(position.X - spriteWidth, position.Y - 8, spriteWidth * 2, 27);
bool standingOnGround = false; bool standingOnGround = false;
foreach (var rect in collisionTargets) { foreach (var rect in collisionTargets) {
playerBbox = new Rectangle(position.X - spriteWidth, position.Y - 8, spriteWidth * 2, 27); playerBbox = new Rectangle(position.X - spriteWidth, position.Y - 8, spriteWidth * 2, 27);
if (playerBbox.Intersects(rect)) { if (playerBbox.Intersects(rect)) {
someIntersection = true;
if (oldPosition.Y > position.Y) { if (oldPosition.Y > position.Y) {
int diff = playerBbox.Top - rect.Bottom; int diff = playerBbox.Top - rect.Bottom;
position.Y -= diff; position.Y -= diff;
@ -85,6 +79,8 @@ namespace Jumpy {
} }
} }
// TODO: refactor input to have a virtual "which directions & buttons were being pressed"
// instead of complicated if-statements in this function.
void UpdateFromGamePad(GameTime time, History<GamePadState> gamePad) { void UpdateFromGamePad(GameTime time, History<GamePadState> gamePad) {
if (gamePad[0].IsButtonDown(Buttons.A) && airState == AirState.Ground) { if (gamePad[0].IsButtonDown(Buttons.A) && airState == AirState.Ground) {
pose = Pose.Jumping; pose = Pose.Jumping;