public static Surface Render(PlayerUnit Unit) { Surface Buffer = new Surface(PUNIT_WIDTH_PX, PUNIT_WIDTH_PX); Color Bg = Color.WhiteSmoke; switch (Unit.Class) { case UnitClasses.Archer: Bg = Color.Orange; break; case UnitClasses.Mage: Bg = Color.Blue; break; case UnitClasses.Paladin: Bg = Color.DeepPink; break; case UnitClasses.Soldier: Bg = Color.Brown; break; case UnitClasses.Thieft: Bg = Color.Yellow; break; } Rectangle UnitRect = new Rectangle(new Point(0,0), new Size(Buffer.Width, Buffer.Height)); Box Border = new Box(new Point(0, 0), new Size(Buffer.Width - 1, Buffer.Height - 1)); Buffer.Fill(UnitRect, Bg); Buffer.Draw(Border, Color.WhiteSmoke, true); Buffer.AlphaBlending = true; Buffer.Alpha = 230; return Buffer; }
public static void DrawSpriteHPBar(RendererDestinationData destData, ISprite sprite, int hp, int maxHP) { int x = 0; int y = 0; x = ScreenRenderer.ToTileX(sprite.Location.X) + sprite.Offset.X; y = ScreenRenderer.ToTileY(sprite.Location.Y) + sprite.Offset.Y; //if (sprite == ScreenRenderer.Camera.FocusedSprite) { // x = ScreenRenderer.NewX; // y = ScreenRenderer.NewY; //} else { //} //if (MaxInfo.SpriteSize == 0) { // Box hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(x, y + 32), new Point(x + 50, y + 36)); // destSurf.Draw(hpBox, Color.Black, false, true); // if (maxHP < 1) { // hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(x, y + 32), new Point(x + ((hp / 100) / ((maxHP + 1) / 100) * 50), y + 36)); // } else { // hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(x, y + 32), new Point(x + ((hp / 100) / (maxHP / 100) * 50), y + 36)); // } // destSurf.Draw(hpBox, Color.LightGreen, false, true); //} else { Box hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 36), new Point(destData.Location.X + x + 32, destData.Location.Y + y + 40)); destData.Draw(hpBox, Color.Black, false, true); if (maxHP > 0) { hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x + 1, destData.Location.Y + y + 37), new Point(Convert.ToInt32(destData.Location.X + x + (Logic.MathFunctions.CalculatePercent(hp, maxHP) * 0.01) * 31), destData.Location.Y + y + 39)); } destData.Draw(hpBox, Color.LightGreen, false, true); //} }
public HelloWorld() { // System Setup Video.SetVideoMode(400, 300); Video.WindowCaption = "Hello World!"; // Objects Setup Player = new Box(20, 20, 60, 60); }
public void Draw(Surface sfcGameWindow, float x, float y, int alpha=255, bool fill=false) { if (sfc != null) { sfcGameWindow.Blit (sfc, new Point ((int)x, (int)y)); } else { box = new Box (new Point ((int)x, (int)y), new Size (width, height)); int r = colour.R; int g = colour.G; int b = colour.B; Color colour2 = Color.FromArgb (alpha, r, g, b); if (colour == Color.Transparent) { colour2 = colour; } sfcGameWindow.Draw (box, colour2, true, fill); } }
public static void DrawNpcBars(RendererDestinationData destData, Map map, Enums.MapID targetMapID, int npcSlot) { MapNpc npc = map.MapNpcs[npcSlot]; int x, y; if (npc != null && npc.HP > 0 && npc.Num > 0 && npc.ScreenActive) { if (npc.HP != npc.MaxHP) { //if (Npc.NpcHelper.Npcs[npc.Num].Big) { // x = (npc.Location.X * Constants.TILE_WIDTH - 9 + npc.Offset.X) - (Globals.NewMapX * Constants.TILE_WIDTH) - Globals.NewMapXOffset; // y = (npc.Location.Y * Constants.TILE_HEIGHT + npc.Offset.Y) - (Globals.NewMapY * Constants.TILE_HEIGHT) - Globals.NewMapYOffset; // Box hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + 50, destData.Location.Y + y + 36)); // destData.Draw(hpBox, Color.Black, false, true); // if (npc.MaxHP < 1) { // hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + ((npc.HP / 100) / ((npc.MaxHP + 1) / 100) * 50), destData.Location.Y + y + 36)); // } else { // double // hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + ((npc.HP / 100) / (double)((double)npc.MaxHP / 100) * 50)), destData.Location.Y + y + 36)); // } // destData.Draw(hpBox, Color.LightGreen, false, true); //} else { int npcX = npc.Location.X; int npcY = npc.Location.Y; Renderers.Maps.SeamlessWorldHelper.ConvertCoordinatesToBorderless(map, targetMapID, ref npcX, ref npcY); x = ScreenRenderer.ToTileX(npcX) + npc.Offset.X; //(npc.X * Constants.TILE_WIDTH + sx + npc.XOffset) - (Globals.NewMapX * Constants.TILE_WIDTH) - Globals.NewMapXOffset; y = ScreenRenderer.ToTileY(npcY) + npc.Offset.Y; //(npc.Y * Constants.TILE_HEIGHT + sx + npc.YOffset) - (Globals.NewMapY * Constants.TILE_HEIGHT) - Globals.NewMapYOffset; Box hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + 32, destData.Location.Y + y + 36)); destData.Draw(hpBox, Color.Black, false, true); if (npc.MaxHP < 1) { hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + 32, destData.Location.Y + y + 36)); } else { hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x + 1, destData.Location.Y + y + 33), new Point(Convert.ToInt32(destData.Location.X + x + (Logic.MathFunctions.CalculatePercent(npc.HP, npc.MaxHP) * 0.01) * 31), destData.Location.Y + y + 35)); } destData.Draw(hpBox, Color.LightGreen, false, true); //} } } }
public void Initialize(Rectangle mapRectangle, Rectangle showRectangle, Surface map) { double xScaleFactor = Convert.ToDouble(panel.Width) / Convert.ToDouble(mapRectangle.Width); double yScaleFactor = Convert.ToDouble(panel.Height) / Convert.ToDouble(mapRectangle.Height); if (xScaleFactor < yScaleFactor) { scaleFactor = xScaleFactor; } else { scaleFactor = yScaleFactor; } short mapX = (short)(mapRectangle.X * scaleFactor); short mapY = (short)(mapRectangle.Y * scaleFactor); short mapW = (short)(mapRectangle.Width * scaleFactor); short mapH = (short)(mapRectangle.Height * scaleFactor); short x = (short)(showRectangle.X * scaleFactor); short y = (short)(showRectangle.Y * scaleFactor); short w = (short)(showRectangle.Width * scaleFactor); short h = (short)(showRectangle.Height * scaleFactor); if (mapW > surfaceControl.Width) { mapW = (short)panel.Width; } if (mapH > surfaceControl.Height) { mapH = (short)panel.Height; } mapViewport = new Box(new Point(x, y), new Point(x + w - 1, y + h - 1)); mapSurface = map; surface = new Surface(mapW, mapH); surface = map.CreateScaledSurface(scaleFactor, true); surface.Draw(mapViewport, Color.Red); Point pos = new Point((panel.Width / 2) - (mapW / 2), (panel.Height / 2) - (mapH / 2)); surfaceControl.Width = mapW; surfaceControl.Height = mapH; surfaceControl.Location = pos; this.surfaceControl.Blit(surface); this.initialized = true; }
private void CreerLevens() { Levens.Clear(); for (int i = speler.Levens; i >0; i--) { LevensBoxen[i] = new Box( new Point(25,25+(i*25)),new Size(50,20)); Levens.Add(LevensBoxen[i]); } }
public void ViewportChanged(Rectangle newViewport, Surface map) { if (initialized) { short x = (short)(newViewport.X * scaleFactor); short y = (short)(newViewport.Y * scaleFactor); short w = (short)(newViewport.Width * scaleFactor); short h = (short)(newViewport.Height * scaleFactor); if (w > surfaceControl.Width) { w = (short)surface.Width; } if (h > surfaceControl.Height) { h = (short)surface.Height; } mapViewport = new Box(new Point(x, y), new Point(x + w - 1, y + h - 1)); mapSurface = map; if (map != null) { surface = map.CreateScaledSurface(scaleFactor, true); } surface.Draw(mapViewport, Color.Red); this.surfaceControl.Blit(surface); } }
public override Surface Render() { Surface Buffer = new Surface(Width,Height); for (int i = 0; i < map.Rows; i++) { for (int j = 0; j < map.Columns; j++) { String TexName = map.DefaultTileTexture; Rectangle Clip = new Rectangle(new Point(j * TileWidth, i * TileHeight), new Size(Tile.TILE_WIDTH,Tile.TILE_HEIGHT)); Buffer.Blit(Textures[TexName], Clip); } } for(int i=0; i<map.Rows; i++) { for(int j=0; j<map.Columns; j++) { String TexName = map.Tiles[i][j].Texture; Rectangle Clip = new Rectangle(new Point(j * TileWidth, i * TileHeight), new Size(Tile.TILE_WIDTH, Tile.TILE_HEIGHT)); Buffer.Blit(Textures[TexName], Clip); } } Box Border = new Box(new Point(0, 0), new Size(Width - 1, Height - 1)); Buffer.Draw(Border, Color.Black, true); return Buffer; }
public override Surface RenderHighlight() { Box outline = new Box(new Point(0, 0), new Size(Width-1, Height-1)); Surface Buffer = new Surface(Width, Height); Buffer.Fill(Color.YellowGreen); Buffer.Draw(outline, Color.WhiteSmoke); Surface CaptionSur = DefaultStyle.GetFont().Render(Caption, Color.White); Buffer.Blit(CaptionSur, new Point((Width - CaptionSur.Width) / 2, (Height - CaptionSur.Height) / 2)); return Buffer; }
public WaveInfoBox(XmlCreepWave Wave, List<GuiItem> Garbage) : base("WaveInfoBox") { this.Wave = Wave; this.Garbage = Garbage; Width = 300; Height = 300; Background = new BackgroundItem(Color.WhiteSmoke); Background.Width = Width; Background.Height = Height; TimeBar = new Rectangle(new Point(10,220),new Size(Width-20,22)); TimeBarBorder = new Box(TimeBar.Location, TimeBar.Size); labelHealth = new LabelItem(); labelResist = new LabelItem(); labelWeakness = new LabelItem(); labelNumbers = new LabelItem(); labelName = new LabelItem(); labelTips = new LabelItem(); labelTitle = new LabelItem("Next Wave"); }
public override void Render(int x, int y, SdlDotNet.Graphics.Surface dest) { Box box = new SdlDotNet.Graphics.Primitives.Box(new Point(x, y), size); dest.Draw(box, background, false, true); dest.Draw(box, border); }
public static Surface RenderHealthBar(int TotalHealth, int Health) { Surface Buffer = new Surface(HEALTHBAR_WIDTH, HEALTHBAR_HEIGHT); Buffer.Fill(Color.Red); int CurHealthWidth = (Buffer.Width * Health) / TotalHealth; Rectangle LifeRect = new Rectangle(new Point(0, 0), new Size(CurHealthWidth, HEALTHBAR_HEIGHT)); Buffer.Fill(LifeRect, Color.LimeGreen); Box Border = new Box(new Point(0, 0), new Size(Buffer.Width - 1, Buffer.Height - 1)); Buffer.Draw(Border, Color.Black, true); return Buffer; }
public static void DrawNpcBars(RendererDestinationData destData, Map map, Enums.MapID targetMapID, int npcSlot) { MapNpc npc = map.MapNpcs[npcSlot]; int x, y; if (npc != null && npc.HP > 0 && npc.Num > 0 && npc.ScreenActive) { if (npc.HP != npc.MaxHP) { //if (Npc.NpcHelper.Npcs[npc.Num].Big) { // x = (npc.Location.X * Constants.TILE_WIDTH - 9 + npc.Offset.X) - (Globals.NewMapX * Constants.TILE_WIDTH) - Globals.NewMapXOffset; // y = (npc.Location.Y * Constants.TILE_HEIGHT + npc.Offset.Y) - (Globals.NewMapY * Constants.TILE_HEIGHT) - Globals.NewMapYOffset; // Box hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + 50, destData.Location.Y + y + 36)); // destData.Draw(hpBox, Color.Black, false, true); // if (npc.MaxHP < 1) { // hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + ((npc.HP / 100) / ((npc.MaxHP + 1) / 100) * 50), destData.Location.Y + y + 36)); // } else { // double // hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + ((npc.HP / 100) / (double)((double)npc.MaxHP / 100) * 50)), destData.Location.Y + y + 36)); // } // destData.Draw(hpBox, Color.LightGreen, false, true); //} else { int npcX = npc.Location.X; int npcY = npc.Location.Y; Renderers.Maps.SeamlessWorldHelper.ConvertCoordinatesToBorderless(map, targetMapID, ref npcX, ref npcY); x = ScreenRenderer.ToTileX(npcX) + npc.Offset.X;//(npc.X * Constants.TILE_WIDTH + sx + npc.XOffset) - (Globals.NewMapX * Constants.TILE_WIDTH) - Globals.NewMapXOffset; y = ScreenRenderer.ToTileY(npcY) + npc.Offset.Y;//(npc.Y * Constants.TILE_HEIGHT + sx + npc.YOffset) - (Globals.NewMapY * Constants.TILE_HEIGHT) - Globals.NewMapYOffset; Box hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + 32, destData.Location.Y + y + 36)); destData.Draw(hpBox, Color.Black, false, true); if (npc.MaxHP < 1) { hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 32), new Point(destData.Location.X + x + 32, destData.Location.Y + y + 36)); } else { hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x + 1, destData.Location.Y + y + 33), new Point(Convert.ToInt32(destData.Location.X + x + (Logic.MathFunctions.CalculatePercent(npc.HP, npc.MaxHP) * 0.01) * 31), destData.Location.Y + y + 35)); } destData.Draw(hpBox, Color.LightGreen, false, true); //} } } }
public void Render(Surface sfc) { var equal = _pfields.Rank == _fields.Rank && Enumerable.Range(0, _pfields.Rank).All(dim => _pfields.GetLength(dim) == _fields.GetLength(dim)) && _pfields.Cast<bool>().SequenceEqual(_fields.Cast<bool>()); if (!Won && equal) { bWon = true; return; } var digitHeight = f.SizeText("10").Height; var digitWidth = f.SizeText("10").Width; sfc.Fill(Color.Black); _fwidth = ((sfc.Width - homeArea) / size); _fheight = ((sfc.Height - homeArea) / size); for (int i = 0; i < size && !Won; i++) { var col = (i % 5 == 0) ? Color.OrangeRed : Color.White; var x = (short)(homeArea + (i * _fwidth)); var y = (short)(homeArea + (i * _fheight)); var lh = new Line(x, 0, x, (short)sfc.Height); var lv = new Line(0, y, (short)sfc.Width, y); lh.Draw(sfc, col, true); lv.Draw(sfc, col, true); } var colcounts = new Dictionary<int, List<int>>(); var rowcounts = new Dictionary<int, List<int>>(); for (int col = 0; col < size; col++) { colcounts[col] = new List<int>(); bool counting = false; int count = 0; for (int row = 0; row < size; row++) { if (!counting && _fields[col, row]) counting = true; if (counting && !_fields[col, row]) { counting = false; colcounts[col].Add(count); count = 0; } if (counting && _fields[col, row]) count++; } if (counting) colcounts[col].Add(count); } for (int row = 0; row < size; row++) { rowcounts[row] = new List<int>(); bool counting = false; int count = 0; for (int col = 0; col < size; col++) { if (!counting && _fields[col, row]) counting = true; if (counting && !_fields[col, row]) { counting = false; rowcounts[row].Add(count); count = 0; } if (counting && _fields[col, row]) count++; } if (counting) rowcounts[row].Add(count); } for (int col = 0; col < size && !Won; col++) { var colc = colcounts[col]; for (int colcIdx = 0; colcIdx < colc.Count; colcIdx++) { var colcSfc = f.Render(String.Format("{0}", colc[colcIdx]), Color.White, true); sfc.Blit(colcSfc, new Rectangle(homeArea + col * _fwidth + 10, colcIdx * (digitHeight) + 3, digitWidth, digitHeight)); } } for (int row = 0; row < size && !Won; row++) { var rowc = rowcounts[row]; for (int rowcIdx = 0; rowcIdx < rowc.Count; rowcIdx++) { var rowcSfc = f.Render(String.Format("{0}", rowc[rowcIdx]), Color.White, true); sfc.Blit(rowcSfc, new Rectangle(rowcIdx * (digitWidth) + 3, homeArea + row * _fheight + 3, digitWidth, digitHeight)); } } for (int r = 0; r < size; r++) for (int c = 0; c < size; c++) { var x1 = c * _fwidth; var y1 = r * _fheight; if (_ufields[c, r] && !Won) { Line r1 = new Line((short)(x1 + homeArea), (short)(y1 + homeArea), (short)(x1 + _fwidth + homeArea), (short)(y1 + _fheight + homeArea)); Line r2 = new Line((short)(x1 + homeArea), (short)(y1 + _fheight + homeArea), (short)(x1 + _fwidth + homeArea), (short)(y1 + homeArea)); r1.Draw(sfc, Color.Tomato, true); r2.Draw(sfc, Color.Tomato, true); } else { var col = (_pfields[c, r]) ? ((_fields[c, r]) ? Color.Green : Color.Yellow) : Color.Black; var x = (short)((homeArea + x1) + 1); var y = (short)((homeArea + y1) + 1); Box b = new Box(x, y, (short)((x + _fwidth - 2)), (short)(y + _fheight - 2)); b.Draw(sfc, col, true, true); } } }
public override void Tick(object sender, TickEventArgs args) { //Game Logic Tick GameObj.GameTick(); //HUD Update LabelScore.Caption = "Score : " + GameObj.Score; LabelWave.Caption = "Wave : " + GameObj.Wave; LabelCrystal.Caption = "Crystals Left : " + GameObj.Crystal; LabelGold.Caption = "Gold : " + GameObj.Gold; LabelFps.Caption = "Fps : " + args.Fps; NextWaveBox.CurrentWave = GameObj.Wave - 1; CleanGarbage(); //Normal GUI Render foreach (GuiItem Item in Container) { Surface RenderedItem = RenderItem(Item); Screen.Blit(RenderedItem, Item.GetRect()); } //Game Graphics Render //Surface GameSurface = MapRender.Render(); Surface GameSurface = new Surface(MapBackground); //GameSurface.Blit(MapBackground, new Point(0, 0)); //Surface GameSurface = new Surface(MapRenderer.MAP_WIDTH_PX, MapRenderer.MAP_HEIGHT_PX); if (GameObj.State == GameState.CreepAttack) { isNewWave = true; Surface CreepsLayer = CreepRender.Render(GameObj.Creeps,GameObj.map); GameSurface.Blit(CreepsLayer, new Point(0, 0)); } else if (GameObj.State == GameState.NoAttack) { if (isNewWave) { LastAttackInfo = 0; isNewWave = false; WaveBox.Wave = GameObj.GetNextWaveInfo(); WaveBox.UpdateCaption(); CreepRender.Clean(); CreepRender = new CreepRenderer(CreepTextures.GetEntry(GameObj.CurrentWave.GfxName)); TopLevelContainer.Add(WaveBox); } if (UnitClassesChooserBox.ChoosenClass != UnitClasses.None) { if (GameRectangle.Contains(MousePos)) { Point relpoint = new Point(MousePos.X - GameStartP.X, MousePos.Y - GameStartP.Y); MapCoord Coord = new MapCoord(relpoint); PlayerUnit tmpUnit = PlayerUnit.CreateUnit(UnitClassesChooserBox.ChoosenClass); UnitInfoBox.ChangeUnit(tmpUnit); Surface UnitGfx = PlayerUnitRenderer.Render(tmpUnit); if (GameObj.map.Tiles[Coord.Row][Coord.Column].Type == TileType.Normal) { GameSurface.Blit(UnitGfx, new Rectangle(new Point(Coord.ToPoint().X + (Tile.TILE_WIDTH - UnitGfx.Width) / 2, Coord.ToPoint().Y + (Tile.TILE_HEIGHT - UnitGfx.Height) / 2), new Size(UnitGfx.Width, UnitGfx.Height))); DrawUnitRange(GameSurface, Coord, tmpUnit); } } } } else if (GameObj.State == GameState.GameOver && TopLevelContainer.Count == 0) { if (!AskedPlayerName) { PlayerNameDialog.TextEntry = PlayerName; TopLevelContainer.Add(PlayerNameDialog); PlayerNameDialog.SetEvents(); AskedPlayerName = true; } else { GameOverBox box = new GameOverBox(GameObj, Garbage); box.SetEvents(); box.X = (Width - box.Width) / 2; box.Y = (Height - box.Height) / 2; TopLevelContainer.Add(box); //Saving Score , must ask for name before GameObj.SaveScore(PlayerName); LastAttackInfo = 0; AskedPlayerName = false; } } else if (GameObj.State == GameState.Complete && TopLevelContainer.Count == 0) { if (!AskedPlayerName) { PlayerNameDialog.TextEntry = PlayerName; TopLevelContainer.Add(PlayerNameDialog); PlayerNameDialog.SetEvents(); AskedPlayerName = true; } else { GameCompleteBox box = new GameCompleteBox(GameObj, Garbage); box.SetEvents(); box.X = (Width - box.Width) / 2; box.Y = (Height - box.Height) / 2; TopLevelContainer.Add(box); //Saving Score , must ask for name before GameObj.SaveScore(PlayerName); LastAttackInfo = 0; AskedPlayerName = false; } } foreach (MapCoord Coord in GameObj.PlayerUnits.Keys) { Surface Unit = PlayerUnitRenderer.Render(GameObj.PlayerUnits[Coord]); Point Dest = new Point(Coord.ToPoint().X + ((Tile.TILE_WIDTH - Unit.Width) / 2), Coord.ToPoint().Y + ((Tile.TILE_HEIGHT - Unit.Height) / 2)); Rectangle Clip = new Rectangle(Dest, Unit.Size); GameSurface.Blit(Unit, Clip); if (!SelectedTile.isEmpty && Coord.SameCoord(SelectedTile)) { DrawUnitRange(GameSurface, Coord, GameObj.PlayerUnits[Coord]); } } if (!SelectedTile.isEmpty && GameObj.map.Tiles[SelectedTile.Row][SelectedTile.Column].Type == TileType.Normal) { Surface Sqr = new Surface(Tile.TILE_WIDTH, Tile.TILE_HEIGHT); Sqr.Alpha = 100; Sqr.AlphaBlending = true; Sqr.Fill(Color.LightBlue); Box Border = new Box(new Point(0, 0), new Size(Sqr.Width-1, Sqr.Height-1)); Sqr.Draw(Border, Color.Black); Rectangle Clip = new Rectangle(SelectedTile.ToPoint(), new Size(Tile.TILE_WIDTH, Tile.TILE_HEIGHT)); GameSurface.Blit(Sqr, Clip); } UpdateAttackSpriteCollection(); MageSprites.Update(args); if (GameObj.State == GameState.CreepAttack) { foreach (TextSprite Spr in CritSprites) { GameSurface.Blit(Spr, new Rectangle(Spr.Position, Spr.Size)); } foreach (MageAttackSprite Spr in MageSprites.Sprites) { GameSurface.Blit(Spr); } foreach (Projectile pro in GameObj.Projectiles) { Circle c = new Circle(pro.Position, 3); Circle d = new Circle(pro.Position, 2); GameSurface.Draw(c, Color.Blue); GameSurface.Draw(d, Color.BlueViolet); } } Screen.Blit(GameSurface, GameRectangle); //Top Level gui Render (Menu to Add Tower and Upgrade Tower) foreach (GuiItem Item in TopLevelContainer) { Surface RenderedItem = RenderItem(Item); Screen.Blit(RenderedItem, Item.GetRect()); } Screen.Update(); }
private void drawWave(Surface s, audio.PitchResult pitch, audio.ToneResult tone, SdlDotNet.Graphics.Font font, Rectangle rect) { if (pitch != null) { double dx = rect.Width / (double)pitch.Length; int width = rect.Width; int height = rect.Height; #region 波形用点列作成 double maxPower = double.MinValue; double maxCorrelation = double.MinValue; double minCorrelation = double.MaxValue; for (int i = 0; i < pitch.Length; i++) { if (maxPower < pitch.Power[i]) maxPower = pitch.Power[i]; if (maxCorrelation < pitch.Correlation[i]) maxCorrelation = pitch.Correlation[i]; if (minCorrelation > pitch.Correlation[i]) minCorrelation = pitch.Correlation[i]; } if (maxCorrelation > -minCorrelation) minCorrelation = -maxCorrelation; else maxCorrelation = -minCorrelation; List<Point> signal = new List<Point>(); List<Point> nsdf = new List<Point>(); List<Point> power = new List<Point>(); double x = rect.X; for (int i = 0; i < pitch.Length; i++) { signal.Add(new Point((int)x, (int)(rect.Bottom - rect.Height * (pitch.Signal[i] + 1) / 2.0))); // 入力波 nsdf.Add(new Point((int)x, (int)(rect.Bottom - rect.Height * (pitch.NSDF[i] + 1) / 2.0))); // NSDF power.Add(new Point((int)x, (int)(rect.Bottom - rect.Height * (pitch.Power[i] / (maxPower == 0 ? 1.0 : maxPower))))); // Power x += dx; } #endregion // 波形描画 drawLines(s, nsdf, _nsdfColor); drawLines(s, power, _powerColor); drawLines(s, signal, _signalColor); } // 枠 Box box = new Box(rect.Location, rect.Size); s.Draw(box, Constants.Color_Foreground, true, false); s.Draw(new Line( new Point(rect.X, rect.Top + (int)(rect.Height / 2.0)), new Point(rect.Right, rect.Top + (int)(rect.Height / 2.0))), Constants.Color_Foreground); }
private void Tick(object sender, TickEventArgs e) { while (times < MAXCOUNT) { circle = new Circle( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(20, 100)); surf.Draw(circle, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); circle = new Circle( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(20, 100)); surf.Draw(circle, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (times < MAXCOUNT) { ellipse = new Ellipse( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(20, 100), (short)rand.Next(20, 100)); surf.Draw(ellipse, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); ellipse = new Ellipse( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(20, 100), (short)rand.Next(20, 100)); surf.Draw(ellipse, Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (times < MAXCOUNT) { line = new Line( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(0, width), (short)rand.Next(0, height)); surf.Draw(line, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (times < MAXCOUNT) { triangle = new Triangle( (short)rand.Next(0, width / 2), (short)rand.Next(0, height / 2), (short)rand.Next(0, width / 2), (short)rand.Next(0, height / 2), (short)rand.Next(0, width / 2), (short)rand.Next(0, height / 2)); surf.Draw(triangle, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255) , rand.Next(255))); triangle = new Triangle( (short)rand.Next(0, width / 2), (short)rand.Next(0, height / 2), (short)rand.Next(0, width / 2), (short)rand.Next(0, height / 2), (short)rand.Next(0, width / 2), (short)rand.Next(0, height / 2)); surf.Draw(triangle, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (times < MAXCOUNT) { short[] x = { (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width) }; short[] y = { (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height) }; polygon = new Polygon(x, y); surf.Draw(polygon, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); short[] a = { (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width) }; short[] b = { (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height) }; polygon = new Polygon(a, b); surf.Draw(polygon, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); try { while (times < MAXCOUNT) { short[] x = { (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width) }; short[] y = { (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height) }; texturedPolygon = new TexturedPolygon(new Surface(file), x, y, 10, 10); surf.Draw(texturedPolygon, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); short[] a = { (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width) }; short[] b = { (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height) }; //short[] a = { // 0, 200, 200, 0 // }; //short[] b = { // 0, 0, 200, 200 // }; texturedPolygon = new TexturedPolygon(new Surface(file), a, b, 10, 20); surf.Draw(texturedPolygon, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } } catch (EntryPointNotFoundException ex) { Console.WriteLine("Using old version of SDL_gfx. Please upgrade to >=2.0.16"); Console.WriteLine(ex); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (times < MAXCOUNT) { pie = new Pie((short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(20, 100), (short)rand.Next(0, 360), (short)rand.Next(0, 360)); surf.Draw(pie, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); pie = new Pie((short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(20, 100), (short)rand.Next(0, 360), (short)rand.Next(0, 360)); surf.Draw(pie, Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (Events.Poll()) { // handle events till the queue is empty } while (times < MAXCOUNT) { short[] c = {(short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width)}; short[] d = {(short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height)}; bezier = new Bezier(c, d, 0); surf.Draw(bezier, Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (times < MAXCOUNT) { box = new Box( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(0, width), (short)rand.Next(0, height)); surf.Draw(box, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); box = new Box( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(0, width), (short)rand.Next(0, height)); surf.Draw(box, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); int xpixel; int ypixel; int rpixel; int gpixel; int bpixel; while (times < 100) { xpixel = rand.Next(10, width); ypixel = rand.Next(10, height); rpixel = rand.Next(255); gpixel = rand.Next(255); bpixel = rand.Next(255); surf.GetColorValue(Color.FromArgb(rpixel, gpixel, bpixel)); //colorValue = screen.MapColor(Color.FromArgb(254, 0, 0)); //screen.DrawPixel(x, y, Color.Red); //Console.WriteLine("colorValue: " + colorValue.ToString(CultureInfo.CurrentCulture)); surf.Draw(new Point(xpixel, ypixel), Color.FromArgb(rpixel, gpixel, bpixel)); //screen.DrawPixel(x, y, Color.Red); //Console.WriteLine("GetPixel: " + screen.GetPixel(xpixel, ypixel).ToString()); //Console.WriteLine("GetPixel: " + screen.GetColorValue(screen.GetPixel(xpixel, ypixel)).ToString(CultureInfo.CurrentCulture)); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); } }
public override Surface Render() { Surface Buffer = new Surface(Width, Height); Box line = new Box(new Point(0, 0), new Size(Width - 1, Height - 1)); Buffer.Transparent = true; Buffer.TransparentColor = Color.Magenta; Buffer.Fill(Color.Magenta); Buffer.Draw(line, Color.Snow); for (int i=0; i<Items.Count; i++) { Surface ibff; if (SelectedIndex == i) { ibff = Items[i].RenderHighlight(); Buffer.Blit(ibff, Items[i].GetRect()); } else { ibff = Items[i].Render(); Buffer.Blit(ibff, Items[i].GetRect()); } } return Buffer; }
public static void DrawSpriteHPBar(RendererDestinationData destData, ISprite sprite, int hp, int maxHP) { int x = 0; int y = 0; x = ScreenRenderer.ToTileX(sprite.Location.X) + sprite.Offset.X; y = ScreenRenderer.ToTileY(sprite.Location.Y) + sprite.Offset.Y; //if (sprite == ScreenRenderer.Camera.FocusedSprite) { // x = ScreenRenderer.NewX; // y = ScreenRenderer.NewY; //} else { //} //if (MaxInfo.SpriteSize == 0) { // Box hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(x, y + 32), new Point(x + 50, y + 36)); // destSurf.Draw(hpBox, Color.Black, false, true); // if (maxHP < 1) { // hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(x, y + 32), new Point(x + ((hp / 100) / ((maxHP + 1) / 100) * 50), y + 36)); // } else { // hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(x, y + 32), new Point(x + ((hp / 100) / (maxHP / 100) * 50), y + 36)); // } // destSurf.Draw(hpBox, Color.LightGreen, false, true); //} else { Box hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x, destData.Location.Y + y + 36), new Point(destData.Location.X + x + 32, destData.Location.Y + y + 40)); destData.Draw(hpBox, Color.Black, false, true); if (maxHP > 0) { hpBox = new SdlDotNet.Graphics.Primitives.Box(new Point(destData.Location.X + x + 1, destData.Location.Y + y + 37), new Point(Convert.ToInt32(destData.Location.X + x + (Logic.MathFunctions.CalculatePercent(hp, maxHP) * 0.01) * 31), destData.Location.Y + y + 39)); } destData.Draw(hpBox, Color.LightGreen, false, true); //} }
void Events_KeyboardDown(object sender, SdlDotNet.Input.KeyboardEventArgs e) { if (startMenu == true)//Mag het startlenu getoont worden { if (e.Key == SdlDotNet.Input.Key.UpArrow)//freemode Up { if (beweeg.Y > 450) beweeg.Y -= 50; selctieboxje = new Box(beweeg, new Size(750, 50)); } if (e.Key == SdlDotNet.Input.Key.DownArrow) //Down { if (beweeg.Y < 550) beweeg.Y += 50; selctieboxje = new Box(beweeg, new Size(750, 50)); } } if (levela == true) //kan het twede startscherm getoond worden { if (e.Key == SdlDotNet.Input.Key.UpArrow)//freemode Up { if (levela == true) if (textvalue < 250) textvalue += 50; } if (e.Key == SdlDotNet.Input.Key.DownArrow) //Down { if (levela == true) if (textvalue > 100) textvalue -= 50; } } if(e.Key == SdlDotNet.Input.Key.Escape) { if ((Remaining.TotalMilliseconds <= 0 || speler.Levens <= 0) && end == true) { play.StopMusic(); esc = true; Events.QuitApplication(); PlayBoem = true; PlayYha = true; } if(col.GameEnd || Cheater.Enough) { speler = new Player(); level = new Level(); gameObjecten = new List<GameObject>(); col = new CollisionDetection(); removeDirt = new RemoveDirt(); gameObjecten.Add(speler); laad = new LoadLevel(); CreerLevens(); levela = true; Level1 = false; Level2= false; PlayBoem = true; PlayYha = true; kleur = Color.Green; } } if(e.Key==SdlDotNet.Input.Key.F1) { Cheater.CheatBaar = true; } if (e.Key == SdlDotNet.Input.Key.Return) { if (startMenu ==true) { if (beweeg.Y == 550) { Events.QuitApplication(); } else if (beweeg.Y == 500) { levela = true; startMenu = false; go = false; } else if (beweeg.Y == 450) { laad.LevelFile = "Level.txt"; initialize(); Free = true; end = true; go = false; } } if(levela == true) { if(textvalue == 100) { Events.QuitApplication(); } else if(textvalue ==150) { levela = false; Free = false; beweeg.Y = 450; textvalue = 250; startMenu = true; go = false; } else if(textvalue ==200) { laad.LevelFile = "Level2.txt"; initialize(); Time = DateTime.Now; Level2 = true; levela = false; end = true; } else if(textvalue == 250 && go ==true) { laad.LevelFile = "Level1.txt"; initialize(); Time = DateTime.Now; end = true; Level1 = true; levela = false; } go = true; } } }
public override Surface Render() { Surface Buffer = new Surface(Width, Height); Buffer.Blit(Background.Render(), Background.GetRect()); Buffer.Blit(BoxTitle.Render(), BoxTitle.GetRect()); int j = 0; for (int i = CurrentWave; i < WaveList.Wave.Count; i++) { if (j == 5) { break; } XmlCreepWave wave = WaveList.Wave[i]; //Surface label = DefaultStyle.GetFont().Render(wave.Name,Color.Black); //Point p = new Point((Width - label.Width) / 2, (j * INFOBOX_HEIGHT) + 20); if (j == 0) { Rectangle bg = new Rectangle(new Point(10, (j * INFOBOX_HEIGHT) + 20), new Size(Width - 20, INFOBOX_HEIGHT - 10)); Buffer.Fill(bg, Color.LightYellow); } Box Border = new Box(new Point(10,(j*INFOBOX_HEIGHT) + 20),new Size(Width - 20, INFOBOX_HEIGHT - 10)); Surface CreepGfx = WavesGfx[i]; Rectangle GfxRect = new Rectangle(new Point((Width - CreepGfx.Width) / 2, (j * INFOBOX_HEIGHT) + 25), CreepGfx.Size); Surface HealthLabel = DefaultStyle.GetFont().Render("Health : " + wave.Health, Color.Black); Point HealthP = new Point((Width - HealthLabel.Width) / 2, (j * INFOBOX_HEIGHT) + 55); Surface WeaknessLabel = DefaultStyle.GetFont().Render("Weakness : " + UnitDmg.GetDamageType(wave.Weakness), Color.Black); Point WeaknessP = new Point((Width - WeaknessLabel.Width) / 2, (j * INFOBOX_HEIGHT) + 70); Surface ResistLabel = DefaultStyle.GetFont().Render("Resist : " + UnitDmg.GetDamageType(wave.Resist), Color.Black); Point ResistP = new Point((Width - ResistLabel.Width) / 2, (j * INFOBOX_HEIGHT) + 85); Surface creepsNb = DefaultStyle.GetBoldFont().Render("x" + wave.Numbers, Color.OrangeRed); Point creepsNbP = new Point(GfxRect.X + GfxRect.Width + 5, (j * INFOBOX_HEIGHT) + 35); if (wave.StealAmount != 1) { Surface stealLabel = DefaultStyle.GetFont().Render("Steal Multiple Crystal", Color.Red); Point stealP = new Point((Width - stealLabel.Width) / 2, (j * INFOBOX_HEIGHT) + 100); Buffer.Blit(stealLabel, stealP); } else if (wave.Speed != 1) { Surface speedLabel = DefaultStyle.GetFont().Render("Moving Faster", Color.Red); Point speedP = new Point((Width - speedLabel.Width) / 2, (j * INFOBOX_HEIGHT) + 100); Buffer.Blit(speedLabel, speedP); } Buffer.Blit(CreepGfx, GfxRect); Buffer.Blit(HealthLabel, HealthP); Buffer.Blit(WeaknessLabel, WeaknessP); Buffer.Blit(ResistLabel, ResistP); Buffer.Blit(creepsNb, creepsNbP); Buffer.Draw(Border, Color.Black); j++; } return Buffer; }
protected virtual void renderKeyboard(Surface s) { if (_keyboardSurface == null) { _keyboardSurface = new Surface(_keyRect.Size); foreach (KeyValuePair<Rectangle, string> kv in _whiteKeys) { Box box = new Box(kv.Key.Location, kv.Key.Size); _keyboardSurface.Draw(box, _backColor, true, true); _keyboardSurface.Draw(box, _foreColor, true, false); } foreach (KeyValuePair<Rectangle, string> kv in _blackKeys) { Box box = new Box(kv.Key.Location, kv.Key.Size); _keyboardSurface.Draw(box, _foreColor, true, true); } } s.Blit(_keyboardSurface, _keyRect.Location); bool black = false; Rectangle cr = Rectangle.Empty; foreach (KeyValuePair<Rectangle, string> kv in _blackKeys) { if (kv.Key.Top <= _parent.Player.Y - _view.Y && _parent.Player.Y - _view.Y <= kv.Key.Bottom) { cr = new Rectangle(kv.Key.Location, kv.Key.Size); black = true; break; } } if (!black) { foreach (KeyValuePair<Rectangle, string> kv in _whiteKeys) { if (kv.Key.Top <= _parent.Player.Y - _view.Y && _parent.Player.Y - _view.Y <= kv.Key.Bottom) { cr = new Rectangle(kv.Key.Location, kv.Key.Size); break; } } } if (!cr.IsEmpty) { cr.Offset(_keyRect.Location); Circle cir = new Circle(new Point(cr.Right - 22, (int)(cr.Y + cr.Height / 2.0)), 10); s.Draw(cir, _strongColor, true, true); s.Draw(cir, _strongColor, true, false); } }