非常简单的坦克大战.zip


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  坦克大战in
     目录           0  2012-08-20 12:35  坦克大战inDebug
     目录           0  2012-08-20 12:30  坦克大战inDebugmp
     文件         822  2001-08-14 00:37  坦克大战inDebugmpDX.BMP
     文件        9270  2001-08-15 00:57  坦克大战inDebugmpETANK1.BMP
     文件        9270  2001-08-15 01:07  坦克大战inDebugmpETANK2.BMP
     文件        9270  2001-08-15 01:11  坦克大战inDebugmpETANK3.BMP
     文件        9270  2001-08-15 01:16  坦克大战inDebugmpETANK4.BMP
     文件         566  2000-02-07 20:21  坦克大战inDebugmpexplode1.bmp
     文件        5174  2000-02-08 21:03  坦克大战inDebugmpexplode2.bmp
     文件        2906  2008-08-07 22:12  坦克大战inDebugmpmissile1.bmp
     文件        2906  2008-08-08 05:38  坦克大战inDebugmpmissile2.bmp
     文件        9270  1999-12-01 17:05  坦克大战inDebugmpMYTANK.BMP
     文件       13970  1999-04-12 15:52  坦克大战inDebugmp ankD.bmp
     文件       14646  1999-04-12 15:52  坦克大战inDebugmp ankL.bmp
     文件       14526  1999-04-12 15:51  坦克大战inDebugmp ankR.bmp
     文件       14654  1999-04-12 15:52  坦克大战inDebugmp ankU.bmp
     文件         822  2001-08-14 00:39  坦克大战inDebugmpTQ.BMP
     目录           0  2012-08-20 12:30  坦克大战inDebugsound
     文件       11414  1997-10-26 17:11  坦克大战inDebugsoundob.wav
     文件        1977  1998-09-07 08:54  坦克大战inDebugsoundDropCell.wav
     文件       85420  2000-04-12 08:42  坦克大战inDebugsoundExplode.wav
     文件       38400  2005-10-27 02:57  坦克大战inDebugsoundexplode2.WAV
     文件       13318  1998-07-22 07:15  坦克大战inDebugsoundMOVE.WAV
     文件        9851  2001-05-18 20:37  坦克大战inDebugsoundMusic1.mid
     文件       10389  1997-08-05 07:49  坦克大战inDebugsoundMusic8.MID
     文件       11504  2005-10-27 02:57  坦克大战inDebugsoundscore.wav
     文件       48274  2000-04-12 23:54  坦克大战inDebugsoundShoot.wav
     文件         972  2000-03-12 03:09  坦克大战inDebugsound ank.wav
     文件        7170  2006-10-29 07:46  坦克大战inDebugsound ie.wav
............此处省略35个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)