public Player(Vector2 pos, Color col) { position = pos; sprite = new SpriteObj("Assets/player.png", position); width = sprite.Width; height = sprite.Height; sprite.Translate(-width / 2, -height); distToSide = 20; shootDelay = 0.5f; color = col; ray = width / 2; nrg = 3; score = 0; IsAlive = true; //baseRect = new Rect(position.X - width / 2, position.Y - height / 2, width, height / 2, color); //int cannWidth = width / 3; //cannonRect = new Rect(position.X - cannWidth / 2, position.Y - height, cannWidth, height / 2, color); bullets = new Bullet[30]; Color bulletCol = new Color(200, 0, 0); for (int i = 0; i < bullets.Length; i++) { bullets[i] = new Bullet(10, 20, bulletCol); } }
public Player(Vector2 pos, Color col) { position = pos; sprite = new SpriteObj("Assets/player.png", position); width = sprite.Width; height = sprite.Height; //sprite.Translate(-width / 2, -height); distToSide = 20; shootDelay = 0.3f; color = col; ray = width / 2; nrg = 3; score = 0; IsAlive = true; bullets = new Bullet[30]; Color bulletCol = new Color(200, 0, 0); for (int i = 0; i < bullets.Length; i++) { bullets[i] = new Bullet(10, 20, bulletCol); } }
public Animation(string[] files, SpriteObj animationOwner, float fps) { Loop = true; IsPlaying = true; numFrames = files.Length; owner = animationOwner; sprites = new Sprite[numFrames]; for (int i = 0; i < sprites.Length; i++) { sprites[i] = new Sprite(files[i]); } owner.SetSprite(sprites[0]); if (fps > 0.0f) { frameDuration = 1 / fps; } else { frameDuration = 0.0f; } }
public Barrier(int x, int y) { position = new Vector2(x, y); sprite = new SpriteObj("Assets/barrier.png", x, y); sprite.Translate(-Width / 2, -Height / 2); counter = 0; }
public AlienBullet() { Position = new Vector2(0, 0); velocity = Position; sprite = new SpriteObj(); string[] animationFiles = { "Assets/alienBullet_0.png", "Assets/alienBullet_1.png" }; animation = new Animation(animationFiles, sprite, 12); }
private void SetText(string newText) { if (newText != text) { text = newText; int numChars = text.Length; int charX = (int)Position.X; int charY = (int)Position.Y; for (int i = 0; i < numChars && i < sprites.Length; i++) { char number = text[i]; sprites[i] = new SpriteObj("Assets/numbers_" + number + ".png", charX, charY); charX += sprites[i].Width; } } }
public Ship() { Position = new Vector2(0, 0); velocity = Position; sprite = new SpriteObj(); string[] animationFiles = new string[8]; for (int i = 0; i < 5; i++) { animationFiles[i] = "Assets/ship_" + i + ".png"; } int index = 3; for (int i = 0; i < 3; i++) { animationFiles[i + 5] = "Assets/ship_" + index + ".png"; index--; } // = { "Assets/alienBullet_0.png", "Assets/alienBullet_1.png" }; animation = new Animation(animationFiles, sprite, 12); ray = sprite.Width / 2; }