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 打字游戏2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Random r = new Random();
//游戏区
PictureBox box = new PictureBox();
//飞机
PictureBox fei = new PictureBox();
//按键区
PictureBox kai = new PictureBox();
//子弹生成器
Timer zi = new Timer();
//下落
Timer Fly = new Timer();
//敌机生成器
Timer zm = new Timer();
//尾翼
PictureBox wei = new PictureBox();
PictureBox weiyi = new PictureBox();
//音效
SoundPlayer ying = new SoundPlayer();
SoundPlayer yin = new SoundPlayer();
//SoundPlayer yinxiao = new SoundPlayer();
//血条
Label xue = new Label();
//积分器
Label defen = new Label();
//开始/暂停按钮
Label ting = new Label();
private void Form1_Load(object sender, EventArgs e)
{
this.Size = new Size(800,500);
this.BackColor = Color.Cyan;
this.Left = Screen.PrimaryScreen.Bounds.Width / 2 - this.Width / 2;
this.Top = Screen.PrimaryScreen.Bounds.Height / 2 - this.Height / 2;
//游戏区
box.Width = 600;
box.Height = 450;
box.Location = new Point(0,10);
box.BackColor = Color.White;
this.Controls.Add(box);
//按键区
kai.Width = 200;
kai.Height = 400;
kai.BackColor = Color.Blue;
this.Controls.Add(kai);
kai.Location = new Point(0, 10);
kai.Left = box.Width + box.Left;
//开始/暂停按钮
//Label ting = new Label();
ting.Tag = "anan";
ting.Size = new Size(150, 40);
ting.BackColor = Color.Yellow;
ting.Text = "开始";
ting.Font = new Font("", 35);
ting.AutoSize = true;
kai.Controls.Add(ting);
ting.Left = kai.Width / 2 - ting.Width / 2;
ting.Click += Ting_Click;
//敌机生成器
//Timer zm = new Timer();
zm.Interval = 1000;
zm.Tick += Zm_Tick;
//zm.Start();
//下落
//Timer Fly = new Timer();
Fly.Interval = 10;
Fly.Tick += Fly_Tick;
//Fly.Start();
//飞机
fei.Tag = "fei";
fei.Image = Image.FromFile(@"../../img/Enemy2.png");
fei.Size = new Size(60,60);
fei.SizeMode = PictureBoxSizeMode.StretchImage;
fei.Left = box.Width/2 - fei.Width/2;
fei.Top = box.Height - fei.Height-40;
fei.BackColor = Color.Transparent;
box.Controls.Add(fei);
//尾翼
wei.Tag = "wei";
wei.Size = new Size(30, 40);
wei.Left = fei.Left + fei.Width / 2;
wei.Top = fei.Top + fei.Height;
wei.Image = imageList1.Images[0];
box.Controls.Add(wei);
weiyi.Tag = "weiji";
weiyi.Image = imageList2.Images[0];
w
c#飞机大战-简单功能2
最新推荐文章于 2020-11-03 17:07:52 发布
本文将详细解析使用C#编程语言实现的飞机大战游戏中的一些基础功能,包括飞机移动、射击、碰撞检测等核心机制。通过实例代码和步骤说明,帮助读者理解游戏开发的基本流程和技巧。
摘要由CSDN通过智能技术生成