X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=CarFire%2FCarFire%2FCarFire%2FHuman.cs;h=07b4222f97a6fff7c3a0b36072ea9d27b0a24110;hb=0b53fe63e2a9354e4c52506e2012065d15bbcff1;hp=8c94c297de9152bcdf999c197f7b7b717ef45751;hpb=f74a6d5893ee639cb45c2190605145365781e6eb;p=chaz%2Fcarfire
diff --git a/CarFire/CarFire/CarFire/Human.cs b/CarFire/CarFire/CarFire/Human.cs
index 8c94c29..07b4222 100644
--- a/CarFire/CarFire/CarFire/Human.cs
+++ b/CarFire/CarFire/CarFire/Human.cs
@@ -18,13 +18,13 @@ namespace CarFire
up,
down
};
+ //The number of frames between each square movements
const int moveCoolDown = 15;
+ //The number of frames between each projectile is spawned.
const int shootCoolDown = 10;
- //Member Variables
State state;
String CharName;
Map theMap;
- int movementSpeed;
int gridX;
int gridY;
Texture2D charModel;
@@ -38,8 +38,6 @@ namespace CarFire
bool isMoving;
float pixelX;
float pixelY;
- float nextPixelX;
- float nextPixelY;
int movementSteps;
int movementCoolDown;
float changeX;
@@ -58,8 +56,6 @@ namespace CarFire
theMap = _theMap;
CharName = Name;
theDisplay = mDisplay;
-
- movementSpeed = 12; // randomly set now
health = 100;
score = 0;
visible = false;
@@ -68,6 +64,7 @@ namespace CarFire
charModel = model;
projectileModel = projectile;
projectileSpeed = 30;
+ //The number of animation steps between each square movement.
movementSteps = moveCoolDown -2;
}
@@ -89,9 +86,14 @@ namespace CarFire
return 0;
}
-
+ ///
+ /// This method will draw a character to the screen.
+ ///
+ ///
+ ///
public long Draw(SpriteBatch spriteBatch)
{
+ //If the sprite is moving there are still movement animations to do.
if (isMoving && movementSteps > 0)
{
movementSteps--;
@@ -100,6 +102,7 @@ namespace CarFire
Rectangle position3 = theMap.GetRectangleFromCoordinates(new Vector2(pixelX / Map.PixelsToUnitSquares, pixelY / Map.PixelsToUnitSquares));
spriteBatch.Draw(charModel, position3, Color.White);
}
+ // If the sprite is not moving then just draw it.
else
{
pixelX = gridX * Map.PixelsToUnitSquares;
@@ -150,8 +153,7 @@ namespace CarFire
gridY -= 1;
movementCoolDown = moveCoolDown;
isMoving = true;
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);
+
}
// move upright
@@ -163,8 +165,7 @@ namespace CarFire
gridY -= 1;
movementCoolDown = moveCoolDown;
isMoving = true;
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);
+
}
// move downleft
@@ -176,8 +177,7 @@ namespace CarFire
gridY += 1;
movementCoolDown = moveCoolDown;
isMoving = true;
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);
+
}
// move downright
else if (keysPressed.Contains(Keys.Down) && keysPressed.Contains(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY + 1))
@@ -188,8 +188,7 @@ namespace CarFire
gridY += 1;
movementCoolDown = moveCoolDown;
isMoving = true;
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);
+
}
// move up
else if (keysPressed.Contains(Keys.Up) && theMap.IsCellOpen(gridX, gridY - 1))
@@ -200,8 +199,6 @@ namespace CarFire
gridY -= 1;
movementCoolDown = moveCoolDown;
isMoving = true;
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);
changeY = (float)(-Map.PixelsToUnitSquares / moveCoolDown);
}
// move down
@@ -213,8 +210,6 @@ namespace CarFire
gridY += 1;
movementCoolDown = moveCoolDown;
isMoving = true;
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);
changeY = (float)(Map.PixelsToUnitSquares / moveCoolDown);
}
// move left
@@ -226,8 +221,6 @@ namespace CarFire
gridX -= 1;
movementCoolDown = moveCoolDown;
isMoving = true;
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);
changeX = (float)(-Map.PixelsToUnitSquares / moveCoolDown);
}
// move right
@@ -239,8 +232,6 @@ namespace CarFire
gridX += 1;
movementCoolDown = moveCoolDown;
isMoving = true;
- nextPixelX = (float)(gridX * Map.PixelsToUnitSquares);
- nextPixelY = (float)(gridY * Map.PixelsToUnitSquares);
changeX = (float)(Map.PixelsToUnitSquares / moveCoolDown);
}
}