基于C# WinForms窗体——飞机大战

原文:基于C# WinForms窗体——飞机大战

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Media; // 添加音乐需引入此命名空间
using System.Reflection;
namespace 飞机大战__
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Random ran = new Random(); // 创建随机对象
        PictureBox youxiqtupian = new PictureBox(); // 创建游戏开始图片
        Label youxiqu = new Label();// 创建游戏区对象
        Label kaiguanqu = new Label();// 创建开关区对象
        PictureBox player = new PictureBox();// 创建飞机对象
        PictureBox weiqi1 = new PictureBox();// 尾气对象1
        PictureBox weiqi2 = new PictureBox(); // 尾气对象2
        Timer dijiTimer = new Timer(); // 敌机生成定时器
        Timer xiaLuoTimer = new Timer();// 敌机下落定时器
        Timer zidanTimer = new Timer(); // 子弹生成定时器
        Timer xiangShangTimer = new Timer(); // 子弹向上定时器
        SoundPlayer baozhasound = new SoundPlayer(); // 爆炸音乐对象
        SoundPlayer jiemiansound = new SoundPlayer(); // 游戏界面音乐对象
        int num = 1; // 敌机随机初始飞机名
        int num1 = 10; // 飞机移动的数,子弹移动的数
        int feng = 0;//分数存储器

        Label kaiguan = new Label(); //开关对象
        Label defeng = new Label();// 得分对象
        Label xuetiao = new Label();//血条对象
        List<PictureBox> zdList = new List<PictureBox>();// 存储生成的子弹
        List<PictureBox> feijiList = new List<PictureBox>();// 存储飞机和尾气
        List<PictureBox> dijiList = new List<PictureBox>();// 存储生成敌机
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Size = new Size(1080, 700);
            this.Text = "飞机大战";
            this.BackColor = Color.FromArgb(80,00,80);
            this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2-this.Width/2, Screen.PrimaryScreen.WorkingArea.Height / 2-this.Height/2);
            // 创建游戏区图片,同样的位置
            youxiqtupian.Size = new Size(800, 600);
            youxiqtupian.Tag = "jiemianTu";
            youxiqtupian.Image = Image.FromFile(@"../../img/youxikaishi.bmp");
            youxiqtupian.SizeMode = PictureBoxSizeMode.StretchImage;
            youxiqtupian.Location = new Point(20, 20);
            this.Controls.Add(youxiqtupian);
            // 创建游戏区
            youxiqu.Size = new Size(800, 600);
            youxiqu.BackColor = Color.White;
            youxiqu.Location = new Point(20, 20);
            this.Controls.Add(youxiqu);
            // 创建开关区
            kaiguanqu.Size = new Size(200, 600);
            kaiguanqu.BackColor = Color.FromArgb(180, 15, 123);
            kaiguanqu.Location = new Point(840, 20);
            this.Controls.Add(kaiguanqu);
            // 创建飞机对象
            playerChuan();// 调用创建方法
            youxiqu.Controls.Add(player);
            feijiList.Add(player);
            //敌机生成定时器
            dijiTimer.Interval = 1500;
            dijiTimer.Tick += DijiTimer_Tick;
            // 敌机下落定时器
            xiaLuoTimer.Interval = 20;
            xiaLuoTimer.Tick += XiaLuoTimer_Tick;
            // 子弹生成定时器
            zidanTimer.Interval = 150;
            zidanTimer.Tick += ZidanTimer_Tick;
            // 子弹向上移动
            xiangShangTimer.Interval = 10;
            xiangShangTimer.Tick += XiangShangTimer_Tick;
            baozhasound.SoundLocation = @"../../music/game_over.wav";// 爆炸音乐路径
            jiemiansound.SoundLocation = @"../../music/game_music.wav";//界面音乐路径
            jiemiansound.PlayLooping(); //游戏界面音乐开启
            // 创建飞机尾气 两个
            // 尾气对象1
            weiqi1.Size = new Size(15,30);
            weiqi1.Tag = 0;
            weiqi1.Location =new Point(player.Left + player.Width / 2 - weiqi1.Width / 2 - 10,player.Top + player.Height + weiqi1.Height / 2 - 15);
            weiqi1.Image = imageList1.Images[0];
            weiqi1.SizeMode = PictureBoxSizeMode.StretchImage;
            youxiqu.Controls.Add(weiqi1);
            feijiList.Add(weiqi1);
            // 尾气对象2
            weiqi2.Size = new Size(15, 30);
            weiqi2.Tag = 0;
            weiqi2.Location = new Point(player.Left + player.Width / 2 + weiqi2.Width / 2 - 5, player.Top + player.Height + weiqi2.Height / 2 - 15);
            weiqi2.Image = imageList1.Images[0];
            weiqi2.SizeMode = PictureBoxSizeMode.StretchImage;
            youxiqu.Controls.Add(weiqi2);
            feijiList.Add(weiqi2);
            //创建尾气定时器
            Timer weiqiTimer = new Timer();
            weiqiTimer.Interval = 10;
            weiqiTimer.Tick += WeiqiTimer_Tick;
            weiqiTimer.Start();
            //创建开始游戏,暂停游戏按钮
            kaiguan.Size = new Size(150, 30);
            kaiguan.Location = new Point(30, 20);
            kaiguan.AutoSize = true;
            kaiguan.Cursor =Cursors.Hand; //鼠标变为手型
            kaiguan.Text = "开始游戏";
            kaiguan.Font = new Font("楷体",18);
            kaiguan.ForeColor = Color.FromArgb(97, 177, 48);
            kaiguan.BackColor = Color.FromArgb(191, 143, 243);
            kaiguan.Click += Kaiguan_Click1;
            kaiguanqu.Controls.Add(kaiguan);
            // 创建得分对象
            defeng.Size = new Size(150, 30);
            defeng.Location = new Point(30, 60);
            defeng.Text = "得分:" +feng + "分";
            defeng.Font = new Font("宋体", 20);
            defeng.ForeColor = Color.Yellow;
            kaiguanqu.Controls.Add(defeng);
            // 血量字体
            Label xlZi = new Label();
            xlZi.Size = new Size(150, 30);
            xlZi.Location = new Point(30, 90);
            xlZi.Text = "飞机血量";
            xlZi.Font = new Font("楷体", 20);
            xlZi.ForeColor = Color.Red;
            kaiguanqu.Controls.Add(xlZi);
            // 创建血条对象
            xuetiao.Size = new Size(160, 15);
            xuetiao.Location = new Point(30, 120);
            xuetiao.BackColor = Color.Red;
            kaiguanqu.Controls.Add(xuetiao);
            //创建血条底部对象
            Label xueTiaodi = new Label();
            xueTiaodi.Size = new Size(160,15);
            xueTiaodi.Location = new Point(30, 120);
            xueTiaodi.BackColor = Color.White;
            kaiguanqu.Controls.Add(xueTiaodi);
            /*// 在游戏区添加鼠标移动事件
            youxiqu.MouseMove += Form1_MouseMove;*/
            // 键盘事件
            this.KeyDown += Form1_KeyDown;

        }
        //游戏开关,暂停点击
        private void Kaiguan_Click1(object sender, EventArgs e)
        {
            if (kaiguan.Text == "开始游戏")
            {
                jiemiansound.Stop(); //游戏界面音乐关闭
                youxiqtupian.Dispose(); //游戏开始图片消失
                dijiTimer.Start(); //敌机生成
                xiaLuoTimer.Start();//敌机下落
                zidanTimer.Start();// 子弹生成
                xiangShangTimer.Start(); // 子弹上升
                kaiguan.BackColor = Color.Red;
                kaiguan.ForeColor = Color.White;

                kaiguan.Text = "暂停游戏";
            }
            else if (kaiguan.Text == "暂停游戏")
            {
                dijiTimer.Stop(); //敌机暂停生成
                xiaLuoTimer.Stop();//敌机暂停下落
                zidanTimer.Stop();// 子弹暂停生成
                xiangShangTimer.Stop(); // 子弹暂停上升
                ziDqing(); //子弹清除
                kaiguan.BackColor = Color.FromArgb(191, 143, 243);
                kaiguan.ForeColor = Color.FromArgb(97, 177, 48);
                kaiguan.Text = "开始游戏";
            }
        }

        // 尾气动画
        int weiQi1 = 0,weiQi2 = 0; // 存储图片数
        private void WeiqiTimer_Tick(object sender, EventArgs e)
        {   // 尾气1添加图片
            weiqi1.Image = imageList1.Images[weiQi1];
            weiQi1++;
            if (weiQi1>=imageList1.Images.Count)
            {
                weiQi1 = 0;
            }
            // 尾气2添加图片
            weiqi2.Image = imageList1.Images[weiQi2];
            weiQi2++;
            if (weiQi2 >=imageList1.Images.Count)
            {
                weiQi2 = 0;
            }
        }
        /*//游戏区鼠标移动事件
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
           player.Left = MousePosition.X - this.Left - youxiqu.Left - player.Width / 2;
           player.Top = MousePosition.Y - this.Top - youxiqu.Top - player.Height / 2;
        }*/

        //敌机生成的定时器
        private void DijiTimer_Tick(object sender, EventArgs e)
        {
            //创建敌机对象
            PictureBox diji = new PictureBox(); // 创建敌机对象
            diji.Size = new Size(70, 60);
            diji.Tag = "diji";
            num = ran.Next(1, 5);
            diji.Image = Image.FromFile(@"../../img/diji/Enemy" + num + ".png");
            if (num==4)
            {
                diji.Size =new Size(100, 80);
            }
            diji.SizeMode = PictureBoxSizeMode.StretchImage;// 图片自适应大小
            diji.Location = new Point(ran.Next(youxiqu.Width - diji.Width), 0); //敌机初始位置
            youxiqu.Controls.Add(diji);
            dijiList.Add(diji);
        }
        // 敌机下落的定时器
        private void XiaLuoTimer_Tick(object sender, EventArgs e)
        {
            foreach (Control diji in youxiqu.Controls)
            {
                if (diji.Tag.ToString()=="diji")
                {
                    diji.Top += 5;
                    if (diji.Top>youxiqu.Height) // 敌机超过游戏区高度
                    {
                        diji.Dispose(); //敌机释放(删除)
                        xuetiao.Width -= 20;
                        if (xuetiao.Width<=0)
                        {
                            diJiqing();// 敌机清除
                            dijiTimer.Stop();// 敌机创建关闭
                            ziDqing();//子弹清除
                            zidanTimer.Stop();// 子弹创建关闭
                            //创建弹框
                            if ((MessageBox.Show("游戏结束,你的得分:" + feng, "Game Over", MessageBoxButtons.RetryCancel) == DialogResult.Retry))
                            {
                                feng = 0;
                                defeng.Text = "得分" + feng + "分";
                                xuetiao.Width = 160;
                                kaiguan.Text = "游戏开始";
                                dijiTimer.Start(); //敌机生成
                                xiaLuoTimer.Start();//敌机下落
                                zidanTimer.Start();// 子弹生成
                                xiangShangTimer.Start(); // 子弹上升
                                playerChuan();// 飞机创建
                                weiqi1.Location = new Point(player.Left + player.Width / 2 - weiqi1.Width / 2 - 10, player.Top + player.Height + weiqi1.Height / 2 - 15);
                                weiqi2.Location = new Point(player.Left + player.Width / 2 + weiqi2.Width / 2 - 5, player.Top + player.Height + weiqi2.Height / 2 - 15);
                                ziDqing(); // 子弹清除
                                diJiqing(); //敌机清除
                            }
                            else
                            {
                                this.Close();
                            }
                        }
                    }
                    foreach (Control player in youxiqu.Controls)
                    {
                        if (player.Tag.ToString() == "player")
                        {   //敌机碰到飞机
                            if (diji.Left >= player.Left && diji.Left <= player.Left + player.Width && diji.Top >= player.Top && diji.Top <= player.Top + player.Height)
                            {
                                diJiqing();// 调用清除敌机方法
                                ziDqing(); // 调用子弹清除方法
                                zidanTimer.Stop();// 子弹暂停生成
                                xiangShangTimer.Stop(); // 子弹暂停上升
                                dijiTimer.Stop();// 敌机生成清除
                                kaiguan.Text = "游戏开始";
                                DialogResult jieshukuang = MessageBox.Show("总得分为:" + feng + "分," + "是否重新开始", "游戏结束", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
                                if (jieshukuang == DialogResult.Retry) // 点击确定按钮
                                {
                                    feng = 0;
                                    defeng.Text = "得分" + feng + "分";
                                    xuetiao.Width = 160;
                                    kaiguan.Text = "游戏开始";
                                    dijiTimer.Start(); //敌机生成
                                    xiaLuoTimer.Start();//敌机下落
                                    zidanTimer.Start();// 子弹生成
                                    xiangShangTimer.Start(); // 子弹上升
                                    playerChuan();// 飞机创建
                                    weiqi1.Location = new Point(player.Left + player.Width / 2 - weiqi1.Width / 2 - 10, player.Top + player.Height + weiqi1.Height / 2 - 15);
                                    weiqi2.Location = new Point(player.Left + player.Width / 2 + weiqi2.Width / 2 - 5, player.Top + player.Height + weiqi2.Height / 2 - 15);
                                    ziDqing(); // 子弹清除
                                    diJiqing(); //敌机清除

                                }
                                else if (jieshukuang == DialogResult.Cancel)//点击取消按钮
                                {
                                    this.Close();// 关闭窗体
                                }
                            }
                        }
                    }
                }
            }
        }
        // 子弹生成定时器
        private void ZidanTimer_Tick(object sender, EventArgs e)
        {
            PictureBox zidan = new PictureBox();// 创建子弹
            zidan.Tag = "zd";
            zidan.Size = new Size(8, 30);
            zidan.Left = player.Left +player.Width / 2 - zidan.Width / 2;
            zidan.Top = player.Top - zidan.Height;
            zidan.Image = Image.FromFile(@"../../img/Ammo1.png");
            zidan.SizeMode = PictureBoxSizeMode.StretchImage; // 图片自适应大小
            youxiqu.Controls.Add(zidan);
            zdList.Add(zidan); //子弹添加到子弹泛型对象中
        }

        // 子弹向上
        private void XiangShangTimer_Tick(object sender, EventArgs e)
        {
            foreach (Control zidan  in youxiqu.Controls)
            {
                if (zidan.Tag.ToString()=="zd") // 获取子弹
                {
                    zidan.Top -= num1;
                    if (zidan.Top<0) // 子弹超过游戏区
                    {
                        zidan.Dispose();
                    }
                    foreach (Control diji in youxiqu.Controls)
                    {
                        if (diji.Tag.ToString() == "diji")  // 获取敌机
                        {
                            // 子弹碰撞敌机
                            if (zidan.Top >= diji.Top && zidan.Top <= diji.Top + diji.Height && zidan.Left>=diji.Left && zidan.Left<=diji.Left+diji.Width)
                            {
                                zidan.Dispose(); // 子弹清除
                                diji.Dispose(); // 敌机清除
                                baozhasound.Play(); // 开启爆炸声
                                if (diji.Width==100)
                                {
                                    feng += 10;
                                }
                                else
                                {
                                    feng += 1;
                                }
                                feng++;
                                defeng.Text = "得分:" + feng + "分";
                                // 创建爆炸对象
                                PictureBox baozha = new PictureBox();
                                baozha.Tag = 0;
                                baozha.Size = new Size(50, 50);
                                baozha.Image = imageList2.Images[0];
                                baozha.SizeMode = PictureBoxSizeMode.StretchImage; // 图片自适应大小
                                baozha.Location = new Point(diji.Left + diji.Width / 2 - baozha.Width / 2, diji.Top - diji.Height / 2 + baozha.Height / 2);
                                youxiqu.Controls.Add(baozha);
                                // 爆炸定时器
                                Timer baozhaTimer = new Timer();
                                baozhaTimer.Tag = baozha;
                                baozhaTimer.Interval = 10;
                                baozhaTimer.Tick += BaozhaTimer_Tick; ;
                                baozhaTimer.Start(); // 爆炸开启
                            }
                        }
                    }
                }
            }
        }
        // 爆炸动画
        private void BaozhaTimer_Tick(object sender, EventArgs e)
        {
            Timer baozhaTimer = sender as Timer;
            PictureBox baoZha = baozhaTimer.Tag as PictureBox;
            baoZha.Image = imageList2.Images[(int)baoZha.Tag];
            baoZha.Tag = (int)baoZha.Tag + 1;
            if ((int)baoZha.Tag>31)
            {
                baozhaTimer.Dispose();
                baoZha.Dispose();
            }
        }
        //键盘事件
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            //飞机向左
            if (e.KeyCode == Keys.A || e.KeyCode == Keys.Left)
            {
                player.Left -= num1;
                weiqi1.Left -= num1; // 尾气1向左
                weiqi2.Left -= num1; // 尾气2向左
                if (player.Left == 0)
                {
                    player.Left = num1;
                    weiqi1.Left = player.Left + player.Width / 2 - weiqi1.Width / 2 - 10;
                    weiqi2.Left = player.Left + player.Width / 2 + weiqi2.Width / 2 - 5;
                }
            }
            // 飞机向右
            if (e.KeyCode==Keys.D || e.KeyCode==Keys.Right)
            {
                player.Left += num1;
                weiqi1.Left += num1;
                weiqi2.Left += num1;
                if (player.Left + player.Width >= youxiqu.Width)
                {
                    player.Left = youxiqu.Width - player.Width;
                    weiqi1.Left = player.Left + player.Width / 2 - weiqi1.Width / 2 - 10;
                    weiqi2.Left = player.Left + player.Width / 2 + weiqi2.Width / 2 - 5;
                }
            }
            // 飞机向上
            if (e.KeyCode==Keys.W|| e.KeyCode==Keys.Up)
            {
                player.Top -= num1;
                weiqi1.Top -= num1;
                weiqi2.Top -= num1;
                if (player.Top == 0)
                {
                    player.Top = num1;
                    weiqi1.Top = player.Top + player.Height + weiqi1.Height / 2 - 15;
                    weiqi2.Top = player.Top + player.Height + weiqi2.Height / 2 - 15;
                }
            }
            // 飞机向下
            if (e.KeyCode==Keys.S || e.KeyCode==Keys.Down)
            {
                player.Top += num1;
                weiqi1.Top += num1;
                weiqi2.Top += num1;
                if (player.Top + player.Height + weiqi1.Height >= youxiqu.Height)
                {
                    player.Top = youxiqu.Height - player.Height - weiqi1.Height;
                    weiqi1.Top = player.Top + player.Height + weiqi1.Height / 2 - 15;
                    weiqi2.Top = player.Top + player.Height + weiqi2.Height / 2 - 15;
                }
            }
        }
        //子弹消除方法
        private void ziDqing()
        {
            foreach (PictureBox zidan in zdList)
            {
                zidan.Dispose();
            }
        }
        //飞机消除方法
        private void feiJiqing()
        {
            foreach (PictureBox feiji in feijiList)
            {
                feiji.Dispose();
            }
        }
        // 敌机消除方法
        private void diJiqing()
        {
            foreach (PictureBox diji in dijiList)
            {
                diji.Dispose();
            }
        }

        private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        // 飞机创建方法
        private void playerChuan()
        {
            player.Size = new Size(70, 60);
            player.Tag = "player";
            player.Left = youxiqu.Width / 2 - player.Width / 2; // 飞机初始位置
            player.Top = youxiqu.Height - player.Height - 20;
            player.Image = Image.FromFile(@"../../img/RP03.png");
            player.SizeMode = PictureBoxSizeMode.StretchImage; // 图片自适应大小

        }
    }
}

原文地址:https://www.cnblogs.com/lonelyxmas/p/12079058.html

时间: 2024-11-19 11:01:43

基于C# WinForms窗体——飞机大战的相关文章

python(pygame)滑稽大战(类似飞机大战) 教程

基于pygame实现类似飞机大战小游戏(滑稽大战) 成品已录制视频投稿B站,点击观看动画 项目稽忽悠不(github)地址(目前只上传了素材,代码还在整理中):https://github.com/BigShuang/From-simple-to-Huaji本文首发于本人简书 初始准备工作 本项目使用的python3版本(如果你用python2,我不知会怎么样) Ide推荐大家选择pycharm(不同ide应该没影响) 需要安装第三方库pygame, pygame安装方法(windows电脑,m

基于Cocos2d-x-1.0.1的飞机大战游戏开发实例(下)

在飞机大战游戏开发中遇到的问题和解决方法: 1.在添加菜单时,我要添加一个有背景的菜单,需要在菜单pMenu中添加一个图片精灵,结果编译过了但是运行出错,如下图: 查了很多资料,调试了很长时间,整个人都要崩溃了. 最后发现引擎中CCMenu::itemForTouch函数中有遍历子节点的行为,但是循环中没有判断子节点类型是否为CCMenuItem.如图:码,这样一来,加入到pMenu中的图片精灵被当作菜单项取了出来使用,导致报错.老版本的果然又不完善的地方,整个人都不好了...果断修改引擎里的源

基于Cocos2d-x-1.0.1的飞机大战游戏开发实例(中)

接<基于Cocos2d-x-1.0.1的飞机大战游戏开发实例(上)> 三.代码分析 1.界面初始化 1 bool PlaneWarGame::init() 2 { 3 bool bRet = false; 4 do 5 { 6 CC_BREAK_IF(! CCLayer::init()); 7 8 _size = CCDirector::sharedDirector()->getWinSize(); 9 10 // 设置触摸可用 11 this->setIsTouchEnabled

基于Cocos2d-x-1.0.1的飞机大战游戏开发实例(上)

最近接触过几个版本的cocos2dx,决定每个大变动的版本都尝试一下.本实例模仿微信5.0版本中的飞机大战游戏,如图: 一.工具 1.素材:飞机大战的素材(图片.声音等)来自于网络 2.引擎:cocos2d-1.0.1-x-0.9.2 3.环境:vs2010 二.使用的类 1.游戏菜单界面类:PlaneWarMenu——派生自CCLayer类. 1 // 游戏菜单界面类 2 class PlaneWarMenu: public CCLayer 3 { 4 public: 5 virtual bo

cocos2d-x-3.3-024-仿微信飞机大战-如何引爆炸弹-实现范围攻击

原文同步发布于我的wiki,查看原文或更新请移步: 点击打开链接 承上文 先回答拓展思考里的问题,'物理引擎可否用来做碰撞检测?',答案是肯定的,具体见下面 cocos2d-x-3.3-019-碰撞检测1-矩形区域是否相交 cocos2d-x-3.3-020-碰撞检测2-物理引擎初探 cocos2d-x-3.3-021-碰撞检测3-物理引擎碰撞过滤 子弹如何杀伤敌人在上面的系列中已经实现.本节要实现的功能点是,继续利用碰撞检测实现飞机大战里炸弹的全屏范围攻击 本文DEMO 基于cocos2d-x

cocos2d-x-3.3-022-仿微信飞机大战-开篇介绍

原文同步发布于我的wiki,查看原文或更新请移步: 点击打开链接 写在最前面 微信飞机大战,触控的大神JackyStudio 已经在他的专栏微信飞机大战讲解中完整细致的实现了一遍,基于cocos2d-x-v2.2.0和cocos2d-x-3.0,推荐大家阅读.同时该系列的资源代码等全部开源(地址见文后链接),利于新手运用和学习.感谢分享. 我是新手,刚懂点cocos的基础.我这系列将沿着大神的足迹前进,更进一步去体会理解cocos的魅力.本系列将记录我个人在实践之路上的体会. 本系列将基于coc

Java飞机大战源代码

刚学不久java,做了一个飞机大战的小小小小游戏,现在把这个思路总结以及代码分享出来.大佬别吐槽(emmmmmm .....开发环境:jdk1.7 开发工具:eclipese PlanelJPanel.java 1 package project02; 2 3 import java.awt.BasicStroke; 4 import java.awt.Color; 5 import java.awt.Cursor; 6 import java.awt.Font; 7 import java.a

无聊吗?写个【飞机大战】来玩吧(上篇)

01前言介绍 微信小游戏是基于微信客户端的游戏,它即点即玩,无需下载安装,体验轻便,可以和微信内的好友一起玩,比如PK.围观等,享受小游戏带来的乐趣.那如何开发一款属于自己的小游戏呢? 源码地址: https://github.com/A123asdo11/aircraft_war (新版ccc已无法正常使用,需要修复,文章作者花费了大量的时间和精力,在ccc2.0以上版本进行了修复,并在微信小游戏正常运行) 02微信小游戏飞机大战简介 1.大事记 经典飞机大战是腾讯交流软件微信5.0版本在20

安卓飞机大战(二) SurfaceView实现自制背景

用SurfaceView写一个自制的背景图,并且可以移动,加上安卓飞机大战(一)中的BackgroundManager类,可以直接使用 GameView代码: public class GameView extends SurfaceView implements SurfaceHolder.Callback,Runnable{    private SurfaceHolder hd=null;    private Canvas canvas=null;    private Backgrou