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 = , j = ; 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 = ;
}
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 / - feiji.Width / , feiji.Top));
Label zd = new Label();
zd.Size = new Size(, );
zd.Location = new Point(new Size(feiji.Left + feiji.Width / - zd.Width / + , feiji.Top));
zd.Text = item.Text;
zd.Tag = "zidan";
zd.Image = imageList2.Images[];
zd.AutoSize = true;
Panel1.Controls.Add(zd);
istrue = false;
}
}
}
}
Random a = new Random();
private void timer1_Tick(object sender, EventArgs e)
{
Label lab = new Label();
lab.BackColor = Color.Transparent;
lab.Size = new Size(, );
lab.Text = Convert.ToChar(a.Next(, )).ToString();
lab.ForeColor = Color.FromArgb(a.Next(), a.Next(), a.Next());
lab.Font = new Font("微软雅黑", );
lab.Location = new Point(new Size(a.Next(, Panel1.Width - lab.Width - ), ));
lab.AutoSize = true;
lab.Tag = "zimu";
this.Panel1.Controls.Add(lab);
}
private void timer2_Tick(object sender, EventArgs e)
{
foreach (Control item in Panel1.Controls)
{
if (item.GetType().Name == "Label")
{
if (item.Tag.ToString() == "zimu" || item.Tag.ToString() == "bj")
{
item.Top += ;
if (item.Bottom >= feiji.Top)
{
item.Dispose();
j += ;
label2.Text = "错误:" + j;
}
}
if (item.Tag.ToString() == "zidan")
{
item.Top -= ;
foreach (Control xz in Panel1.Controls)
{
if (xz.GetType().Name == "Label")
{
if (xz.Tag.ToString() == "bj")
{
if (xz.Bottom >= item.Top)
{
PictureBox pb = new PictureBox();
pb.Image = imageList1.Images[];
pb.BackColor = Color.Transparent;
pb.Location = item.Location;
pb.Tag = ;
pb.Size = new Size(, );
pb.SizeMode = PictureBoxSizeMode.StretchImage;
//pb.BackColor = Color.Red;
Panel1.Controls.Add(pb);
timer3.Start();
s.Play();
item.Tag = ;
xz.Dispose();
item.Dispose();
i += ;
label1.Text = "分数:" + i;
istrue = true;
}
}
}
}
}
}
}
} private void timer3_Tick(object sender, EventArgs e)
{
foreach (Control item in Panel1.Controls)
{
if (item.GetType().Name == "PictureBox" && item.Tag != null)
{
int n = int.Parse(item.Tag.ToString());
n++;
if (n > )
{
item.Dispose();
return;
}
((PictureBox)item).Image = imageList1.Images[n];
((PictureBox)item).Tag = n;
}
}
} private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
if (comboBox1.Text == "长平之战")
{
this.BackgroundImage = new Bitmap("2.jpg");
}
if (comboBox1.Text == "赤壁之战")
{
this.BackgroundImage = new Bitmap("3.jpg");
}
if (comboBox1.Text == "蓝色星球")
{
this.BackgroundImage = Image.FromFile("1.jpg");
}
} private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "开始")
{
timer1.Start();
timer2.Start();
button1.Text = "暂停";
}
else
{
button1.Text = "开始";
timer1.Stop();
timer2.Stop();
}
} private void timer4_Tick(object sender, EventArgs e)
{ foreach (Control item in Panel1.Controls)
{
if (item.GetType().Name == "Label" && item.Tag.ToString() == "zidan")
{
item.BackColor = Color.Transparent;
int m = int.Parse(((Label)item).Image.Tag.ToString());
m++;
if (m > )
{
item.Dispose();
return;
}
((Label)item).Image = imageList2.Images[m];
((Label)item).Image.Tag = m;
}
}
}
}
}

C#编写一个大字母游戏,详细代码,不懂问博主。。。。的更多相关文章

  1. python新手如何编写一个猜数字小游戏

    此文章只针对新手,希望大家勿喷,感谢!话不多说先上代码: import random if __name__ == '__main__': yourname = input("你好! 你的名 ...

  2. 25.Qt Quick QML-500行代码实现"合成大西瓜游戏"

    "合成大西瓜"这个游戏在年前很火热,还上过微博热搜,最近便玩了一阵还挺有意思的,所以研究了一下小球碰撞原理,自己亲自手写碰撞算法来实现一个合成大西瓜游戏.并支持任意大小布局,你想玩 ...

  3. 编写一个算法,将非负的十进制整数转换为其他进制的数输出,10及其以上的数字从‘A’开始的字母表示

    编写一个算法,将非负的十进制整数转换为其他进制的数输出,10及其以上的数字从‘A’开始的字母表示. 要求: 1) 采用顺序栈实现算法: 2)从键盘输入一个十进制的数,输出相应的八进制数和十六进制数. ...

  4. 代码实现:编写一个函数,输入n为偶数时,调用函数求1/2+1/4+...+1/n,当输入n为奇数时,调用函数1/1+1/3+...+1/n

    import java.util.Scanner; //编写一个函数,输入n为偶数时,调用函数求1/2+1/4+...+1/n,当输入n为奇数时,调用函数1/1+1/3+...+1/n public ...

  5. 如何建立一个完整的游戏AI

    http://blog.friskit.me/2012/04/how-to-build-a-perfect-game-ai/ 人工智能(Artificial Intelligence)在游戏中使用已经 ...

  6. 编写快速、高效的JavaScript代码

    许多Javascript引擎都是为了快速运行大型的JavaScript程序而特别设 计的,例如Google的V8引擎(Chrome浏览器,Node均使用该引擎).在开发过程中,如果你关心你程序的内存和 ...

  7. Java图形界面实战案例——实现打字母游戏

    实现打字母的游戏 这次这个案例能够说是头几次所讲的内容的一个技术汇总,主要是 运用了几大块的知识.我们先来定义一下案例的背景:在一个300*400的窗口上.有10个随机产生的字母下落,在键盘上敲击字母 ...

  8. GJM : 各大开发游戏引擎

    感谢您的阅读.喜欢的.有用的就请大哥大嫂们高抬贵手"推荐一下"吧!你的精神支持是博主强大的写作动力以及转载收藏动力.欢迎转载! 版权声明:本文原创发表于 [请点击连接前往] ,未经 ...

  9. 使用Vue编写点击数字小游戏

    使用vue编写一个点击数字计时小游戏,列入你在文本框中输入3,点击开始会生成一个3行3列的表格,表格数据为1-9随机排列,这时候从1开始点击,按顺序点到9,当按正确顺序点击完毕,会提示所用的时间,如果 ...

随机推荐

  1. Caused by:java.sql.SQLException:ORA-01008:并非所有变量都已绑定

    1.错误描述 Caused by:java.sql.SQLException:ORA-01008:并非所有变量都已绑定 2.错误原因 3.解决办法

  2. E: 未发现软件包 install_flash_player_11_linux.x86_64.tar.gz

    1 错误描述 youhaidong@youhaidong:~$ sudo apt-get install install_flash_player_11_linux.x86_64.tar.gz 正在读 ...

  3. box-sizing -- 盒模型

    项目开发中,在浏览同事的代码,发现他经常用一个属性--box-sizing,很好奇是什么,于是乎,上网查阅资料学了起来. 首先我们先复习一下盒模型的组成:一个div通常由 content(内容)+ma ...

  4. Java冒泡排序法升级版

    /*  * 冒泡排序之升级版,可比较整型数组.小数型数组  *   * */ public static <T extends Comparable<T>> void Bubb ...

  5. Python机器学习中文版

    Python机器学习简介 第一章 让计算机从数据中学习 将数据转化为知识 三类机器学习算法 第二章 训练机器学习分类算法 透过人工神经元一窥早期机器学习历史 使用Python实现感知机算法 基于Iri ...

  6. spring boot redis分布式锁

    随着现在分布式架构越来越盛行,在很多场景下需要使用到分布式锁.分布式锁的实现有很多种,比如基于数据库. zookeeper 等,本文主要介绍使用 Redis 做分布式锁的方式,并封装成spring b ...

  7. ssm整合快速入门程序(一)

    整合基础说明 spring 是一个开放源代码的设计层面框架,他解决的是业务逻辑层和其他各层的松耦合问题,因此它将面向接口的编程思想贯穿整个系统应用.Spring是于2003 年兴起的一个轻量级的Jav ...

  8. BZOJ 3527: [ZJOI2014]力(FFT)

    BZOJ 3527: [ZJOI2014]力(FFT) 题意: 给出\(n\)个数\(q_i\),给出\(Fj\)的定义如下: \[F_j=\sum \limits _ {i < j} \fra ...

  9. 【noip模拟】最小点覆盖

    Time Limit: 1000ms      Memory Limit: 128MB Description 最小点覆盖是指在二分图中,用最小的点集覆盖所有的边.当然,一个二分图的最小点覆盖可能有很 ...

  10. 软件License认证方案的设计思路

    销售license是商业软件的贯用商业模式.用户向商家购买软件安装盘搭载license许可,才可以使用该软件.我们作为软件开发者,为了保护自身的权益,在软件开发过程中也不可避免的会设计license管 ...