欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    2022年C#游戏开发教程--指引如何开发最好的游戏 .pdf

    • 资源ID:32497364       资源大小:74.19KB        全文页数:13页
    • 资源格式: PDF        下载积分:4.3金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要4.3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    2022年C#游戏开发教程--指引如何开发最好的游戏 .pdf

    C游戏开发教程-指引如何开发最好的游戏本文适合有一定编程基础的爱好者!本文不会涉及基本的语法等内容,本文适合所有游戏开发初学者,本文从 Microsoft DirectX 9.0 SDK (Summer 2004)中的 D3D 下 Tutorials 文件夹下的例子开始! !关键字: c游戏开发3D教程C#(读作“ C sharp” )是一种简单、现代、面向对象且类型安全的编程语言。C 和 C+ 程序员能很快熟悉它。C# 同时具备“应用程序快速开发”(RAD) 语言的高效率和C+ 固有的强大能力。 (c语言标准参考如是说)废话少说,进入主题,开始我们的c游戏开发之旅! (翻译有误请多原谅)第一章组建我们的设备1。建立一个DX 程序,首先你需要下载Microsoft DirectXSDK( 最好事 9.0 一下简称DX ) ,安装。然后事要保证你安装了Visual Studio .NET开发产品套件(一下简称) ,这是最小环境,然后你就可以进行游戏开发了。建立一个 DX 设备。打开DX 中的 Tutorials 文件夹下的Tutorials1 例子并打开编译!下面是运行结果:创建了一个DX 窗口!下面是代码:/- / File: CreateDevice.cs / 创建设备/ Desc: This is the first tutorial for using Direct3D. In this tutorial, all /we are doing is creating a Direct3D device and using it to clear the /window. / 注释:这是第一个使用D3D 的教学例子,在这个例子中,我们要作的仅仅是创建以个 D3D “设备”和刷新窗口/ Copyright (c) Microsoft Corporation. All rights reserved. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 13 页 - - - - - - - - - /- using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace DeviceTutorial public class CreateDevice : Form / Our global variables for this project Device device = null; / Our rendering device /我们的绘图设备public CreateDevice() / Set the initial size of our form /设置窗体的初始值this.ClientSize = new System.Drawing.Size(400,300); / And its caption /设置窗体标题this.Text = D3D Tutorial 01: CreateDevice; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 13 页 - - - - - - - - - public bool InitializeGraphics() try / Now lets setup our D3D stuff /现在我们设置D3D 的一些选项PresentParameters presentParams = new PresentParameters(); presentParams.Windowed=true;/标志着程序运行时窗口模式presentParams.SwapEffect = SwapEffect.Discard;/ 返回或设置交换区选项? device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams); /?,设备的类型 (这里选择了硬件),创建图形设备的窗体,创建类型,创建实体);/创建设备实例return true; catch (DirectXException)/ 捕捉 DX 异常 return false; private void Render()/ 刷新模块名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 13 页 - - - - - - - - - if (device = null) return; /Clear the backbuffer to a blue color /将设备窗口刷成绿色device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0); /clear(刷屏的参数这里选的是目标,使用的颜色,深度(可能用于模板),模板( 0)因为没有使用模板)/Begin the scene /开始渲染场景, (因为没有场景所以一下句是空的就直接结束了场景的渲染)device.BeginScene(); / Rendering of scene objects can happen here /可以在这里渲染场景/End the scene /结束场景的渲染device.EndScene(); device.Present(); protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)/重写 OnPaint方法 /this.Render(); / Render on painting /循环的刷新窗口名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 13 页 - - - - - - - - - protected override void _disibledevent(System.Windows.Forms.KeyPressEventArgs e)/重写OnKeyPress 方法 if (int)(byte)e.KeyChar = (int)System.Windows.Forms.Keys.Escape) this.Close(); / Esc was pressed /如果按下了ESC 则退出程序 / / The main entry point for the application. / 程序的主函数,入口点/ static void Main() /使用 USING 语句创建对象保证对象的销毁using (CreateDevice frm = new CreateDevice() if (!frm.InitializeGraphics() / Initialize Direct3D MessageBox.Show(Could not initialize Direct3D.This tutorial will exit.); return; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 13 页 - - - - - - - - - frm.Show(); / While the form is still valid, render and process messages /消息循环while(frm.Created) frm.Render(); Application.DoEvents(); 代码中有加入的注释!首先是:using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; 使用命 3 名空间!注意的是,在程序的Main 主程序中使也用了USING ,注意这是c中的一条语句,using 语句定义一个范围,在此范围的末尾将处理对象。名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 13 页 - - - - - - - - - 接着 Device device = null;这句是申请了Device 类的对象device 但并未创建实例对象,实例对象的创建必须使用new 语句创建。 public bool InitializeGraphics() 函数的作用是初始化 DX ,private void Render() 函数是渲染函数,其中的device.BeginScene(); 是开始渲染,device.EndScene(); device.Present(); 结束渲染,就如同翻页!可以在BeginScene();和 EndScene();函数之中添加图像的显示或文字的显示等其它工作!程序最后的while(frm.Created) frm.Render(); Application.DoEvents(); 是检测程序是否在执行,是则使用frm实例对象的方法Render();来渲染屏幕,Application.DoEvents(); 是执行消息循环!这样!一个简单的DX 窗口就建立好了!说明:本信息本文适合有一定编程基础的爱好者!本文不会涉及基本的语法等内容,本文适合所有游戏开发初学者,本文从 Microsoft DirectX 9.0 SDK (Summer 2004)中的 D3D 下 Tutorials 文件夹下的例子开始! !关键字: c游戏开发3D教程C#(读作“ C sharp” )是一种简单、现代、面向对象且类型安全的编程语言。C 和 C+ 程序员能很快熟悉它。C# 同时具备“应用程序快速开发”(RAD) 语言的高效率和C+ 固有的强大能力。 (c语言标准参考如是说)废话少说,进入主题,开始我们的c游戏开发之旅! (翻译有误请多原谅)第一章组建我们的设备1。建立一个DX 程序,首先你需要下载Microsoft DirectXSDK( 最好事 9.0 一下简称DX ) ,安装。然后事要保证你安装了Visual Studio .NET开发产品套件(一下简称) ,这是最小环境,然后你就可以进行游戏开发了。建立一个 DX 设备。打开DX 中的 Tutorials 文件夹下的Tutorials1 例子并打开编译!下面是运行结果:名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 13 页 - - - - - - - - - 创建了一个DX 窗口!下面是代码:/- / File: CreateDevice.cs / 创建设备/ Desc: This is the first tutorial for using Direct3D. In this tutorial, all /we are doing is creating a Direct3D device and using it to clear the /window. / 注释:这是第一个使用D3D 的教学例子,在这个例子中,我们要作的仅仅是创建以个 D3D “设备”和刷新窗口/ Copyright (c) Microsoft Corporation. All rights reserved. /- using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace DeviceTutorial public class CreateDevice : Form 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 13 页 - - - - - - - - - / Our global variables for this project Device device = null; / Our rendering device /我们的绘图设备public CreateDevice() / Set the initial size of our form /设置窗体的初始值this.ClientSize = new System.Drawing.Size(400,300); / And its caption /设置窗体标题this.Text = D3D Tutorial 01: CreateDevice; public bool InitializeGraphics() try / Now lets setup our D3D stuff /现在我们设置D3D 的一些选项PresentParameters presentParams = new PresentParameters(); presentParams.Windowed=true;/标志着程序运行时窗口模式presentParams.SwapEffect = SwapEffect.Discard;/ 返回或设置交换区选项? device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 9 页,共 13 页 - - - - - - - - - /?,设备的类型 (这里选择了硬件),创建图形设备的窗体,创建类型,创建实体);/创建设备实例return true; catch (DirectXException)/ 捕捉 DX 异常 return false; private void Render()/ 刷新模块 if (device = null) return; /Clear the backbuffer to a blue color /将设备窗口刷成绿色device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0); /clear(刷屏的参数这里选的是目标,使用的颜色,深度(可能用于模板),模板( 0)因为没有使用模板)/Begin the scene /开始渲染场景, (因为没有场景所以一下句是空的就直接结束了场景的渲染)device.BeginScene(); / Rendering of scene objects can happen here 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 10 页,共 13 页 - - - - - - - - - /可以在这里渲染场景/End the scene /结束场景的渲染device.EndScene(); device.Present(); protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)/重写 OnPaint方法 /this.Render(); / Render on painting /循环的刷新窗口 protected override void _disibledevent(System.Windows.Forms.KeyPressEventArgs e)/重写OnKeyPress 方法 if (int)(byte)e.KeyChar = (int)System.Windows.Forms.Keys.Escape) this.Close(); / Esc was pressed /如果按下了ESC 则退出程序 / / The main entry point for the application. / 程序的主函数,入口点名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 11 页,共 13 页 - - - - - - - - - / static void Main() /使用 USING 语句创建对象保证对象的销毁using (CreateDevice frm = new CreateDevice() if (!frm.InitializeGraphics() / Initialize Direct3D MessageBox.Show(Could not initialize Direct3D.This tutorial will exit.); return; frm.Show(); / While the form is still valid, render and process messages /消息循环while(frm.Created) frm.Render(); Application.DoEvents(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 12 页,共 13 页 - - - - - - - - - 代码中有加入的注释!首先是:using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; 使用命 3 名空间!注意的是,在程序的Main 主程序中使也用了USING ,注意这是c中的一条语句,using 语句定义一个范围,在此范围的末尾将处理对象。接着 Device device = null;这句是申请了Device 类的对象device 但并未创建实例对象,实例对象的创建必须使用new 语句创建。 public bool InitializeGraphics() 函数的作用是初始化 DX ,private void Render() 函数是渲染函数,其中的device.BeginScene(); 是开始渲染,device.EndScene(); device.Present(); 结束渲染,就如同翻页!可以在BeginScene();和 EndScene();函数之中添加图像的显示或文字的显示等其它工作!程序最后的while(frm.Created) frm.Render(); Application.DoEvents(); 是检测程序是否在执行,是则使用frm实例对象的方法Render();来渲染屏幕,Application.DoEvents(); 是执行消息循环!这样!一个简单的DX窗口就建立好了!本信息来源:CAD教育网 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 13 页,共 13 页 - - - - - - - - -

    注意事项

    本文(2022年C#游戏开发教程--指引如何开发最好的游戏 .pdf)为本站会员(C****o)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开