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();
}
//定义图片
PictureBox tp = new PictureBox();
//实例化timer
Timer zimu = new Timer();
Timer up = new Timer();
//左分组
Panel yx = new Panel();
//右分组
Panel an = new Panel();
//随机
Random r = new Random();
// 得分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();
List<Label> zimulab = new List<Label>();
//实例化小火苗1
PictureBox fire = new PictureBox();
//实例化小火苗2
PictureBox firet = new PictureBox();
private void Form1_Load(object sender, EventArgs e)
{ //背景
this.Size = new Size(1200,700) ;
//颜色
this.BackColor = Color.Cyan;
//位置居中
this.Left = Screen.PrimaryScreen.Bounds.Width / 2 - this.Width/2;
this.Top = Screen.PrimaryScreen.Bounds.Height / 2 - this.Height/2;
//游戏区
yx.Size = new Size(900,600);
yx.BackColor = Color.White;
this.Controls.Add(yx);
yx.Location = new Point(20, 30);
//字母生成器
zimu.Interval = 1000;
zimu.Tick += Zimu_Tick;
//控制字母下落
up.Interval = 20;
up.Tick += Up_Tick;
//图片插入
//飞机大小
tp.Size = new Size(50, 50);
//图片自适应大小
tp.SizeMode = PictureBoxSizeMode.StretchImage;
//飞机图片
tp.Image = Image.FromFile(@"../../img/BP03.png");
//飞机位置
tp.Top = yx.Height - tp.Height-20;
tp.Left = yx.Width
C#打字游戏
最新推荐文章于 2019-11-25 23:30:59 发布
本文介绍如何使用C#语言开发一款打字游戏,详细阐述了游戏的逻辑设计、用户交互界面的创建以及打字速度检测等核心功能的实现过程。
摘要由CSDN通过智能技术生成