up,\r
down\r
};\r
+ //The number of frames between each square movements\r
const int moveCoolDown = 15;\r
+ //The number of frames between each projectile is spawned.\r
const int shootCoolDown = 10;\r
- //Member Variables\r
State state;\r
String CharName;\r
Map theMap;\r
- int movementSpeed;\r
int gridX;\r
int gridY;\r
Texture2D charModel;\r
bool isMoving;\r
float pixelX;\r
float pixelY;\r
- float nextPixelX;\r
- float nextPixelY;\r
int movementSteps;\r
int movementCoolDown;\r
float changeX;\r
theMap = _theMap;\r
CharName = Name;\r
theDisplay = mDisplay;\r
-\r
- movementSpeed = 12; // randomly set now\r
health = 100;\r
score = 0;\r
visible = false;\r
charModel = model;\r
projectileModel = projectile;\r
projectileSpeed = 30;\r
+ //The number of animation steps between each square movement.\r
movementSteps = moveCoolDown -2;\r
\r
}\r
return 0;\r
\r
}\r
-\r
+ /// <summary>\r
+ /// This method will draw a character to the screen.\r
+ /// </summary>\r
+ /// <param name="spriteBatch"></param>\r
+ /// <returns></returns>\r
public long Draw(SpriteBatch spriteBatch)\r
{\r
+ //If the sprite is moving there are still movement animations to do.\r
if (isMoving && movementSteps > 0)\r
{\r
movementSteps--;\r
Rectangle position3 = theMap.GetRectangleFromCoordinates(new Vector2(pixelX / Map.PixelsToUnitSquares, pixelY / Map.PixelsToUnitSquares));\r
spriteBatch.Draw(charModel, position3, Color.White);\r
}\r
+ // If the sprite is not moving then just draw it.\r
else\r
{\r
pixelX = gridX * Map.PixelsToUnitSquares;\r
gridY -= 1;\r
movementCoolDown = moveCoolDown;\r
isMoving = true;\r
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);\r
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);\r
+ \r
\r
}\r
// move upright\r
gridY -= 1;\r
movementCoolDown = moveCoolDown;\r
isMoving = true;\r
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);\r
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);\r
+ \r
\r
}\r
// move downleft\r
gridY += 1;\r
movementCoolDown = moveCoolDown;\r
isMoving = true;\r
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);\r
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);\r
+ \r
}\r
// move downright\r
else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY + 1))\r
gridY += 1;\r
movementCoolDown = moveCoolDown;\r
isMoving = true;\r
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);\r
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);\r
+ \r
}\r
// move up\r
else if (keysPressed.Contains<Keys>(Keys.Up) && theMap.IsCellOpen(gridX, gridY - 1))\r
gridY -= 1;\r
movementCoolDown = moveCoolDown;\r
isMoving = true;\r
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);\r
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);\r
changeY = (float)(-Map.PixelsToUnitSquares / moveCoolDown);\r
}\r
// move down\r
gridY += 1;\r
movementCoolDown = moveCoolDown;\r
isMoving = true;\r
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);\r
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);\r
changeY = (float)(Map.PixelsToUnitSquares / moveCoolDown);\r
}\r
// move left\r
gridX -= 1;\r
movementCoolDown = moveCoolDown;\r
isMoving = true;\r
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);\r
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);\r
changeX = (float)(-Map.PixelsToUnitSquares / moveCoolDown);\r
}\r
// move right\r
gridX += 1;\r
movementCoolDown = moveCoolDown;\r
isMoving = true;\r
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);\r
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);\r
changeX = (float)(Map.PixelsToUnitSquares / moveCoolDown);\r
}\r
}\r