Movement Acceleration

Modified the player class, so that now whenever the player moves an acceleration value is added to the player’s velocity.  Previously, I just set the velocity to a constant (8 pixels per frame).  That gave the effect of the player abruptly starting and stopping.  By adding the acceleration value, the player now more smoothly starts and stops.

Unfortunately, this caused the player to start getting stuck in blocks again.  This did not become apparent until velocities with decimals (fractions) were being used.  This was due to the player not being offset when colliding with a block.  Therefore, I added a Vector2 ref parameter to the checkCollision method, which gets set to the number of pixels that the player should get set forward when colliding with the block to align with the block.  If the player is moving right, this will be the block location minus the player location and width.  The calculations are the same for moving left, except the block width is added and player’s width is not used.  This could have been easily fixed by just using whole numbers for acceleration, but I wanted to go ahead and do this the right way because I may want to use factions for acceleration to give an ice floor sliding effect.

 

screen062

I also noticed a problem when trying to socket an ability into a weapon that does not exist.  I added some additional bounds and null checking to resolve this error.

Below is the list of remaining changes I plan to implement in the near future.

  • Make a max speed socket
  • Limit number of shots at a time based on weapon
  • Get defense items working; Additional updates to equipment screen
  • Fix light gradient for dark rooms
  • Create model for weapon
  • Buy items with money
  • Level editor
  • Add rooms above/below, vertical scrolling