基本信息
源码名称:C# 打字练习游戏源码《》Head first C#丛书Hit the keys!小游戏编码
源码大小:0.22M
文件格式:.rar
开发语言:C#
更新时间:2017-06-10
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
可以用来做简易的打字练习,提高打字速度。
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Game { public partial class TheGame : Form { Random random = new Random(); Stats stats = new Stats(); public TheGame() { InitializeComponent(); this.Select(); this.KeyPreview = true; } private void timer1_Tick_1(object sender, EventArgs e) { //add a random key to the listbox listBox1.Items.Add((Keys)random.Next(65, 90)); if (listBox1.Items.Count > 7) { listBox1.Items.Clear(); listBox1.Items.Add("GAME OVER"); timer1.Stop(); } } private void TheGame_KeyDown(object sender, KeyEventArgs e) { if (listBox1.Items.Contains(e.KeyCode)) { listBox1.Items.Remove(e.KeyCode); listBox1.Refresh(); if (timer1.Interval > 400) timer1.Interval -= 10; if (timer1.Interval > 250) timer1.Interval -= 10; if (timer1.Interval > 100) timer1.Interval -= 10; difficultyProgressBar.Value = 800 - timer1.Interval; stats.Update(true); } else { stats.Update(false); } correctLabel.Text = "正确:" stats.Correct; misssingLabel.Text = "错误:" stats.Missed; totalLabel.Text = "总计:" stats.Total; accuracyLabel.Text = "准确率:" stats.Accuracy "%"; } } }