|

楼主 |
发表于 2009-8-30 21:53:00
|
显示全部楼层
Re:游戏逻辑开发中的“超超级技巧”
State Astate, Bstate;
delegate void State(int dt);
private void Form1_Load(object sender, EventArgs e)
{
{
State state0 = null;
Astate = state0 = delegate(int dt0)
{
button1.Left = 10;
button1.Top = 10;
State state1 = null;
Astate = state1 = delegate(int dt1)
{
button1.Left += dt1 / 10;
if (button1.Left > 200)
{
State state2;
Astate = state2 = delegate(int dt2)
{
button1.Left -= dt2 / 10;
button1.Top += dt2 / 10;
if (button1.Left < 10)
{
Astate = state0;
}
};
}
};
};
}
{
State state0 = null;
Bstate = state0 = delegate(int dt0)
{
button2.Left = 10;
button2.Top = 200;
State state1 = null;
Bstate = state1 = delegate(int dt1)
{
button2.Left += dt1 / 10;
if (button1.Left > 200)
{
State state2;
Bstate = state2 = delegate(int dt2)
{
button2.Left -= dt2 / 10;
button2.Top -= dt2 / 10;
if (button1.Left < 10)
{
Bstate = state0;
}
};
}
};
};
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (Astate != null) Astate(timer1.Interval);
if (Bstate != null) Bstate(timer1.Interval);
} |
|