Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 Typing_Game
- {
- 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 Sucka");
- timer1.Stop();
- }
- }
- private void Form1_KeyDown(object sender, KeyEventArgs e)
- {
- // If the user pressed a key that's in the ListBox, remove it
- // and then make the game a little faster
- 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;
- // The user pressed a correct key, so update the Stats object
- // by calling its Update() method with the argument true
- stats.Update(true);
- }
- else
- {
- // The user pressed an incorrect key, so update the Stats object
- // by calling its Update() method with the argument false
- stats.Update(false);
- }
- //Update the levels on the main GUI
- correctLabel.Text = "Correct: " + stats.Correct;
- missedLabel.Text = "Missed: " + stats.Missed;
- totalLabel.Text = "Total: " + stats.Total;
- accuracyLabel.Text = "Accuracy: " + stats.Accuracy + "%";
- }
- }
- }
Add Comment
Please, Sign In to add comment