A simple C # typing game.

Source: Internet
Author: User

This is the entry point.
Using System;
Using system.collections.generic;using system.linq;using system.threading.tasks;using System.Windows.Forms; namespace keygame{    Static class Program {///<summary>//        The main entry point of the application. //        </summary>        [STAThread]        static void Main () {            application.enablevisualstyles ();            Application.setcompatibletextrenderingdefault (false);            Application.Run (New Form1 ());}}}    
The tracking class for the data
<pre name= "code" class= "CSharp" >using system;using system.collections.generic;using system.linq;using System.text;using system.threading.tasks;namespace keygame{    class countstatus    {public        int correct = 0;        public int missed = 0;        public int total = 0;        public float accuracy = 0;        public void Update (bool correctkey) {            if (correctkey) {                correct++;                Accuracy = ((float) correct)/total;                return;            }            missed++;            Accuracy = ((float) correct)/total;            return;}}}    


Form Programs
Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.linq;using system.text;using system.threading.tasks;using system.windows.forms;namespace KEYGAME{     Public partial class form1:form    {        random random = new Random () &NB Sp       Countstatus status = new Countstatus ();        public Form1 () {    &nbs P       InitializeComponent ();       }        private void Timer1_ti CK (object sender, EventArgs e) {            status.total++;        &NBSP ;   LISTBOX1.ITEMS.ADD (Keys) (random. Next (+));            if (ListBox1.Items.Count > 7) {        &NB Sp       ListBox1.Items.Clear ();                Listbox1.items. ADD ("GAME over");                timer1. Stop ();           }       }        private void Fo Rm1_load (object sender, EventArgs e) {            progressBar1.Value = 100;    &NB Sp       Timer1. Stop ();       }        private void Btstart_click (object sender, EventArgs e) {&N Bsp           timer1.  Start ();       }        private void Form1_keydown (object sender, KeyEventArgs e) {            if (ListBox1.Items.Contains (E.keycode)) {          &N Bsp     ListBox1.Items.Remove (e.keycode);                Listbox1.refresh ( );               //this part would increse the difficult of the GAme by putting down the interval                if (timer1. Interval >) timer1. Interval-= 10;                if (timer1. Interval >) timer1. Interval-= 8;                if (timer1. Interval >) timer1. Interval-= 2;                            &NBSP ;   status. Update (True);           } else {                STA Tus. Update (false);           }            progressBar1.Value = 80 0-timer1. interval;            Labelcorrect.text = "Correct:  " +status.correct;    &NB Sp       Labelmiss.text = "Missed:  " +status.missed;            Labeltotal. Text = "total;   " +status.total;            Labelaccuracy.text = "accuracy:" +status. accuracy;       }
}}



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

A simple C # typing game.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.