| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2541 人关注过本帖
标题:C#打字游戏
只看楼主 加入收藏
ordinary逗比
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-3-15
收藏
 问题点数:0 回复次数:2 
C#打字游戏
namespace Desktop_progran7
{
    public partial class Form1 : Form
    {
        Random random = new Random();
        Stats stats = new Stats();

        public Form1()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            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 Form1_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 -= 7;
                if (timer1.Interval > 100)
                    timer1.Interval -= 2;
                difficultyProgressBar.Value = 800 - timer1.Interval;

                stats.Update(true);
            }
            else
            {
                stats.Update(false);
            }

            correctLabel.Text = "Correct: " + stats.Correct;
            missedLabel.Text = "Missed: " + stats.Missed;
            totalLabel.Text = "Total: " + stats.Total;
            accuracyLabel.Text = "Accuracy: " + stats.Accuracy + "%";
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}


namespace Desktop_progran7
{
    class Stats
    {
        public int Total = 0;
        public int Missed = 0;
        public int Correct = 0;
        public int Accuracy = 0;

        public void Update(bool correctKey)
        {
            Total++;

            if (!correctKey )
            {
                Missed++;
            }
            else
            {
                Correct++;
            }
            Accuracy = 100 * Correct / (Missed + Correct);
        }
    }
}
搜索更多相关主题的帖子: 打字游戏 private public Random 
2017-03-23 18:41
daluji
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-1-13
收藏
得分:0 
有教程就好了
2017-05-20 23:33
MTT
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2017-5-18
收藏
得分:0 
有压缩包就好了
2017-05-21 21:39
快速回复:C#打字游戏
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.051949 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved