public void Draw_CollisionMap() { RectangleF r; GL.Disable(EnableCap.Texture2D); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); Reset_Matrix_GL(); GL.Color4(1f, 0f, 0f, 1f); foreach (KeyValuePair <Point, StageCollisionTile> tile in stage.CollisionMap) { if (tile.Value.Active) { GL.Color4(1f, 0f, 0f, 1f); } else { GL.Color4(0f, 1f, 0f, 1f); } r = new RectangleF(tile.Key.X * 16 - ScreenScroll.X, tile.Key.Y * 16 - ScreenScroll.Y, 16, 16); GL.Begin(PrimitiveType.Quads); //Top left, Top right, Bottom right, Bottom left GL.Vertex2(r.X, r.Y + 16 - tile.Value.HeightLeft); GL.Vertex2(r.Right, r.Y + 16 - tile.Value.HeightRight); GL.Vertex2(r.Right, r.Bottom); GL.Vertex2(r.X, r.Bottom); GL.End(); } r = Host_Navi.Navi_Location(); r.X -= ScreenScroll.X; r.Y -= ScreenScroll.Y; GL.Begin(PrimitiveType.Quads); //Top left, Top right, Bottom right, Bottom left GL.Vertex2(r.X, r.Y); GL.Vertex2(r.Right, r.Y); GL.Vertex2(r.Right, r.Bottom); GL.Vertex2(r.X, r.Bottom); GL.End(); GL.Enable(EnableCap.Texture2D); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); }
public void Draw_Navi() { if (GLOn == false) { if (!(Host_Navi.Sprite == Host_Navi.OldSprite) || !(Host_Navi.FaceLeft == Host_Navi.OldFaceLeft)) { NaviForm.Invalidate(); Host_Navi.OldSprite = Host_Navi.Sprite; Host_Navi.OldFaceLeft = Host_Navi.FaceLeft; } } if (GLOn == true) { if (Init_GL == false) { Start_GL(); } ScreenScroll.X = Host_Navi.Location.X + Host_Navi.GetSize().X / 2 - ScreenSize.Width / 2; ScreenScroll.Y = Host_Navi.Location.Y + Host_Navi.GetSize().Y / 2 - ScreenSize.Height / 2; SizeF screenBounds = new SizeF(0 - (ScreenSize.Width - (ScreenSize.Width / ScreenZoom)) / 2, 0 - (ScreenSize.Height - (ScreenSize.Height / ScreenZoom)) / 2); SizeF stageBounds = new SizeF(0 - (stage.Bounds.Width - (stage.Bounds.Width / ScreenZoom)) / 2, 0 - (stage.Bounds.Height - (stage.Bounds.Height / ScreenZoom)) / 2); if (ScreenScroll.X + ScreenSize.Width > stage.Bounds.Width - screenBounds.Width) { ScreenScroll.X = stage.Bounds.Width - (ScreenSize.Width + screenBounds.Width); } if (ScreenScroll.X < screenBounds.Width) { ScreenScroll.X = screenBounds.Width; } if (ScreenScroll.Y < screenBounds.Height) { ScreenScroll.Y = screenBounds.Height; } if (ScreenScroll.Y + ScreenSize.Height > stage.Bounds.Height - screenBounds.Height) { ScreenScroll.Y = stage.Bounds.Height - (ScreenSize.Height + screenBounds.Height); } Draw_GL(); } }
public void Draw_Navi_GDI(object sender, System.Windows.Forms.PaintEventArgs e) { NaviForm.Width = Convert.ToInt32(Host_Navi.GetSize().X); NaviForm.Height = Convert.ToInt32(Host_Navi.GetSize().Y); e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; float xoff = 0; float yoff = 0; xoff = Convert.ToSingle(-0.5 + 0.5 * Host_Navi.SpriteSize.X / Host_Navi.GetSize().X) + Host_Navi.SpriteSize.X * Host_Navi.Sprite.X; yoff = Convert.ToSingle(-0.5 + 0.5 * Host_Navi.SpriteSize.Y / Host_Navi.GetSize().Y) + Host_Navi.SpriteSize.Y * Host_Navi.Sprite.Y; if (Host_Navi.FaceLeft == true) { e.Graphics.DrawImage(Host_Navi.SpriteSheet, new Rectangle(Convert.ToInt32(Host_Navi.GetSize().X), 0, Convert.ToInt32(-Host_Navi.GetSize().X - 1), Convert.ToInt32(Host_Navi.GetSize().Y)), xoff, yoff, Host_Navi.SpriteSize.X, Host_Navi.SpriteSize.Y, GraphicsUnit.Pixel, NormalImage); } else { e.Graphics.DrawImage(Host_Navi.SpriteSheet, new Rectangle(0, 0, Convert.ToInt32(Host_Navi.GetSize().X), Convert.ToInt32(Host_Navi.GetSize().Y)), xoff, yoff, Host_Navi.SpriteSize.X, Host_Navi.SpriteSize.Y, GraphicsUnit.Pixel, NormalImage); } }