46
Chapter 7: Flash Application Layout
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
switch (event->command)
{
case CM_START:
WinOpen(&w, event->info.startInfo.startRect, WF_DUP_SCR);
DrawWinBorder(&w, &w.Window);
WinClr(&w);
width = w.Client.xy.x1 - w.Client.xy.x0;
height = w.Client.xy.y1 - w.Client.xy.y0;
/* Pick initial box location */
if (box.x0 == 0 && box.y0 == 0)
{
box.x0 = random(1, width - BOX_DIMENSION - 1);
box.x1 = box.x0 + BOX_DIMENSION;
box.y0 = random(1, height - BOX_DIMENSION - 1);
box.y1 = box.y0 + BOX_DIMENSION;
}
break;
/* User pressed [F1][1:Clear] */
case CM_CLEAR_ALL:
WinClr(&w);
break;
case CM_QUIT:
WinClose(&w);
break;
/* Draw pipes when system is not busy with anything else */
case CM_NULL:
if (boxcount <= 0)
{
// Choose new direction
deltaX = random(2, 4);
if (random(0,99) < 50)
deltaX = -deltaX;
deltaY = random(2, 4);
if (random(0,99) < 50)
deltaY = -deltaY;
boxcount = MAX_BOX;
}
if (box.x0 < 0)
deltaX = sabs(deltaX);
if (box.x1 > width)
deltaX = -sabs(deltaX);