Wie konvertiere ich das als Spieler zwei?C#

Ein Treffpunkt für C#-Programmierer
Guest
 Wie konvertiere ich das als Spieler zwei?

Post by Guest »

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>
^^^ Ich und mein Klassenkameraden waren in einem Gruppenprojekt über das Projekt, aber ich weiß wirklich nicht, wie es aussehen wird. Hier sind also die Codierungen. Hinweis: Ich bin neu auf dieser Seite, also bitte mach mich leicht. Ich hoffe auch, dass ich die Tags richtig gemacht habe. "

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post