public SpaceShip(GameCore gameRef, Sprite sprite) { this.game = gameRef; this.sprite = sprite; health = new Health(10); guns = new Gun[1]; guns[0] = new Gun(game,77,27); }
public Gun(GameCore gameRef, int x, int y) { this.game = gameRef; sprite = game.resources.LoadSprite("resources/gfx/bullet.png"); fireRate = 150; this.x = x; this.y = y; }
public Sprite LoadSprite(string filePath) { Sprite sprite = GetSprite(filePath); if (sprite != null) { sprite.loadCount += 1; return sprite; } else { sprite = new Sprite(filePath); sprites.Add(sprite); return sprite; } }
public static bool HasHit(Point point1, Point point2, Sprite sprite1, Sprite sprite2) { Rectangle rec1 = new Rectangle(point1, sprite1.imageRec.Size); Rectangle rec2 = new Rectangle(point2, sprite2.imageRec.Size); if (rec1.IntersectsWith(rec2)) { return CheckCollisionData(rec1, rec2, sprite1, sprite2); //return true; } return false; }
private static bool CheckCollisionData(Rectangle rec1, Rectangle rec2, Sprite sprite1, Sprite sprite2) { Rectangle inter = rec1; inter.Intersect(rec2); for (int ix = inter.X; ix < inter.X + inter.Width; ix++) { for (int iy = inter.Y; iy < inter.Y + inter.Height; iy++) { if (sprite1.collisionData[ix - rec1.X, iy - rec1.Y] >= 96) { if (sprite2.collisionData[ix - rec2.X, iy - rec2.Y] >= 150) { return true; } } } } return false; }
public Bullet(Sprite sprite, bool playerIsOwner) { dead = false; this.sprite = sprite; this.playerIsOwner = playerIsOwner; }
public void Load(string filePath) { string platformPath = Globals.MakePathPlatformSpecific(filePath); if (!File.Exists(platformPath)) { throw new FileNotFoundException("File not found.", platformPath); } StreamReader sr = new StreamReader(platformPath); while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line.Contains("=")) { string[] split = line.Split(Convert.ToChar("=")); switch (split[0]) { case "name": name = split[1]; break; case "image": sprite = game.resources.LoadSprite(split[1]); break; case "health": health = new Health(int.Parse(split[1])); break; case "guntype": ReadGun(split[1]); break; } } } sr.Close(); sr.Dispose(); }
public Gun(GameCore gameRef) { this.game = gameRef; sprite = game.resources.LoadSprite("resources/gfx/bullet.png"); fireRate = 150; }