很简单,就是调用罗云斌老师做好的DLL。
附上源码!
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Text;
7
using System.Windows.Forms;
8
using System.Runtime.InteropServices;
9![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
namespace water
11![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
12
public partial class Form1 : Form
13![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
14
public Form1()
15![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
16
InitializeComponent();
17
}
18![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
[DllImport("Wave.dll")]
20
public static extern int E_WaveInit(IntPtr hwnd, string bmpStr);//初始化对象
21
[DllImport("Wave.dll")]
22
public static extern int E_AutoEffects(int type, int type1, int type2, int type3);//效果类型
23
[DllImport("Wave.dll")]
24
public static extern int E_WaveDropStone(int x,int y,int dx,int zl);//仍石头
25
[DllImport("Wave.dll")]
26
public static extern void E_WaveFree();//释放对象
27![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
28
Random r = new Random();//置随机数种子
29![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
30
private void Form1_Load(object sender, EventArgs e)
31![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
32
E_WaveInit(this.Handle, Application.StartupPath + "\\wave.bmp");
33
E_AutoEffects(2,0,0,0);
34
}
35![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
36
private void btnXY_Click(object sender, EventArgs e)
37![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
38
E_AutoEffects(1, r.Next(3, 25), r.Next(0, 5), r.Next(50, 250));
39
}
40![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
41
private void btnCZ_Click(object sender, EventArgs e)
42![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
43
E_AutoEffects(2, r.Next(3, 7), r.Next(1, 5), r.Next(100, 500));
44
}
45![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
46
private void btnFL_Click(object sender, EventArgs e)
47![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
48
E_AutoEffects(3, r.Next(50, 300), r.Next(2, 5), r.Next(5, 10));
49
}
50![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
51
private void btnStop_Click(object sender, EventArgs e)
52![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
53
E_AutoEffects(0, 0, 0, 0);
54
}
55![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
56
private void btnDispos_Click(object sender, EventArgs e)
57![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
58
if (btnDispos.Text == "卸载")
59![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
60
E_WaveFree();//释放资源
61
btnDispos.Text = "加载";
62
}
63
else
64![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
65
E_WaveInit(this.Handle, Application.StartupPath + "\\wave.bmp");
66
btnDispos.Text = "卸载";
67
}
68![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
69
}
70![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
71
private void btnExit_Click(object sender, EventArgs e)
72![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
73
E_WaveFree();//释放资源
74
Application.Exit();
75
}
76![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
77
private void Form1_MouseMove(object sender, MouseEventArgs e)
78![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
79
E_WaveDropStone(e.X, e.Y, r.Next(0, 5), r.Next(300, 800));
80
}
81![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
82
private void Form1_MouseDown(object sender, MouseEventArgs e)
83![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
84
E_WaveDropStone(e.X, e.Y, r.Next(0, 5), r.Next(300, 800));
85
}
86
}
87
}
88![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
这里没有做过多的解释,菜鸟的人也可以看懂!
需要源码的话,请点击这里下载