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.