public void Draw(CanvasContext2D context, int _x, int _y, int mapX, int mapY) { context.Save(); context.Translate(_x + mapX * ZombieGameConfig.TileSize, _y + mapY * ZombieGameConfig.TileSize); /* context.Translate(ZombieGameConfig.TileSize / 2, ZombieGameConfig.TileSize / 2); //context.Rotate(fm); context.Translate(-ZombieGameConfig.TileSize / 2, -ZombieGameConfig.TileSize / 2); */ context.DrawImage((CanvasElement) Image.Canvas, 0, 0); /* context.StrokeStyle = "red"; context.StrokeRect(0, 0, ZombieGameConfig.TileSize, ZombieGameConfig.TileSize); switch (Collision) { case CollisionType.Full: context.FillStyle = "rgba(233,12,22,0.6)"; context.FillRect(0, 0, ZombieGameConfig.TileSize, ZombieGameConfig.TileSize); break; case CollisionType.RightHalf: context.FillStyle = "rgba(233,12,22,0.6)"; context.FillRect(ZombieGameConfig.TileSize / 2, 0, ZombieGameConfig.TileSize / 2, ZombieGameConfig.TileSize); break; case CollisionType.TopHalf: context.FillStyle = "rgba(233,12,22,0.6)"; context.FillRect(0, 0, ZombieGameConfig.TileSize, ZombieGameConfig.TileSize / 2); break; case CollisionType.LeftHalf: context.FillStyle = "rgba(233,12,22,0.6)"; context.FillRect(0, 0, ZombieGameConfig.TileSize / 2, ZombieGameConfig.TileSize); break; case CollisionType.BottomHalf: context.FillStyle = "rgba(233,12,22,0.6)"; context.FillRect(0, ZombieGameConfig.TileSize / 2, ZombieGameConfig.TileSize, ZombieGameConfig.TileSize / 2); break; } */ //todo enable when some sort of edit mode is enabled context.Restore(); }
public void Draw(CanvasContext2D context) { context.Save(); switch (GameMode) { case GameMode.TileEdit: break; case GameMode.Play: screenOffset.X = Game.Screen.Width / 2 - WindowManager.Width * Scale.X / 2; screenOffset.Y = Game.Screen.Height / 2 - WindowManager.Height * Scale.Y / 2; context.Translate(screenOffset.X, screenOffset.Y); playDraw(context); break; } context.Restore(); }
private void playDraw(CanvasContext2D context) { var wm = WindowManager; int wX = Math.Max(0, wm.X / ZombieGameConfig.TileSize - 3); int wY = Math.Max(0, wm.Y / ZombieGameConfig.TileSize - 3); int wWidth = wX + wm.Width / ZombieGameConfig.TileSize + 6; int wHeight = wY + wm.Height / ZombieGameConfig.TileSize + 6; context.Save(); context.Scale(Scale.X, Scale.Y); context.BeginPath(); context.Rect(0, 0, wm.Width, wm.Height); context.Clip(); context.ClosePath(); context.Translate(-wm.X, -wm.Y); ( (DrawMapManager) MapManager ).Draw(context, wX, wY, wWidth, wHeight); ( (DrawUnitManager) UnitManager ).Draw(context); context.Restore(); }
public void Render(CanvasContext2D context, bool force) { var x = Position.X; var y = Position.Y; context.Save(); context.Translate(x, y); if (Game.DRAWFAST) drawCircle(context, obtainGradient(context, this), Size); else { if (force || cache.Images == null) drawGrad(context, obtainGradient(context, this), Size); else drawImage(context, cache.Images[curGradIndex++], Size); } context.Restore(); }