编程
来源:互联网 发布:ce6.0软件 编辑:程序博客网 时间:2024/05/17 06:56
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace TypeWriteGame {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
Form.CheckForIllegalCrossThreadCalls=false;
}
private void Form1_Load(object sender, EventArgs e) {
this.time.Start();
}
int i=0;
private void time_Tick(object sender, EventArgs e) {
try{
Random rPic=new Random();
Label lable=new Label();
lable.Size=new Size(51,51);
lable.Left=rPic.Next(this.Width-50);
lable.Image=Image.FromFile(rPic.Next(10)+".jpg");
lable.Text=Convert.ToChar(65+rPic.Next(57)).ToString();
lable.TextAlign=ContentAlignment.MiddleCenter;
lable.Refresh();
lable.Font=new Font("宋体",15,FontStyle.Bold);
this.Controls.Add(lable);
Thread thread = new Thread(Mover);
thread.IsBackground = true;
thread.Start(lable);
i++;
if (i == 10) {
this.time.Interval -= 10;
i = 0;
}
}
catch(System.Exception E)
{
MessageBox.Show(E.Message);
}
}
Random random = new Random();
public void Mover(Object o) {
Label lbl = o as Label;
int speed = random.Next(3) + 2;
while (lbl.Top < this.Height) {
Thread.Sleep(speed * 5);
this.Invoke(new ParameterizedThreadStart(ChangeLocation), new Object[] { lbl });
}
}
public void ChangeLocation(Object o) {
Label lbl = o as Label;
lbl.Top += 1;
}
private void Form1_KeyPress(object sender, KeyPressEventArgs e) {
foreach (Label lbl in this.Controls)
{
if (lbl == null)
break;
if (lbl.Text[0] == e.KeyChar)
{
lbl.Dispose();
break;
}
}
}
}
}
刚做的打字游戏,希望大家看看,帮我评价一下。
- 编程
- 编程
- 编程
- 编程
- 编程
- 编程!
- 编程
- 编程
- 编程
- 编程
- 编程
- 编程
- 编程
- 编程
- 编程
- 编程
- 编程
- 编程
- No magic, just Basic----- 读《Windows核心编程》前言
- 几种排序
- 正则匹配
- Mac os X 下的截图快捷键
- 2011.5.21 C++中,float double区别
- 编程
- PLSQL导入导出数据库
- 给一个数组,求a[i]<a[j]的情况下,j-i的最大值是多少,要求用O(n)时间复杂度
- malloc、free用法
- 浅析字符编码
- asp RecordCount返回-1
- 一个int数组,求乘起来最大的连续子序列
- DELPHI使用键盘钩子
- HDFS小文件问题及解决方案