资源简介
WinForm只能做一些简单的游戏,比如:连连看,贪吃蛇等
WinForm游戏的核心就是:人机交互界面,
图像加载形成静态图像,玩家控制游戏坦克,定时频繁刷新,就完成了行走等命令,形成游戏。

代码片段和文件信息
using System.Drawing;
//add
//add
namespace 坦克
{
internal class bullet
{
private readonly bool type; //己方子弹true敌方子弹false
private int direct; //子弹行进方向
private int height = 32;
private int left;
private int top; //子弹坐标(TopLeft)
private int width = 32;
public bullet(int type) // 子弹类构造函数
{
if (type == 6) //己方
this.type = true;
else
this.type = false;
}
public int Top //Top属性
{
get { return top; }
set { top = value; }
}
public int Left //Left属性
{
get { return left; }
set { left = value; }
}
public int Direct //Direct属性(子弹行进方向)
{
get { return direct; }
set { direct = value; }
}
public void move()
{
switch (Direct)
{
case 0:
Top--;
break;
case 1:
Top++;
break;
case 2:
Left--;
break;
case 3:
Left++;
break;
}
}
public void Draw(Graphics g)
{
Image bulletImage;
if (type) //己方
bulletImage = Image.FromFile(“BMP/missile1.bmp“);
else
bulletImage = Image.FromFile(“BMP/missile2.bmp“);
//得到绘制这个子弹图形的在游戏面板中的矩形区域
Rectangle destRect = new Rectangle(left*width top*height width height);
Rectangle srcRect = new Rectangle(0 0 width height);
g.DrawImage(bulletImage destRect srcRect GraphicsUnit.Pixel);
}
public bool hitE(int tanktype) //是否击中对方坦克
{
if (type == false) //敌方子弹
if (tanktype >= 2 && tanktype <= 5)
//坦克的类型(2---5敌方,6己方)
return false;
else
return true;
if (type) //己方子弹
if (tanktype == 6) //坦克的类型(2---5敌方,6己方)
return false;
else
return true;
return false;
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-08-20 12:35 坦克大战\
目录 0 2012-08-20 12:30 坦克大战\bin\
目录 0 2012-08-20 12:35 坦克大战\bin\Debug\
目录 0 2012-08-20 12:30 坦克大战\bin\Debug\bmp\
文件 822 2001-08-14 00:37 坦克大战\bin\Debug\bmp\DX.BMP
文件 9270 2001-08-15 00:57 坦克大战\bin\Debug\bmp\ETANK1.BMP
文件 9270 2001-08-15 01:07 坦克大战\bin\Debug\bmp\ETANK2.BMP
文件 9270 2001-08-15 01:11 坦克大战\bin\Debug\bmp\ETANK3.BMP
文件 9270 2001-08-15 01:16 坦克大战\bin\Debug\bmp\ETANK4.BMP
文件 566 2000-02-07 20:21 坦克大战\bin\Debug\bmp\explode1.bmp
文件 5174 2000-02-08 21:03 坦克大战\bin\Debug\bmp\explode2.bmp
文件 2906 2008-08-07 22:12 坦克大战\bin\Debug\bmp\missile1.bmp
文件 2906 2008-08-08 05:38 坦克大战\bin\Debug\bmp\missile2.bmp
文件 9270 1999-12-01 17:05 坦克大战\bin\Debug\bmp\MYTANK.BMP
文件 13970 1999-04-12 15:52 坦克大战\bin\Debug\bmp\tankD.bmp
文件 14646 1999-04-12 15:52 坦克大战\bin\Debug\bmp\tankL.bmp
文件 14526 1999-04-12 15:51 坦克大战\bin\Debug\bmp\tankR.bmp
文件 14654 1999-04-12 15:52 坦克大战\bin\Debug\bmp\tankU.bmp
文件 822 2001-08-14 00:39 坦克大战\bin\Debug\bmp\TQ.BMP
目录 0 2012-08-20 12:30 坦克大战\bin\Debug\sound\
文件 11414 1997-10-26 17:11 坦克大战\bin\Debug\sound\bob.wav
文件 1977 1998-09-07 08:54 坦克大战\bin\Debug\sound\DropCell.wav
文件 85420 2000-04-12 08:42 坦克大战\bin\Debug\sound\Explode.wav
文件 38400 2005-10-27 02:57 坦克大战\bin\Debug\sound\explode2.WAV
文件 13318 1998-07-22 07:15 坦克大战\bin\Debug\sound\MOVE.WAV
文件 9851 2001-05-18 20:37 坦克大战\bin\Debug\sound\Music1.mid
文件 10389 1997-08-05 07:49 坦克大战\bin\Debug\sound\Music8.MID
文件 11504 2005-10-27 02:57 坦克大战\bin\Debug\sound\score.wav
文件 48274 2000-04-12 23:54 坦克大战\bin\Debug\sound\Shoot.wav
文件 972 2000-03-12 03:09 坦克大战\bin\Debug\sound\tank.wav
文件 7170 2006-10-29 07:46 坦克大战\bin\Debug\sound\tie.wav
............此处省略35个文件信息
- 上一篇:C#+数据库
- 下一篇:KTV点歌系统的设计与实现论文
相关资源
- 考试管理系统 - C#源码
- 逐步法线性回归C#源码
- 连连看游戏C#源码有提示和洗牌功能
- C#初学者编程150个
- gerber 查看软件(C#源码)
- C#源码读取DXF文件
- 打印机监控(C#源码)
- 00后搞笑辞职信(C#源码)
- 桌面日历_V1.0(C#源码)
- 快递接口(C#源码以及文档)
- vb调用c#编写的串口DLL文件(vb源码
- BouncyCastle C#源码
- C#锁屏软件(真正禁用ctrl+alt+del,含源
- 拱猪扑克牌游戏C#源码
- 各类称重仪表C#源码
- C#坦克大战源代码全部用C#编写
- C#源码:批量自动去除图片白边
- 100个C#初学者编程
- [C#源码]内存搜索修改像金山游侠一下
- C#源码让windows系统待机休眠
- C#图书管理系统源码(含数据库)-附
- c#编写的绘图软件源码
- [C#源码]超市项目BS架构
- Modbus通讯协议-C#源码
- 发票套打[全C#源码]
- apk信息查看C#源码
- 使用C#和MySql数据库实现的小程序---适
- c#图书管理系统C#源码和SQL数据库
- 客户端根据服务器端的指令弹出提示
- 三层架构 asp.net网上书店BookShop适合初
评论
共有 条评论