//The oject of this "game" is to find the correct combination of button //pushes that will turn on all the lights. You are allowed to push only //the "active" buttons (i.e., the ones with relief shading). Common Int f[]={264,294,328,352,392,438,494,528} Common Int c[]={1,3,2,6,4,5,9,11,10,14,12,13} Common Int s[]={0,0,0,0,0,0,0,0,0,0,0,0} randomize frame (50, 100, 590, 329, 11) solid color (3); solid rectangle (50, 100, 590, 329) line color (0); fill color (9) filled rectangle (78, 210, 560, 252) fill color (12); filled rectangle (290, 275, 348, 315) move mouse (320,232) tabxy (30, 9); draw button (32, " ", 0, 1) disable button (32) Do k=0,11 line color (8); fill color (7) filled circle (40*k+99, 185, 10) draw light (k) @ tabxy (5*k+13, 15); draw button (k+1, " ", 7, -1) disable button (k+1) Loop k tabxy (39, 19); draw button (13, "Quit", 7, 1) disable button (13) newgame: nosound wait quitkey (27, 1000) tabxy (30, 9); Display " ", b=0; hot=random(10)+1 Do k=1,24 b=4-b sound (f[random(4)+b]) n=Random(12); s[n]=1-s[n] draw light (n) @ wait quitkey (27, 100) Loop k nosound Do k=0,11 enable button (k+1) If k=hot Set s[k]=0 Else s[k]=1 draw light (k) @ Loop k enable button (13) tabxy (30, 9); Display "Turn on all the lights", disable button (32) Do read quitkey (27) id=iabs(read buttons()) If id=0 Continue If id=13 Call quit sound (500) win=s[id-1]; lose=1-win Do k=0,11 enable button (k+1) If k+1=id Continue s[k]=1-s[k] If s[k]=0 Set win=0 If s[k]=1 Set lose=0 draw light (k) @ Loop k numon=s[0]; id=0 Do k=1,11 numon=numon+s[k] If s[k] Set id=k If s[k-1] Or s[k] Continue disable button (k+1) disable button (k) Loop k If numon=1 all off @ If id=hot Call enable button (hot+1) Else lose=1 Endif wait quitkey (27, 50); nosound If win all off @ tabxy (30, 9); cwrite (" YOU WIN! ", 2, 0) wait quitkey (27, 250) whistle @ Goto newgame Endif If lose all off @ tabxy (30, 9); cwrite (" You Lose ", 4, 0) wait quitkey (27, 250) id=read buttons() booboo @ id=read buttons() Goto newgame Endif Loop ///////////////////////////////////////////////////////////////////////////// Task draw light (Int k) Common Int c[12], s[12] If s[k] Set z=c[k] Else z=0 line color (8); fill color (z) filled circle (40*k+99, 185, 7) End draw light ///////////////////////////////////////////////////////////////////////////// Task all off Do k=1,13 disable button (k) Loop k End all off ///////////////////////////////////////////////////////////////////////////// Task whistle slide (128, 1024, 3) @ nosound wait quitkey (27, 100) slide (256, 1024, 4) @ slide (1024, 256, -1) @ End whistle ///////////////////////////////////////////////////////////////////////////// Task slide (Int a, Int b, Int c) Do j=a,b,c sound (j); delay (1) id=read buttons() Loop j End slide ///////////////////////////////////////////////////////////////////////////// Task booboo sound (160) wait quitkey (27, 500) id=read buttons() sound (100) wait quitkey (27, 750) End booboo