using System;
using System.Drawing;
using System.Windows.Forms;
using System.Media;
namespace dazimuyouxi_2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int i = 0, j = 0;
private void Form1_Load(object sender, EventArgs e)
{
label1.BackColor = Color.Green;
label2.BackColor = Color.Red;
label1.Text = "分数:" + i;
label2.Text = "错误:" + j;
this.KeyPress += Form1_KeyPress;
this.comboBox1.SelectedIndex = 0;
}
bool istrue = true;
SoundPlayer s = new SoundPlayer("GRAY2WEA.WAV");
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
foreach (Control item in Panel1.Controls)
{
if (item.Text == e.KeyChar.ToString().ToUpper())
{
if (istrue == true)
{
item.Tag = "bj";
feiji.Location = new Point(new Size(item.Left + item.Width / 2 - feiji.Width / 2, feiji.Top));
Label zd = new Label();
zd.Size = new Size(40, 40);
zd.Location = new Point(new Size(feiji.Left + feiji.Width / 2 - zd.Width / 2 + 20, feiji.Top));
C#编写一个打字母游戏,详细代码。。。。。
最新推荐文章于 2024-07-13 11:55:33 发布
这个博客介绍了一个使用C#编程实现的字母射击游戏。游戏中,字母随机出现在屏幕上,玩家需要通过键盘输入来击中它们。游戏计分系统记录正确的命中和错误,背景和音效增强了游戏体验。游戏还允许玩家选择不同的背景主题。
摘要由CSDN通过智能技术生成