1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using System.Media;
  5.  
  6. namespace dazimuyouxi_2
  7. {
  8. public partial class Form1 : Form
  9. {
  10. public Form1()
  11. {
  12. InitializeComponent();
  13. }
  14. int i = , j = ;
  15.  
  16. private void Form1_Load(object sender, EventArgs e)
  17. {
  18. label1.BackColor = Color.Green;
  19. label2.BackColor = Color.Red;
  20. label1.Text = "分数:" + i;
  21. label2.Text = "错误:" + j;
  22. this.KeyPress += Form1_KeyPress;
  23. this.comboBox1.SelectedIndex = ;
  24. }
  25. bool istrue = true;
  26. SoundPlayer s = new SoundPlayer("GRAY2WEA.WAV");
  27. private void Form1_KeyPress(object sender, KeyPressEventArgs e)
  28. {
  29.  
  30. foreach (Control item in Panel1.Controls)
  31. {
  32. if (item.Text == e.KeyChar.ToString().ToUpper())
  33. {
  34. if (istrue == true)
  35. {
  36. item.Tag = "bj";
  37. feiji.Location = new Point(new Size(item.Left + item.Width / - feiji.Width / , feiji.Top));
  38. Label zd = new Label();
  39. zd.Size = new Size(, );
  40. zd.Location = new Point(new Size(feiji.Left + feiji.Width / - zd.Width / + , feiji.Top));
  41. zd.Text = item.Text;
  42. zd.Tag = "zidan";
  43. zd.Image = imageList2.Images[];
  44. zd.AutoSize = true;
  45. Panel1.Controls.Add(zd);
  46. istrue = false;
  47. }
  48. }
  49. }
  50. }
  51. Random a = new Random();
  52. private void timer1_Tick(object sender, EventArgs e)
  53. {
  54. Label lab = new Label();
  55. lab.BackColor = Color.Transparent;
  56. lab.Size = new Size(, );
  57. lab.Text = Convert.ToChar(a.Next(, )).ToString();
  58. lab.ForeColor = Color.FromArgb(a.Next(), a.Next(), a.Next());
  59. lab.Font = new Font("微软雅黑", );
  60. lab.Location = new Point(new Size(a.Next(, Panel1.Width - lab.Width - ), ));
  61. lab.AutoSize = true;
  62. lab.Tag = "zimu";
  63. this.Panel1.Controls.Add(lab);
  64. }
  65. private void timer2_Tick(object sender, EventArgs e)
  66. {
  67. foreach (Control item in Panel1.Controls)
  68. {
  69. if (item.GetType().Name == "Label")
  70. {
  71. if (item.Tag.ToString() == "zimu" || item.Tag.ToString() == "bj")
  72. {
  73. item.Top += ;
  74. if (item.Bottom >= feiji.Top)
  75. {
  76. item.Dispose();
  77. j += ;
  78. label2.Text = "错误:" + j;
  79. }
  80. }
  81. if (item.Tag.ToString() == "zidan")
  82. {
  83. item.Top -= ;
  84. foreach (Control xz in Panel1.Controls)
  85. {
  86. if (xz.GetType().Name == "Label")
  87. {
  88. if (xz.Tag.ToString() == "bj")
  89. {
  90. if (xz.Bottom >= item.Top)
  91. {
  92. PictureBox pb = new PictureBox();
  93. pb.Image = imageList1.Images[];
  94. pb.BackColor = Color.Transparent;
  95. pb.Location = item.Location;
  96. pb.Tag = ;
  97. pb.Size = new Size(, );
  98. pb.SizeMode = PictureBoxSizeMode.StretchImage;
  99. //pb.BackColor = Color.Red;
  100. Panel1.Controls.Add(pb);
  101. timer3.Start();
  102. s.Play();
  103. item.Tag = ;
  104. xz.Dispose();
  105. item.Dispose();
  106. i += ;
  107. label1.Text = "分数:" + i;
  108. istrue = true;
  109. }
  110. }
  111. }
  112. }
  113. }
  114. }
  115. }
  116. }
  117.  
  118. private void timer3_Tick(object sender, EventArgs e)
  119. {
  120. foreach (Control item in Panel1.Controls)
  121. {
  122. if (item.GetType().Name == "PictureBox" && item.Tag != null)
  123. {
  124. int n = int.Parse(item.Tag.ToString());
  125. n++;
  126. if (n > )
  127. {
  128. item.Dispose();
  129. return;
  130. }
  131. ((PictureBox)item).Image = imageList1.Images[n];
  132. ((PictureBox)item).Tag = n;
  133. }
  134. }
  135. }
  136.  
  137. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  138. {
  139. comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
  140. if (comboBox1.Text == "长平之战")
  141. {
  142. this.BackgroundImage = new Bitmap("2.jpg");
  143. }
  144. if (comboBox1.Text == "赤壁之战")
  145. {
  146. this.BackgroundImage = new Bitmap("3.jpg");
  147. }
  148. if (comboBox1.Text == "蓝色星球")
  149. {
  150. this.BackgroundImage = Image.FromFile("1.jpg");
  151. }
  152. }
  153.  
  154. private void button1_Click(object sender, EventArgs e)
  155. {
  156. if (button1.Text == "开始")
  157. {
  158. timer1.Start();
  159. timer2.Start();
  160. button1.Text = "暂停";
  161. }
  162. else
  163. {
  164. button1.Text = "开始";
  165. timer1.Stop();
  166. timer2.Stop();
  167. }
  168. }
  169.  
  170. private void timer4_Tick(object sender, EventArgs e)
  171. {
  172.  
  173. foreach (Control item in Panel1.Controls)
  174. {
  175. if (item.GetType().Name == "Label" && item.Tag.ToString() == "zidan")
  176. {
  177. item.BackColor = Color.Transparent;
  178. int m = int.Parse(((Label)item).Image.Tag.ToString());
  179. m++;
  180. if (m > )
  181. {
  182. item.Dispose();
  183. return;
  184. }
  185. ((Label)item).Image = imageList2.Images[m];
  186. ((Label)item).Image.Tag = m;
  187. }
  188. }
  189. }
  190. }
  191. }

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. Flex设置LinkButton的背景色

    1.设计思路    由于Flex中没有设置LinkButton的背景色的属性,现在得从两个方面入手:第一,直接通过调用样式方法画出LinkButton的背景色:第二,设置LinkButton的背景图片 ...

  2. JavaScript的几种常见的创建方式

    1.通过Object构造函数或者对象字面量创建单个对象 使用字面量方法创建对象:var stut = {name: "张三"}; 使用内置构造函数创建对象:var stu = ne ...

  3. docker学习系列(三):docker镜像的分层结构

    docker的镜像分层 docker里的镜像绝大部分都是在别的镜像的基础上去进行创建的,也就是使用镜像的分层结构. 实验 比如说使用dockerfile去创建一个最简单的hello镜像.创建好对应的d ...

  4. JavaScript设计模式(7)-设配器模式

    适配器模式 1. 作用: 协调两个不同的接口 2. 适用场景 适配器适用于客户期待的接口与现有 API 提供的接口不兼容这种场景.他只能用来协调语法上的差异问题.适配器所适配的两个方法执行的应该是类似 ...

  5. 自己写的,然后配合zepto+iscroll的上拉加载

    /** * Created by jl on 2016/3/28. *///初始化绑定iScroll控件var actHtml="";var myScroll,    pullUp ...

  6. 【NOIP2012】【CJOJ1093】【洛谷1083】借教室

    我写的是不完美算法!!! 题面 Description 在大学期间,经常需要租借教室.大到院系举办活动,小到学习小组自习讨论,都需要 向学校申请借教室.教室的大小功能不同,借教室人的身份不同,借教室的 ...

  7. 【NOIP2015】子串(动态规划)

    题目戳我 题解 很简单的一道题... 看来那时候还是我太菜了... 设f[i][j][k][0/1]表示在第一个串中的位置i,匹配到了位置j,一共分了k段,0/1表示上一个位置是否在某一段中 转移就很 ...

  8. 【HNOI 2002 】营业额统计(splay)

    题面 Description Tiger最近被公司升任为营业部经理,他上任后接受公司交给的第一项任务便是统计并分析公司成立以来的营业情况. Tiger拿出了公司的账本,账本上记录了公司成立以来每天的营 ...

  9. 【noip模拟】局部最小值

    TimeLimit: 1000ms               MemoryLimit: 256MB Description 有一个n行m列的整数矩阵,其中1到n×m之间的每个整数恰好出现一次.如果一 ...

  10. Handsontable 筛选事件

    有时候我们需要知道在使用Handsontable时筛选掉了哪些数据,并对这些数据进行处理,可以使用afterFilter事件来进行相关操作. Handsontable筛选掉的数据没有真的被删除,而是被 ...