using DxVBLib命名空间是什么意思
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
// 添加新的命名空间。
using DxVBLib;
namespace DirectDraw1
{
/// <summary>
/// DirectDraw实例:显示图片。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码。
//
DirectX = new DirectX7();
InitializeDirectX();
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(440, 320);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(440, 320);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "显示图片";
this.Resize += new System.EventHandler(this.Form1_Resize);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private DirectX7 DirectX = null;
private DirectDraw7 DirectDraw = null;
private DirectDrawSurface7 Surface = null;
private DirectDrawSurface7 PrimarySurface = null;
private DDSURFACEDESC2 Surface1;
private DDSURFACEDESC2 Surface2;
private DirectDrawClipper Clipper = null;
private Boolean bInit;
private void Blt()
{
// 判断是否初始化成功。
if (bInit == false)
return;
DxVBLib.RECT r1 = new DxVBLib.RECT();
DxVBLib.RECT r2 = new DxVBLib.RECT();
// 得到窗口边界大小。
DirectX.GetWindowRect(panel1.Handle.ToInt32(), ref r1);
// 按照新的边界大小显示图片。
r2.Bottom = Surface2.lHeight;
r2.Right = Surface2.lWidth;
PrimarySurface.Blt(ref r1, Surface, ref r2, CONST_DDBLTFLAGS.DDBLT_WAIT);
}
private void InitializeDirectX()
{
// 初始化各个变量。
DirectDraw = DirectX.DirectDrawCreate("");
DirectDraw.SetCooperativeLevel(this.Handle.ToInt32(), CONST_DDSCLFLAGS.DDSCL_NORMAL);
Surface1.lFlags = CONST_DDSURFACEDESCFLAGS.DDSD_CAPS;
Surface1.ddsCaps.lCaps = CONST_DDSURFACECAPSFLAGS.DDSCAPS_PRIMARYSURFACE;
PrimarySurface = DirectDraw.CreateSurface(ref Surface1);
Surface2.lFlags = CONST_DDSURFACEDESCFLAGS.DDSD_CAPS;
Surface2.ddsCaps.lCaps = CONST_DDSURFACECAPSFLAGS.DDSCAPS_OFFSCREENPLAIN;
try
{
Surface = DirectDraw.CreateSurfaceFromFile("sample.bmp", ref Surface2); //background.bmp
}
catch(System.Runtime.InteropServices.COMException e)
{
// 没有找到文件。
if ( (uint)e.ErrorCode == 0x800A0035)
{
MessageBox.Show("没有找到文件'sample.bmp'.\n该文件必须和程序放在一个目录下面。", "图片没有找到");
}
else
{
MessageBox.Show("异常: " + e.ToString(), "异常信息");
}
Application.Exit();
Application.DoEvents();
}
Clipper = DirectDraw.CreateClipper(0);
Clipper.SetHWnd(panel1.Handle.ToInt32());
PrimarySurface.SetClipper(Clipper);
// 初始化完成。
bInit = true;
Blt();
}
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
DirectDraw.RestoreAllSurfaces();
Blt();
}
private void Form1_Resize(object sender, System.EventArgs e)
{
panel1.Width = this.ClientSize.Width;
panel1.Height = this.ClientSize.Height;
Blt();
}
}
}
这个命名是什么.为什么我在连机帮助中找不到啊.
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
// 添加新的命名空间。
using DxVBLib;
namespace DirectDraw1
{
/// <summary>
/// DirectDraw实例:显示图片。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码。
//
DirectX = new DirectX7();
InitializeDirectX();
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(440, 320);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(440, 320);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "显示图片";
this.Resize += new System.EventHandler(this.Form1_Resize);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private DirectX7 DirectX = null;
private DirectDraw7 DirectDraw = null;
private DirectDrawSurface7 Surface = null;
private DirectDrawSurface7 PrimarySurface = null;
private DDSURFACEDESC2 Surface1;
private DDSURFACEDESC2 Surface2;
private DirectDrawClipper Clipper = null;
private Boolean bInit;
private void Blt()
{
// 判断是否初始化成功。
if (bInit == false)
return;
DxVBLib.RECT r1 = new DxVBLib.RECT();
DxVBLib.RECT r2 = new DxVBLib.RECT();
// 得到窗口边界大小。
DirectX.GetWindowRect(panel1.Handle.ToInt32(), ref r1);
// 按照新的边界大小显示图片。
r2.Bottom = Surface2.lHeight;
r2.Right = Surface2.lWidth;
PrimarySurface.Blt(ref r1, Surface, ref r2, CONST_DDBLTFLAGS.DDBLT_WAIT);
}
private void InitializeDirectX()
{
// 初始化各个变量。
DirectDraw = DirectX.DirectDrawCreate("");
DirectDraw.SetCooperativeLevel(this.Handle.ToInt32(), CONST_DDSCLFLAGS.DDSCL_NORMAL);
Surface1.lFlags = CONST_DDSURFACEDESCFLAGS.DDSD_CAPS;
Surface1.ddsCaps.lCaps = CONST_DDSURFACECAPSFLAGS.DDSCAPS_PRIMARYSURFACE;
PrimarySurface = DirectDraw.CreateSurface(ref Surface1);
Surface2.lFlags = CONST_DDSURFACEDESCFLAGS.DDSD_CAPS;
Surface2.ddsCaps.lCaps = CONST_DDSURFACECAPSFLAGS.DDSCAPS_OFFSCREENPLAIN;
try
{
Surface = DirectDraw.CreateSurfaceFromFile("sample.bmp", ref Surface2); //background.bmp
}
catch(System.Runtime.InteropServices.COMException e)
{
// 没有找到文件。
if ( (uint)e.ErrorCode == 0x800A0035)
{
MessageBox.Show("没有找到文件'sample.bmp'.\n该文件必须和程序放在一个目录下面。", "图片没有找到");
}
else
{
MessageBox.Show("异常: " + e.ToString(), "异常信息");
}
Application.Exit();
Application.DoEvents();
}
Clipper = DirectDraw.CreateClipper(0);
Clipper.SetHWnd(panel1.Handle.ToInt32());
PrimarySurface.SetClipper(Clipper);
// 初始化完成。
bInit = true;
Blt();
}
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
DirectDraw.RestoreAllSurfaces();
Blt();
}
private void Form1_Resize(object sender, System.EventArgs e)
{
panel1.Width = this.ClientSize.Width;
panel1.Height = this.ClientSize.Height;
Blt();
}
}
}
这个命名是什么.为什么我在连机帮助中找不到啊.
...全文
相关推荐
DxVBLib C# 源码
这是微软DirectX7的C#源码。爱好游戏开发的朋友和想了解C#底层以及硬件开发的朋友可以下了去看看。此源码我在VS2002上编译通过,经测试完全可用。!
2022年用VB.NET实现你的游戏梦想Java教程.docx
2022年用VB.NET实现你的游戏梦想Java教程.docx
C# DX 编程-0f9b10b165ce0508763213ed.doc
C# DX 编程-0f9b10b165ce0508763213ed.doc
深入了解DirectDraw的编程实践
本篇博客将探讨DirectDraw在游戏编程中的应用,通过分析书中章节关于DirectDrawSurface7对象和clsDDSprite7类的代码,深入理解如何在DirectX中处理图形和精灵对象。我们将详细讨论DirectDraw表面创建、位图加载、透明度设置及精灵类的初始化和属性管理,揭示如何提高图形渲染效率。
打造多玩家太空战斗游戏 Stellar War 的技术要点
本文主要介绍了在开发多玩家太空战斗游戏Stellar War时的技术要点。文中详细阐述了如何通过Visual Basic结合DirectX库(包括DirectDraw和DirectInput8)以及DirectX7和DirectX8的共同引用,解决因共用结构体如RECT而产生的编译错误问题。此外,还提供了一段实际的客户端源代码,包括了游戏设置的加载、DirectDraw对象的初始化以及游戏窗口的创建等关键步骤。通过代码片段,我们可以了解到游戏开发过程中对多种游戏编程技术的综合运用。


