程序小白,欢迎建议
有需要源码或图片或音效的请在GitHup自行下载下载地址请点击这里
主要实现代码:
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 bg = new Panel();
//实例化一个控制区
Panel kz = new Panel();
//实例化随机对象
Random r = new Random();
//实例化己方飞机对象
PictureBox plan = new PictureBox();
//实例化得分板
Label lb1 = new Label();
//实例化开始按钮
Label lb2 = new Label();
//记录分数
int count = 0;
//创建敌机
Timer GreateEnmmy = new Timer();
//字母下落
Timer FlyTime = new Timer();
//lab进度条背景
Label jdback = new Label();
//lab进度条
Label jdtiao = new Label();
//进度条血量
int xt = 100;
//实例化放飞机火苗1
PictureBox fire2 = new PictureBox();
//实例化放飞机火苗2
PictureBox fire = new PictureBox();
装敌机
List<PictureBox> djBox = new List<PictureBox>();
装子弹
List<PictureBox> zdBox = new List<PictureBox>();
//创建子弹生成器
Timer Greatbutt = new Timer();
//子弹上升
Timer buttTop = new Timer();
//给飞机火苗添加控制时间
Timer firet = new Timer();
//实例化声音
SoundPlayer sy = new SoundPlayer();
private void Form1_Load(object sender, EventArgs e)
{
//初始化窗口
this.Size = new Size(1000, 600);
//this.BackColor = Color.Red;
this.BackgroundImage = Image.FromFile(@"../../img/bg.jpg");
this.BackgroundImageLayout = ImageLayout.Stretch;
this.Left = Screen.PrimaryScreen.Bounds.Width / 2 - this.Width / 2;
this.Top = Screen.PrimaryScreen.Bounds.Height / 2 - this.Height / 2;
//创建游戏区
bg.Width = 800;
bg.Height = 530;
bg.BackColor = Color.Pink;
this.Controls.Add(bg);
bg.Location = new Point(10, 20);
//创建控制区
kz.Width = 200;
kz.Height = 530;
kz.BackColor = Color.Cyan;
kz.Location = new Point(this.Width-kz.