C#编写一个大字母游戏,详细代码,不懂问博主。。。。
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#编写一个大字母游戏,详细代码,不懂问博主。。。。的更多相关文章
- python新手如何编写一个猜数字小游戏
此文章只针对新手,希望大家勿喷,感谢!话不多说先上代码: import random if __name__ == '__main__': yourname = input("你好! 你的名 ...
- 25.Qt Quick QML-500行代码实现"合成大西瓜游戏"
"合成大西瓜"这个游戏在年前很火热,还上过微博热搜,最近便玩了一阵还挺有意思的,所以研究了一下小球碰撞原理,自己亲自手写碰撞算法来实现一个合成大西瓜游戏.并支持任意大小布局,你想玩 ...
- 编写一个算法,将非负的十进制整数转换为其他进制的数输出,10及其以上的数字从‘A’开始的字母表示
编写一个算法,将非负的十进制整数转换为其他进制的数输出,10及其以上的数字从‘A’开始的字母表示. 要求: 1) 采用顺序栈实现算法: 2)从键盘输入一个十进制的数,输出相应的八进制数和十六进制数. ...
- 代码实现:编写一个函数,输入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 ...
- 如何建立一个完整的游戏AI
http://blog.friskit.me/2012/04/how-to-build-a-perfect-game-ai/ 人工智能(Artificial Intelligence)在游戏中使用已经 ...
- 编写快速、高效的JavaScript代码
许多Javascript引擎都是为了快速运行大型的JavaScript程序而特别设 计的,例如Google的V8引擎(Chrome浏览器,Node均使用该引擎).在开发过程中,如果你关心你程序的内存和 ...
- Java图形界面实战案例——实现打字母游戏
实现打字母的游戏 这次这个案例能够说是头几次所讲的内容的一个技术汇总,主要是 运用了几大块的知识.我们先来定义一下案例的背景:在一个300*400的窗口上.有10个随机产生的字母下落,在键盘上敲击字母 ...
- GJM : 各大开发游戏引擎
感谢您的阅读.喜欢的.有用的就请大哥大嫂们高抬贵手"推荐一下"吧!你的精神支持是博主强大的写作动力以及转载收藏动力.欢迎转载! 版权声明:本文原创发表于 [请点击连接前往] ,未经 ...
- 使用Vue编写点击数字小游戏
使用vue编写一个点击数字计时小游戏,列入你在文本框中输入3,点击开始会生成一个3行3列的表格,表格数据为1-9随机排列,这时候从1开始点击,按顺序点到9,当按正确顺序点击完毕,会提示所用的时间,如果 ...
随机推荐
- ORA-00904:"T1"."AREA_ID" :标识符无效
1.错误描述 ORA-00904:"T1"."AREA_ID" :标识符无效 00904 . 00000 - "%s:invalid identifi ...
- VS2017 启动调试报错:ID为{....}进程未启动解决方案
今天遇到这么一个问题,打开VS启动调试,始终报错,如下图: 我重启VS,甚至重启电脑都不得行,那个进程号还在变化,就在网上查找资料,各式各样的解决方案,这里我记录我成功的方案. 打开项目文件地址,在解 ...
- Maven使用中央仓库下载慢的解决办法
配置Maven仓库的方法 打开Maven配置文件Setting.xml,如下: vim /Users/yuanweipeng/.m2/settings.xml 在配置文件中添加如下配置: <mi ...
- Css多列语法笔记
columns多列属性定义: column-width:规定列的宽度(此宽度是缩放scale以后的最小宽度): column-count:规定元素被分隔的列数: column-rule设置所有colu ...
- Educational Codeforces Round 37
Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. W ...
- 【BZOJ3262】陌上花开(树套树)
[BZOJ3262]陌上花开(树套树) 题面 对于权限题,我这种苦逼肯定是从别的OJ上搞的对不对??? CJOJ 洛谷 Description 有n朵花,每朵花有三个属性:花形(s).颜色(c).气味 ...
- [BZOJ4292] [PA2015] Równanie
Description 对于一个正整数n,定义f(n)为它十进制下每一位数字的平方的和.现在给定三个正整数k,a,b,请求出满足a<=n<=b且k*f(n)=n的n的个数. Input 第 ...
- OpenAI dota2大战人类顶尖选手视频
AI大战Dendi:http://www.bilibili.com/video/av13267474/?zw#quality=3 AI大战Sumail:http://www.bilibili.com/ ...
- golang 互斥锁和读写锁
golang 互斥锁和读写锁 golang中sync包实现了两种锁Mutex(互斥锁)和RWMutex(读写锁),其中RWMutex是基于Mutex实现的,只读锁的实现使用类似引用计数器的功能. ty ...
- URL中“#”
2010年9月,twitter改版.一个显著变化,就是URL加入了"#!"符号.比如,改版前的用户主页网址为http://twitter.com/username改版后,就变成了h ...