无聊 画个地图
好无聊啊 画个地图 看qq堂的地图好炫啊 所以参照(功夫) 地图自己也用GDI+画个功夫1 首先截取图片
(还有几个限于附件上传个数)
以一个图片为一个类 比方说石头
程序代码:
class Stone { public Point Position; static Bitmap StoneImage = null; public Stone() { // // TODO: Add constructor logic here // Position.X = 0; Position.Y = 0; if (StoneImage == null) { string fname = "box09.png"; StoneImage = new Bitmap(fname); } } public Stone(int x, int y) { // // TODO: Add constructor logic here // Position.X = x; Position.Y = y; if (StoneImage == null) { StoneImage = new Bitmap("box09.png"); } } public Rectangle GetFrame() { Rectangle myRect = new Rectangle(Position.X, Position.Y, StoneImage.Width, StoneImage.Height); return myRect; } public void Draw(Graphics g) { Rectangle destR = new Rectangle(Position.X, Position.Y, StoneImage.Width, StoneImage.Height); Rectangle srcR = new Rectangle(0, 0, StoneImage.Width, StoneImage.Height); g.DrawImage(StoneImage, destR, srcR, GraphicsUnit.Pixel); } } ArrayList gongfu1 = new ArrayList(10); private void Initializegongfu2() { Point P = new Point(); { P.X = 144; P.Y = 15; Stone _stone = new Stone(P.X, P.Y); gongfu1.Add(stone); } } 然后在窗体paint中绘制 石头 private void gongfu_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; TheTimer.Draw(g, TheSeconds); for (int i = 0; i < gongfu1.Count; i++) { ((Stone )Stone[i]).Draw(g); } }最后在窗体构造函数调用这个方法Initializegongfu2();就可以显示画好的石头了 呵呵 很有趣吧