X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FProjectile.cs;h=308e313d39dbbfae5fa5467d84f30f34b3d7bf54;hb=24421b10105ddc8a33d95c5e4ccb3d6380916fa8;hp=e9fd47b2cc95b06eb8b5cbc379a1728e48b1cda3;hpb=65c7b1983e25cd16f2e00b83f23542854e8345af;p=chaz%2Fcarfire
diff --git a/CarFire/CarFire/CarFire/Projectile.cs b/CarFire/CarFire/CarFire/Projectile.cs
index e9fd47b..308e313 100644
--- a/CarFire/CarFire/CarFire/Projectile.cs
+++ b/CarFire/CarFire/CarFire/Projectile.cs
@@ -40,48 +40,51 @@ namespace CarFire
Texture2D _projectileModel,
Vector2 _velocity,
int _gridX,
- int _gridY,
+ int _gridY)
+ /*,
int _pixelX,
- int _pixelY)
+ int _pixelY)*/
{
theMap = _currentMap;
projectileModel = _projectileModel;
velocity = _velocity;
gridX = _gridX;
gridY = _gridY;
- pixelX = _pixelX;
- pixelY = _pixelY;
+ pixelX = _gridX * (int)Map.PixelsToUnitSquares;
+ pixelY = _gridY * (int)Map.PixelsToUnitSquares;
+ damage = 20;
}
- public void Update()
+ public void Update(TimeSpan timespan)
{
+ /*
//See if something moved onto this projectile.
- if(theMap.IsCellOpen(gridX, gridY))
+ if(theMap.isOpenSquare(gridX, gridY))
{
- //theMap.damageSquare(gridX, gridY, damage);
+ theMap.damageSquare(gridX, gridY, damage);
}
+ */
//If the projectile will be moving to a new grid position we need to check to see if it is occupied.
- /*
- if ((int)((pixelX + velocity.X) / theMap.gridToPixelRatio) != gridX || (int)((pixelY + velocity.Y) / Map.gridToPixelRatio) != gridY)
+ if ((int)((pixelX + velocity.X) / Map.PixelsToUnitSquares) != gridX || (int)((pixelY + velocity.Y) / Map.PixelsToUnitSquares) != gridY)
{
- bool open = theMap.IsCellOpen((pixelX + velocity.X) / theMap.gridToPixelRatio, (pixelY + velocity.Y) / Map.gridToPixelRatio);
+ //bool open = theMap.IsCellOpen((int)((pixelX + velocity.X) /Map.PixelsToUnitSquares), (int)((pixelY + velocity.Y) / Map.PixelsToUnitSquares));
//If open just move this projectile there
//***Map doesn't need to know that this projectile is there because players/monsters are allowed
// to move into the path of projectiles.
- if (open)
+ //if (open)
{
+ //Console.WriteLine("pixelX:" + pixelX + " " + " pixelY: "+ pixelY);
pixelX += (int)velocity.X;
pixelY += (int)velocity.Y;
- gridX = pixelX / theMap.gridToPixelRatio;
- gridY = pixelY / theMap.gridToPixelRatio;
+ gridX = (int)(pixelX /Map.PixelsToUnitSquares);
+ gridY = (int)(pixelY / Map.PixelsToUnitSquares);
}
//If the square isn't open then just damage whatever is there
//TODO: A projectile must be deleted after this happens
- else
+ //else
{
//theMap.damageSquare(gridX, gridY, damage);
}
}
- */
//If it is not moving grid positions just increment pixelX and pixelY
else
{
@@ -96,9 +99,15 @@ namespace CarFire
///
/// The map X pixel position of the topLeft of the display
/// The map Y pixel position of the topLeft of the display
- public void Draw(SpriteBatch spriteBatch, int topLeftX, int topLeftY)
+ public void Draw(SpriteBatch spriteBatch)
{
- spriteBatch.Draw(projectileModel, new Vector2(topLeftX - pixelX, topLeftY - pixelY), null, Color.White, 0, new Vector2(0f, 0f), 1f, SpriteEffects.None, 0);
+ //Console.WriteLine(gridX + " " + gridY);
+ //Console.WriteLine(theMap.GetRectangleFromCoordinates(new Vector2(gridX, gridY)));
+ Rectangle position = theMap.GetRectangleFromCoordinates(new Vector2(gridX, gridY));
+ //spriteBatch.Draw(projectileModel, position, Color.White);
+ Rectangle position2 = new Rectangle((int)(pixelX), (int)(pixelY), (int)Map.PixelsToUnitSquares, (int)Map.PixelsToUnitSquares);
+ Rectangle position3 = theMap.GetRectangleFromCoordinates(new Vector2(pixelX / Map.PixelsToUnitSquares, pixelY / Map.PixelsToUnitSquares));
+ spriteBatch.Draw(projectileModel, position3, Color.White);
}
///