//keno example program for Aurora
//Green = selected, yellow = miss, red = hit
//the balls are represented in an integer array
//values for the array are:
//0 = not selected, 1 = selected, 2 = hit, 3 = miss
//Compile as a WINDOWS target
#autodefine "off"
int run;
int selected,hit,miss,playing;
class kenowin:window
{
//overridden virtual methods
declare OnClose(),int;
declare OnCreate(),int;
declare OnPaint(),int;
declare OnLButtonDown(int x,int y, int flags),int;
declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
declare OnChar(unsigned int nChar,INT nRepCnt),int;
declare OnTimer(int nIDEvent),int;
//other methods
declare DrawBalls();
declare SelectBall(int mx,int my);
declare StartPlay();
declare EndPlay();
declare ClearBoard();
declare PickBall();
//class variables
int balls[80];
int hitcount,selectcount,picked;
//The balls colors
selected = RGB(0,255,0);
hit = RGB(255,0,0);
miss = RGB(255,255,0);
//the play window
playwin.Create(0,0,410,400,AWS_VISIBLE|AWS_CAPTION|AWS_SYSMENU|AWS_MINIMIZEBOX,0,"Keno",0);
playwin.SetWindowColor(RGB(0,0,255));
//the buttons
startbtn.Create(0,340,70,20,AWS_VISIBLE,1,"START",playwin);
clearbtn.Create(80,340,70,20,AWS_VISIBLE,2,"CLEAR",playwin);
run = 1;
playing = 0;
do{ wait();}until run = 0;
playwin.Destroy();
return 0;
run = 0;
return true;
CenterWindow();
ClearBoard();
return true;
DrawBalls();
return true;
SelectBall(x,y);
return true;
if(nNotifyCode = 0)
{
select nID
{
CASE 1:
StartPlay();
CASE 2:
ClearBoard();
}
SetFocus();
}
return true;
select nChar
{
CASE ASC("s"):
StartPlay();
CASE ASC("c"):
CASE& ASC("C"):
ClearBoard();
}
return true;
if picked < 20
{
PickBall();
picked = picked + 1;
DrawBalls();
}
else
{
EndPlay();
playing = 0;
}
return true;
int x,y,num;
unsigned int cacheDC,colorball;
string strball,strstat;
cacheDC = GetHDC();
DrawMode(TRANSPARENT);
num = 1;
for( y = 0; y < 8;y++)
{
for( x = 0; x < 10; x++)
{
colorball = 0xFFFFFF;
if balls[num-1] = 1 colorball = selected;
if balls[num-1] = 2 colorball = hit;
if balls[num-1] = 3 colorball = miss;
Circle( (x*40)+20,(y*40)+20,20,0,colorball );
strball = ltrim$(str$(num,0));
if num < 10 strball = "0" + strball;
WriteText( (x*40) + 10, (y*40) + 10,strball );
num = num + 1;
}
}
DrawMode(OPAQUE);
strstat = "Drawn: " + ltrim$(str$(picked,0));
strstat = strstat + " / Hit: " + ltrim$(str$(hitcount,0));
strstat = strstat + " out of " + ltrim$(str$(selectcount,0)) + " ";
WriteText( 155,342,strstat);
ReleaseHDC(cacheDC);
return;
int x,y,num;
if playing return;
x = (mx - 10) / 40.0;
y = (my - 10) / 40.0;
num = x + (y * 10);
if ((num > 79) OR (num < 0)) return;
select balls[num]
{
CASE 3:
CASE& 0:
IF selectcount < 10
{
balls[num] = 1;
selectcount = selectcount + 1;
}
CASE 1:
CASE& 2:
balls[num] = 0;
selectcount = selectcount - 1;
}
DrawBalls();
return;
int x;
if selectcount > 0
{
playing = 1;
picked = 0;
hitcount = 0;
for( x = 0; x < 80; x++)
{
if(balls[x]=3) balls[x] = 0;
if(balls[x]=2) balls[x] = 1;
}
DrawBalls();
StartTimer(100);
EnableControl(m_hWnd,1,0);
EnableControl(m_hWnd,2,0);
}
return;
StopTimer();
EnableControl(m_hWnd,1,1);
EnableControl(m_hWnd,2,1);
return;
int x;
for( x = 0; x< 80; x++) { balls[x] = 0; }
selectcount = 0;
picked = 0;
hitcount = 0;
DrawBalls();
return;
int x,done;
done = 0;
do
{
x = rnd(80);
if ((balls[x] <> 3) AND (balls[x] <> 2)) done = 1;
}
until done;
//If its a selected ball then set it to 'hit'
if balls[x] = 1
{
balls[x] = 2;
hitcount = hitcount + 1;
}
//If its a non selected ball then set it to 'miss'
if balls[x] = 0 balls[x] = 3;
return;
int hControl = GetDlgItem(hParent,id);
if(hControl)
EnableWindow(hControl,bEnable);
return;
}