using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms; // must be added if going by Keys
namespace A___B___Type___Climb
{
//
// Description of Single.
//
public partial class Single : Form
{
private int timeLeft = 60;
private int score = 0;
private string currentWord;
private Random rand = new Random();
private List wordList = new List { "apple", "banana", "orange", "grape", "cherry", "mango", "lemon", "peach", "berry", "melon" };
private int wordsTyped = 0;
public Single()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
timer1.Stop();
textBox1.KeyDown += new KeyEventHandler(TextBox1KeyDown);
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void Single_PlayerLoad(object sender, EventArgs e){
timeLeft = 60; // Reset time
label2.Text = "Time: 60 secs";
label1.Text = "Score: 00";
label4.Text = "Generated Word:";
textBox1.Text = "";
GenerateNewWord();
textBox1.Enabled = false; //This was to make sure that the timer doesn't automatically starts.
label4.Text = "---";
}
void Button1Click(object sender, EventArgs e)
{
if (!timer1.Enabled){ //Once pressed, the timer will start.
timeLeft = 60;
score = 0;
wordsTyped = 0;
label2.Text = "Time: 60 secs:";
label1.Text = "Score: 00";
textBox1.Enabled = true;
textBox1.Clear();
GenerateNewWord();
timer1.Start(); // Start countdown
}
}
void Timer1Tick(object sender, EventArgs e)
{
if (timeLeft > 0){
timeLeft--;
label2.Text = string.Format("Time: {0}:{1:D2} mins", timeLeft / 60, timeLeft % 60);
double elapsedTime = (60 - timeLeft) / 60.0;
int wpm = (elapsedTime > 0) ? (int)Math.Round(wordsTyped / elapsedTime) : 0;
label5.Text = "Words per Minute: " + wpm.ToString("D2");
}
else{
timer1.Stop();
textBox1.Enabled = false;
int finalscore = score;
int finalwordsTyped = wordsTyped;
int finalwpm = (wordsTyped > 0) ? (int)Math.Round(finalwordsTyped / 1.0) : 0;
MessageBox.Show(string.Format("Game Over!\nFinal Score: {0} \nWords per Minute: {1}", finalscore, finalwpm));
}
}
void GenerateNewWord(){
currentWord = wordList[rand.Next(wordList.Count)];
label4.Text = "" + currentWord;
}
void Label2Click(object sender, EventArgs e)
{
}
void Label1Click(object sender, EventArgs e)
{
}
void Label3Click(object sender, EventArgs e)
{
}
void Label4Click(object sender, EventArgs e)
{
currentWord = wordList[rand.Next(wordList.Count)];
label4.Text = "" + currentWord;
}
void TextBox1TextChanged(object sender, EventArgs e)
{
}
void TextBox1KeyDown(object sender, KeyEventArgs e){
if (e.KeyCode == Keys.Enter){
if (textBox1.Text.Trim().Equals(currentWord, StringComparison.OrdinalIgnoreCase)){
score += 10;
wordsTyped++;
label1.Text = "Score: " + score.ToString("D2");
textBox1.Clear();
GenerateNewWord();
}
}
}
void SingleLoad(object sender, EventArgs e)
{
}
void Label5Click(object sender, EventArgs e)
{
}
}
}
< /code>
^^^ Я и мой одноклассник были в групповом проекте о проекте, но я действительно не знаю, как это будет выглядеть. Итак, вот кодирования. Примечание: я новичок на этом сайте, поэтому, пожалуйста, идите на меня. Я также надеюсь, что правильно понял теги.
Подробнее здесь: https://stackoverflow.com/questions/794 ... player-two
Как преобразовать это как игрока два? ⇐ C#
Место общения программистов C#
1740049628
Anonymous
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms; // must be added if going by Keys
namespace A___B___Type___Climb
{
//
// Description of Single.
//
public partial class Single : Form
{
private int timeLeft = 60;
private int score = 0;
private string currentWord;
private Random rand = new Random();
private List wordList = new List { "apple", "banana", "orange", "grape", "cherry", "mango", "lemon", "peach", "berry", "melon" };
private int wordsTyped = 0;
public Single()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
timer1.Stop();
textBox1.KeyDown += new KeyEventHandler(TextBox1KeyDown);
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void Single_PlayerLoad(object sender, EventArgs e){
timeLeft = 60; // Reset time
label2.Text = "Time: 60 secs";
label1.Text = "Score: 00";
label4.Text = "Generated Word:";
textBox1.Text = "";
GenerateNewWord();
textBox1.Enabled = false; //This was to make sure that the timer doesn't automatically starts.
label4.Text = "---";
}
void Button1Click(object sender, EventArgs e)
{
if (!timer1.Enabled){ //Once pressed, the timer will start.
timeLeft = 60;
score = 0;
wordsTyped = 0;
label2.Text = "Time: 60 secs:";
label1.Text = "Score: 00";
textBox1.Enabled = true;
textBox1.Clear();
GenerateNewWord();
timer1.Start(); // Start countdown
}
}
void Timer1Tick(object sender, EventArgs e)
{
if (timeLeft > 0){
timeLeft--;
label2.Text = string.Format("Time: {0}:{1:D2} mins", timeLeft / 60, timeLeft % 60);
double elapsedTime = (60 - timeLeft) / 60.0;
int wpm = (elapsedTime > 0) ? (int)Math.Round(wordsTyped / elapsedTime) : 0;
label5.Text = "Words per Minute: " + wpm.ToString("D2");
}
else{
timer1.Stop();
textBox1.Enabled = false;
int finalscore = score;
int finalwordsTyped = wordsTyped;
int finalwpm = (wordsTyped > 0) ? (int)Math.Round(finalwordsTyped / 1.0) : 0;
MessageBox.Show(string.Format("Game Over!\nFinal Score: {0} \nWords per Minute: {1}", finalscore, finalwpm));
}
}
void GenerateNewWord(){
currentWord = wordList[rand.Next(wordList.Count)];
label4.Text = "" + currentWord;
}
void Label2Click(object sender, EventArgs e)
{
}
void Label1Click(object sender, EventArgs e)
{
}
void Label3Click(object sender, EventArgs e)
{
}
void Label4Click(object sender, EventArgs e)
{
currentWord = wordList[rand.Next(wordList.Count)];
label4.Text = "" + currentWord;
}
void TextBox1TextChanged(object sender, EventArgs e)
{
}
void TextBox1KeyDown(object sender, KeyEventArgs e){
if (e.KeyCode == Keys.Enter){
if (textBox1.Text.Trim().Equals(currentWord, StringComparison.OrdinalIgnoreCase)){
score += 10;
wordsTyped++;
label1.Text = "Score: " + score.ToString("D2");
textBox1.Clear();
GenerateNewWord();
}
}
}
void SingleLoad(object sender, EventArgs e)
{
}
void Label5Click(object sender, EventArgs e)
{
}
}
}
< /code>
^^^ Я и мой одноклассник были в групповом проекте о проекте, но я действительно не знаю, как это будет выглядеть. Итак, вот кодирования. Примечание: я новичок на этом сайте, поэтому, пожалуйста, идите на меня. Я также надеюсь, что правильно понял теги.
Подробнее здесь: [url]https://stackoverflow.com/questions/79454269/how-to-convert-this-into-as-a-player-two[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия