110,534
社区成员
发帖
与我相关
我的任务
分享
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;
namespace shake_shake
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnsend_Click(object sender, EventArgs e)
{
txtget.Text = txtsend.Text + System.Environment.NewLine +System.DateTime.Now.Day;
txtsend.Clear();
}
private void btnshake_Click(object sender, EventArgs e)
{
int recordx = this.Left;
int recordy = this.Top;
Random raline = new Random();
for (int i = 0; i < 1000; i++)
{
int x = raline.Next(recordx);//别人说这里是rand。不懂什么意思
int y = raline.Next(recordy);
if (x % 2 == 0)
{
this.Left=this.Left + x;
}
else
{
this.Left = this.Left - x ;
}
if (y % 2 == 0)
{
this.Top = this.Top +y;
}
else
{
this.Top = this.Top - y;
}
//System.Threading.Thread.Sleep(1);//不知道这句什么意思
}
this.Left = recordx;
this.Top = recordy;
}
}
}
//问题1:为什么震动的时候,窗体在屏幕中不停乱跑,不像qq震动一样呢?问题2:int x = raline.Next(recordx);//别人说这里是rand。不懂什么意思/。问题3:System.Threading.Thread.Sleep(1);//不知道这句什么意思