C#飞机大战(开始,结束,清屏)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 飞机大战
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //飞机大战项目整体划分
        /*1、界面UI(背景图、战机信息、游戏信息)
         * 2、战机控制
         * 3、战机生成器
         * 4、游戏逻辑控制
         * 5、首先打字游戏
         * (1)设置背景
         * (2)字母生成
         * <1>每秒生成1.5个
         */
        Panel YX = new Panel();//控件盒子的集合,游戏主页面
                           
    //随机字母,可以用数字转换成字母形式
    Random sj = new Random();

    //pictureBox装图片的盒子(装F飞机图片的盒子)
    PictureBox tupianplsyer = new PictureBox();


    //游戏开始控制区Panel
    Panel kaishi = new Panel();


    Timer zimuTime = new Timer();

    Timer flyziti = new Timer();

    Label defen = new Label();


    ProgressBar HS = new ProgressBar();
    // lab进度条背景
    Label HSback = new Label();
    // lab进度条
    Label HSjindu = new Label();
    // 记录血量
    int xt = 100;
    //飞机自动
    //Timer fjzd = new Timer();

    //尾气图片
    //PictureBox wqtu = new PictureBox();

    //开始按钮
    Label kanniu = new Label();

    //音乐
    SoundPlayer yinyue = new SoundPlayer();
    SoundPlayer yinyue2 = new SoundPlayer();
    private void Form1_Load(object sender, EventArgs e)
    {
        yinyue.SoundLocation = @"../../yin/bz.wav";
        yinyue2.SoundLocation = @"../../yin/bjyl.wav";
       ///yinyue2.Play();
        this.Size = new Size(1920, 1000);
        this.BackColor = Color.Green;
        //this.FormBorderStyle = FormBorderStyle.None;//去掉框架
        //this.BackgroundImage = Image.FromFile(@"../../img/bg.jpg");
        //FromFile()从指定的文件创建
        //@转义字符
        //路径问题:(BackgroundImage要注意相对路径和绝对路径)
        //1.绝对路径
        //不用考虑其位置所在文件夹,只需要根据这个路径就能够直接找到目标
        //2.相对路径
        //以当前运行的文件为起始点,根据相对的路径去寻找目标,跳出使用“../”,进入使用“文件夹名/”

        //把页面放在最中间
        this.Left = Screen.PrimaryScreen.Bounds.Width / 2 - this.Width / 2;
        this.Top = Screen.PrimaryScreen.Bounds.Height / 2 - this.Height / 2;

        //创建游戏区
        //Panel YX = new Panel();
        YX.Width = 1000;
        YX.Height = 600;
        //YX.BackgroundImage = Image.FromFile(@"../../img/bg.jpg");
        YX.BackColor = Color.White;
        YX.BackgroundImageLayout = ImageLayout.Stretch;//沿工作区拉伸
        this.Controls.Add(YX);//表示获取包含在this当前所指的控件里,将add里的控件全部添加到this中的所有控件
        //图片放进去后,让图片放在框架中间
        YX.Location = new Point(0, 30);//表示图片显示的位置

        //字母生成器(zimuTime名字),给这个字母生成器添加一个计时器事件,创建计时器
        //Timer zimuTime = new Timer();
        zimuTime.Interval = 1500;//调用的事件时间
        zimuTime.Tick += ZimuTime_Tick;
        //zimuTime.Start();


        //字体下落的计时器//创建计时器
        //Timer flyziti = new Timer();
        flyziti.Interval = 10;
        flyziti.Tick += Flyziti_Tick;
        //flyziti.Start();

        //飞机图片
        //飞机图片大小
        //pictureBox装图片的盒子(装F飞机图片的盒子)
        //PictureBox tupianplsyer = new PictureBox();
        tupianplsyer.Size= new Size(100, 130);
        //tupianplsyer.BackColor = Color.Pink;
        //飞机位置
        tupianplsyer.Top = YX.Height- tupianplsyer.Height;//飞机图片的位置
        tupianplsyer.Left = YX.Width / 2 - tupianplsyer.Width / 2;
        tupianplsyer.Image = Image.FromFile(@"../../img/RP03.png");
        tupianplsyer.Tag = 0;
        //tupianplsyer.SizeMode = PictureBoxSizeMode.StretchImage;//自适应图片大小
        tupianplsyer.Tag = &#
  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值