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();
}
//游戏区
Panel game = new Panel();
//控制区
Panel kz = new Panel();
//随机
Random r = new Random();
//飞机盒子
PictureBox plane = new PictureBox();
//小火苗1
PictureBox fire1 = new PictureBox();
//小火苗2
PictureBox fire2 = new PictureBox();
//敌机timer
Timer djplane = new Timer();
//敌机下落
Timer djtop = new Timer();
//子弹计时器
Timer zdt = new Timer();
// 得分label
Label lab = new Label();
// 记录分数
int score = 0;
// lab进度条背景
Label HSback = new Label();
// lab进度条
Label HSjindu = new Label();
// 记录血量
int xt = 100;
//开始游戏
Label start = new Label();
//实例化声音
SoundPlayer sound = new SoundPlayer();
private void Form1_Load(object sender, EventArgs e)
{
//form1位置
this.Size = new Size(1100, 700);
this.Left = Screen.PrimaryScreen.Bounds.Width / 2 - this.Width / 2;
this.Top = Screen.PrimaryScreen.Bounds.Height / 2 - this.Height / 2;
this.BackColor = Color.Cyan;
//游戏区位置
game.Size = new Size(800, 600);
game.BackColor = Color.White;
game.Location = new Point(30, 30);
this.Controls.Add(game);
//控制区
kz.Size = new Size(200, 600);
kz.BackColor = Color.White;
kz.Location = new Point(game.Left + game.Width + 30, 30);
this.Controls.Add(kz);
//开始游戏
start.Font = new Font("", 20);
start.AutoSize = true;
start.Text = "开始游戏";
start.Location = new Point(40, 50);
start.Click += Start_Click;
kz.Controls.Add(start);
//暂停游戏
Label stop = new Label();
stop.Font = new Font("", 20);
stop.AutoSize = true;
C#简易飞机大战
最新推荐文章于 2023-10-31 20:57:05 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)