那位朋友帮我处理一下有关游戏的地图(如:ra2红警)
问题:
1.想ra2红警那样地图随鼠标的不同位置而变化,同时游戏的浏览窗用矩形显示当前位置。
2.怎样解决如采矿车采矿在地图上处理,即动态变化显示地图的处理。
email:[email protected] 如那位高手解决的好可再追加分
问题:
1.想ra2红警那样地图随鼠标的不同位置而变化,同时游戏的浏览窗用矩形显示当前位置。
2.怎样解决如采矿车采矿在地图上处理,即动态变化显示地图的处理。
email:[email protected] 如那位高手解决的好可再追加分
解决方案 »
- .NET动态配置控件逻辑
- 算法对程序员的重要性
- 急!!c#将控制台动态输入的一组学生数据存储到数组student中怎么实现
- 为什么我获取不到存储过程里的output参数(有代码)
- 向高手请教gridview控件问题
- 各位高手,我是一个出学者,现在学到c#面向Windows那一块了,可是学的前边的知识,如继承,多态,接口等
- 如何在textmode=multiline的textbox控件中控制用户的输入长度?
- DataGridView的问题
- 下面是一个pop3接收类的一个方法。老外的。接收回来的是乱马。如何用中文编码。谢谢
- 请教各位前辈有关WPF相关问题,谢谢!!
- 数据库本地备份可以,怎么异地备份不行,代码如下,请高手指点?
- c#中怎样调用dll中的函数
以下代码要说明的是:
首先,maxPanel与controlPanel的比例是5:1
其次,minPanel与原图片的比例是1:5以下是代码部分:using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Diagnostics;
namespace WindowsApplication4
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel maxPanel;
private System.Windows.Forms.Panel minPanel;
private System.Windows.Forms.Panel controlframe;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private Point mousePosition=new Point(0,0); public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.maxPanel = new System.Windows.Forms.Panel();
this.minPanel = new System.Windows.Forms.Panel();
this.controlframe = new System.Windows.Forms.Panel();
this.minPanel.SuspendLayout();
this.SuspendLayout();
//
// maxPanel
//
this.maxPanel.Location = new System.Drawing.Point(16, 0);
this.maxPanel.Name = "maxPanel";
this.maxPanel.Size = new System.Drawing.Size(500, 400);
this.maxPanel.TabIndex = 0;
//
// minPanel
//
this.minPanel.Controls.Add(this.controlframe);
this.minPanel.Location = new System.Drawing.Point(544, 8);
this.minPanel.Name = "minPanel";
this.minPanel.Size = new System.Drawing.Size(262, 350);
this.minPanel.TabIndex = 1;
this.minPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.minPanel_Paint);
this.minPanel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.minPanel_MouseDown);
//
// controlframe
//
this.controlframe.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.controlframe.Location = new System.Drawing.Point(48, 72);
this.controlframe.Name = "controlframe";
this.controlframe.Size = new System.Drawing.Size(50, 40);
this.controlframe.TabIndex = 0;
this.controlframe.MouseUp += new System.Windows.Forms.MouseEventHandler(this.controlframe_MouseUp);
this.controlframe.Paint += new System.Windows.Forms.PaintEventHandler(this.controlframe_Paint);
this.controlframe.MouseMove += new System.Windows.Forms.MouseEventHandler(this.controlframe_MouseMove);
this.controlframe.MouseDown += new System.Windows.Forms.MouseEventHandler(this.controlframe_MouseDown);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(824, 485);
this.Controls.Add(this.minPanel);
this.Controls.Add(this.maxPanel);
this.Name = "Form1";
this.minPanel.ResumeLayout(false);
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void minPanel_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g=this.minPanel.CreateGraphics();
Image img=Image.FromFile(Application.StartupPath+@"\girl.tif");
g.DrawImage(img,this.minPanel.ClientRectangle,0,0,img.Width,img.Height,System.Drawing.GraphicsUnit.Pixel);
} private void controlframe_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
DrawSmall();
} private void DrawSmall()
{
Graphics g=this.controlframe.CreateGraphics();
Bitmap bmp=new Bitmap((Bitmap)Bitmap.FromFile(Application.StartupPath+@"\girl.tif"),new Size(this.minPanel.Width,this.minPanel.Height));
g.DrawImage(bmp,this.controlframe.ClientRectangle,this.controlframe.Left,this.controlframe.Top,this.controlframe.ClientRectangle.Width,this.controlframe.ClientRectangle.Height,System.Drawing.GraphicsUnit.Pixel);
g.Dispose();
this.controlframe.Update();
} private void DrawBig()
{
Graphics g=this.maxPanel.CreateGraphics();
Image img=Image.FromFile(Application.StartupPath+@"\girl.tif");
g.DrawImage(img,this.maxPanel.ClientRectangle,this.controlframe.Left*4,this.controlframe.Top*4,this.maxPanel.ClientRectangle.Width,this.maxPanel.ClientRectangle.Height,System.Drawing.GraphicsUnit.Pixel);
g.Dispose();
this.minPanel.Update();
} private void controlframe_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
this.mousePosition.X = this.controlframe.Left;
this.mousePosition.Y =this.controlframe.Top;
this.DrawSmall();
DrawBig();
}
} private void controlframe_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
if (e.X>=0 && e.X<=this.minPanel.ClientRectangle.Width && e.Y>=0 && e.Y<=this.minPanel.ClientRectangle.Height)
{
this.controlframe.Left=e.X+this.mousePosition.X;
this.controlframe.Top=e.Y+this.mousePosition.Y;
DrawSmall();
DrawBig();
}
}
} private void controlframe_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
DrawSmall();
DrawBig();
} private void minPanel_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.controlframe.Left=e.X;
this.controlframe.Top=e.Y;
DrawBig();
DrawSmall();
}
}
}
真的很牛B啊