private void DrawTime(IGameGraphics graphics) { var sec = (int)(Math.Ceiling(remainingTime / 60.0)); var digits = 0; { var n = sec; while (n > 0) { digits++; n /= 10; } } var drawOffsetX = (Setting.ScreenWidth - 32 * digits) / 2; var drawOffsetY = 16; { var n = sec; for (var i = 0; i < digits; i++) { var d = n % 10; var row = d / 4; var col = d % 4; var drawX = drawOffsetX + 32 * (digits - i - 1); graphics.DrawImage(GameImage.Time, 32, 32, row, col, drawX, drawOffsetY); n /= 10; } } }
public EnemyGraphicsComponent(IGameGraphics gameGraphics, ISprite eSprite) { _gameGraphics = gameGraphics ?? throw new ArgumentNullException(nameof(gameGraphics)); _eSprite = eSprite ?? throw new ArgumentNullException(nameof(eSprite)); //Ensure that _active sprite is not null, as update could potentially be called before initialize _activeSprite = _eSprite; }
public void Draw(IGameGraphics graphics) { if (playerIndex >= 4) { graphics.SetColor(255, 0, 255, 0); } var drawOffset = (int)((32 - Width) / 2); var drawX = (int)Math.Round(X) - World.CameraLeft - drawOffset; var drawY = (int)Math.Round(Y); var rowOffset = 2 * (playerIndex % 4); if (canMove) { if (state == State.OnGround) { var anim = (int)(walkingDistance / distancePerAnimation); if (direction == Direction.Right) { anim += 4; } graphics.DrawImage(GameImage.Player, 32, 32, rowOffset, anim, drawX, drawY); } else if (state == State.InAir) { var anim = 0; if (vy > 0) { if (vy < maxFallingSpeed) { anim = 1; } else { anim = 2; } } if (direction == Direction.Right) { anim += 4; } graphics.DrawImage(GameImage.Player, 32, 32, rowOffset + 1, anim, drawX, drawY); } else { Debug.Assert(false); } } else { var anim = 3; if (direction == Direction.Right) { anim += 4; } graphics.DrawImage(GameImage.Player, 32, 32, rowOffset + 1, anim, drawX, drawY); } graphics.SetColor(255, 255, 255, 255); }
public void Draw(IGameGraphics graphics) { if (Right <= World.CameraLeft || Left >= World.CameraRight) { return; } var drawX = (int)Math.Round(X) - World.CameraLeft; var drawY = (int)Math.Round(Y); graphics.DrawImage(GameImage.Bomb, drawX, drawY); }
public override void Draw(IGameGraphics graphics) { if (Right <= World.CameraLeft || Left >= World.CameraRight) { return; } var drawX = (int)Math.Round(X - World.CameraLeft); var drawY = (int)Math.Round(Y); var anim = animation / 2; graphics.DrawImage(GameImage.Explosion, 128, 128, 0, anim, drawX, drawY); }
private void DrawPlayerState(IGameGraphics graphics) { for (var i = 0; i < players.Length; i++) { var rank = -1; if (playerRank != null) { rank = playerRank[i]; } players[i].DrawState(graphics, rank); } }
public void Draw(IGameGraphics graphics) { if (Right <= World.CameraLeft || Left >= World.CameraRight) { return; } var drawX = (int)Math.Round(X) - World.CameraLeft; var drawY = (int)Math.Round(Y); var row = animation / 2 / 8; var col = animation / 2 % 8; graphics.DrawImage(GameImage.Coin, 32, 32, row, col, drawX, drawY); }
public override void Draw(IGameGraphics graphics) { if (Right <= World.CameraLeft || Left >= World.CameraRight) { return; } var drawX = (int)Math.Round(X - World.CameraLeft); var drawY = (int)Math.Round(Y); var anim = animation; var row = anim / 4; var col = anim % 4; graphics.DrawImage(GameImage.SmallExplosion, 32, 32, row, col, drawX, drawY); }
private void DrawHuds(IGameGraphics graphics) { var hudSpace = 96 * players.Length; var emptySpace = Setting.ScreenWidth - hudSpace; var left = emptySpace / (players.Length + 1); var stride = left + 96; var drawX = left; foreach (var player in Players) { DrawHud(graphics, player, drawX, Setting.ScreenHeight - 48); drawX += stride; } }
private void DrawHud(IGameGraphics graphics, GamePlayer player, int x, int y) { graphics.DrawImage(GameImage.Hud, 96, 32, 3, 0, x, y); var ammo = player.CoinCount; if (ammo / 100 > 0) { DrawNumber(graphics, ammo / 100 % 10, x + 32, y); } if (ammo / 10 > 0) { DrawNumber(graphics, ammo / 10 % 10, x + 32 + 19, y); } if (ammo >= 0) { DrawNumber(graphics, ammo % 10, x + 32 + 19 + 19, y); } var pi = player.PlayerIndex % 4; if (player.PlayerIndex >= 4) { graphics.SetColor(255, 0, 255, 0); } graphics.DrawImage(GameImage.Player, 32, 32, 2 * pi, 4, x, y); if (player.PlayerIndex >= 4) { graphics.SetColor(255, 255, 255, 255); } for (var i = 0; i < Math.Min(player.TrophyCount, 6); i++) { graphics.DrawImage(GameImage.Trophy, 16, 16, 0, 0, x + 16 * i, y - 16); } for (var i = 0; i < Math.Min(player.UnkoCount, 6); i++) { graphics.DrawImage(GameImage.Trophy, 16, 16, 0, 1, x + 16 * i, y + 32); } }
public void DrawState(IGameGraphics graphics, int rank) { if (!ready) { if (rank >= 0) { var r = rank; if (r > 3) { r = 3; } var drawX = (int)Math.Round(CenterX - World.CameraLeft - 32); var drawY = (int)Math.Round(Top - 64); graphics.DrawImage(GameImage.Rank, 64, 64, 0, r, drawX, drawY); } } else { var drawX = (int)Math.Round(CenterX - World.CameraLeft - 32); var drawY = (int)Math.Round(Top - 32); graphics.DrawImage(GameImage.Ready, drawX, drawY); } }
public MortalCoilSolver() : base() { this.gameSystem = system.SystemInterface; this.graphics = gameSystem.Graphics; this.input = gameSystem.Input; FPSComponent fps = new FPSComponent(this); this.r = new Random(); }
public abstract void Draw(IGameGraphics graphics);
public BulletGraphicsComponent(IGameGraphics gameGraphics, ISprite bulletSprite) { _gameGraphics = gameGraphics; _bulletSprite = bulletSprite; }
private void DrawNumber(IGameGraphics graphics, int n, int x, int y) { graphics.DrawImage(GameImage.Hud, 32, 32, 4 + n / 8, n % 8, x, y); }
public void Draw(IGameGraphics graphics) { graphics.Begin(); var sky = (double)elapsedTime / oneGameDuration; graphics.SetColor(255, 255, 255, 255); { var dx = cameraIntX + Setting.ScreenWidth / 2 - fieldWidth / 2; var drawX = (int)Math.Round((Setting.ScreenWidth - 1024) / 2 - dx / 4.0); graphics.DrawImage(GameImage.BlueSky, drawX, 0); } { var dx = cameraIntX + Setting.ScreenWidth / 2 - fieldWidth / 2; var drawX = (int)Math.Round((Setting.ScreenWidth - 1024) / 2 - dx / 2.0); graphics.DrawImage(GameImage.Trees, drawX, 256); } graphics.DrawImage(GameImage.Field, -cameraIntX, Setting.ScreenHeight - 128); graphics.SetColor(255, 255, 255, 255); foreach (var particle in particles) { particle.Draw(graphics); } foreach (var coin in coins) { coin.Draw(graphics); } foreach (var bomb in bombs) { bomb.Draw(graphics); } foreach (var player in players) { player.Draw(graphics); } if (state == State.Waiting) { DrawPlayerState(graphics); if (playerRank != null) { var drawX = (Setting.ScreenWidth - 256) / 2; graphics.DrawImage(GameImage.Message, 256, 128, 1, 1, drawX, 64); } else { var drawX = (Setting.ScreenWidth - 512) / 2; graphics.DrawImage(GameImage.Title, drawX, 64); } } else if (state == State.Ready) { if (countDown < 3) { var drawX = (Setting.ScreenWidth - 128) / 2; graphics.DrawImage(GameImage.Message, 128, 128, 0, countDown, drawX, 64); } } else if (state == State.Playing) { if (elapsedTime < 60) { var drawX = (Setting.ScreenWidth - 256) / 2; graphics.DrawImage(GameImage.Message, 256, 128, 1, 0, drawX, 64); } DrawTime(graphics); } DrawHuds(graphics); graphics.End(); }