home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
No Fragments Archive 10: Diskmags
/
nf_archive_10.iso
/
MAGS
/
ST_USER
/
1990
/
USEROC90.MSA
/
LISTINGS_RUBICLOC.BSC
< prev
next >
Wrap
Text File
|
1990-08-19
|
5KB
|
171 lines
REM RUBIC'S CLOCK
ESCAPE OFF:CLEAR 512
IF SCREENMODE<>2 THEN PRINT "Set screenmode to hires.":END
PROCpreamble:PROCinit:PROCscreen:done%=FALSE
REPEAT
REPEAT:MOUSE x%,y%,b%,k%:UNTIL k%=4 OR b%=1 OR b%=2
IF k%=4 THEN CLG 0:END
PROCselectbutton
PROCselectwheel
REPEAT:MOUSE x%,y%,b%,k%:UNTIL b%=0
UNTIL done%
TXTSIZE 26:PRINT TAB(0,10);
PRINT " Well done!-You have solved the puzzle. ";
g=GET:CLG 0:END
DEF PROCscreen
FILLSTYLE 2,2:CIRCLE 160,160,150:CIRCLE 480,160,150
FILLSTYLE 0,0
FOR y%=120 TO 200 STEP 80:FOR x%=120 TO 200 STEP 80
CIRCLE x%,y%,11:GTXT x%,y%-2,"U"
CIRCLE x%+320,y%,11:GTXT x%+320,y%-2,"D"
NEXT:NEXT
FOR clock%=1 TO 18
CIRCLE cx%(clock%),cy%(clock%),32
NEXT
PROCclocks
GTXTSIZE 26:GTXT 320,8,"RUBIK CLOCK"
GTXTSIZE 13:GTXT 60,10,"FRONT FACE":GTXT 580,10,"BACK FACE"
a$="TURN"
FOR y%=40 TO 275 STEP 235
GTXT 40,y%,a$:GTXT 285,y%,a$:GTXT 360,y%,a$:GTXT 605,y%,a$
NEXT
PRINT TAB(1,20);"Click on U/D buttons to toggle between Up and Down.";
PRINT "(PRESS CONTROL TO QUIT.)"
PRINT TAB(1);"Click on TURN to turn clocks.";
PRINT "(Left-hand anticlockwise,right-hand clockwise.)"
PRINT TAB(10);"Set all the clocks to 12 o'clock ";
PRINT "to complete the puzzle."
ENDPROC
DEF PROCinit
DIM clock%(18),cx%(18),cy%(18),turn%(18),butt%(7),bx%(7),by%(7),hx%(12),hy%(12)
PROChourxy
FOR clock%=1 TO 18
clock%(clock%)=clock%:IF clock%>9 THEN clock%(clock%)=21-clock%
READ cx%(clock%),cy%(clock%)
turn%(clock%)=1:IF clock%>9 THEN turn%(clock%)=-1
NEXT
DATA 80,80,160,80,240,80,240,160,240,240,160,240,80,240,80,160,160,160
DATA 560,80,480,80,400,80,400,160,400,240,480,240,560,240,560,160,480,160
FOR butt%=1 TO 7 STEP 2
butt%(butt%)=-1
READ bx%(butt%),by%(butt%)
NEXT
DATA 120,120,200,120,200,200,120,200
ENDPROC
DEF PROCselectbutton
butt%=0:bx%=0:by%=0
IF x%>109 AND x%<131 THEN bx%=1
IF x%>189 AND x%<211 THEN bx%=3
IF x%>429 AND x%<451 THEN bx%=3
IF x%>509 AND x%<521 THEN bx%=1
IF y%>109 AND y%<131 THEN by%=1
IF y%>189 AND y%<211 THEN by%=7
butt%=bx%*by%:IF butt%>7 THEN butt%=5
IF butt%>0 THEN PROCbutt
ENDPROC
DEF PROCselectwheel
wheel%=0:wx%=0:wy%=0
IF x%>17 AND x%<59 THEN wx%=1
IF x%>262 AND x%<305 THEN wx%=3
IF x%>336 AND x%<378 THEN wx%=12
IF x%>583 AND x%<625 THEN wx%=10
IF y%>34 AND y%<50 THEN wy%=1
IF y%>270 AND y%<286 THEN wy%=7
wheel%=wx%*wy%
IF wheel%=21 THEN wheel%=5
IF wheel%=84 THEN wheel%=14
IF wheel%=70 THEN wheel%=16
IF wheel%>0 THEN PROCturn
ENDPROC
DEF PROCbutt
BEEP
IF butt%(butt%)=-1 THEN
GTXT bx%(butt%),by%(butt%),"D":GTXT 640-bx%(butt%),by%(butt%),"U"
ELSE
GTXT bx%(butt%),by%(butt%),"U":GTXT 640-bx%(butt%),by%(butt%),"D"
ENDIF
butt%(butt%)=-butt%(butt%)
ENDPROC
DEF PROCturn
IF wheel%<10 THEN front%=2*b%-3 ELSE front%=3-2*b%
back%=-front%:IF wheel%>9 THEN wheel%=wheel%-9
b1%=wheel%:b2%=wheel%+2:IF b2%>7 THEN b2%=b2%-8
b3%=wheel%+4:IF b3%>7 THEN b3%=b3%-8
b4%=wheel%+6:IF b4%>7 THEN b4%=b4%-8
FOR clock%=1 TO 18:turn%(clock%)=0:NEXT
turn%(b1%)=front%:turn%(b1%+9)=back%
IF butt%(b1%)=-1 THEN
turn%(9)=front%:turn%(b1%+1)=front%:turn%(b4%+1)=front%
IF butt%(b2%)=-1 THEN
turn%(b1%+1)=front%:turn%(b2%)=front%:turn%(b2%+1)=front%
turn%(b2%+9)=back%
ENDIF
IF butt%(b3%)=-1 THEN
turn%(b2%+1)=front%:turn%(b3%)=front%:turn%(b3%+1)=front%
turn%(b3%+9)=back%
ENDIF
IF butt%(b4%)=-1 THEN
turn%(b3%+1)=front%:turn%(b4%)=front%:turn%(b4%+1)=front%
turn%(b4%+9)=back%
ENDIF
ELSE
turn%(18)=back%:turn%(b1%+10)=back%:turn%(b4%+10)=back%
IF butt%(b2%)=1 THEN
turn%(b2%)=front%
turn%(b1%+10)=back%:turn%(b2%+9)=back%:turn%(b2%+10)=back%
ENDIF
IF butt%(b3%)=1 THEN
turn%(b3%)=front%
turn%(b2%+10)=back%:turn%(b3%+9)=back%:turn%(b3%+10)=back%
ENDIF
IF butt%(b4%)=1 THEN
turn%(b4%)=front%
turn%(b3%+10)=back%:turn%(b4%+9)=back%:turn%(b4%+10)=back%
ENDIF
ENDIF
BEEP:PROCclocks
ENDPROC
DEF PROCclocks
LINEENDS 0,1:done%=TRUE
FOR clock%=1 TO 18
IF turn%(clock%)<>0 THEN
hr%=clock%(clock%):LINECOL 0
LINE cx%(clock%),cy%(clock%) TO cx%(clock%)+hx%(hr%),cy%(clock%)+hy%(hr%)
hr%=hr%+turn%(clock%):IF hr%=0 THEN hr%=12
IF hr%=13 THEN hr%=1
clock%(clock%)=hr%:LINECOL 1
LINE cx%(clock%),cy%(clock%) TO cx%(clock%)+hx%(hr%),cy%(clock%)+hy%(hr%)
ENDIF
IF clock%(clock%)<>12 THEN done%=FALSE
NEXT
ENDPROC
DEF PROChourxy
FOR hr%=1 TO 12
ang%=90-30*hr%:IF ang%<0 THEN ang%=ang%+360
hx%=30*COS(RAD(ang%)):hy%=-30*SIN(RAD(ang%))
hx%(hr%)=hx%:hy%(hr%)=hy%
NEXT
ENDPROC
DEF PROCpreamble
GRAFRECT 0,0,640,400:CLG 0:GTXTALIGN 1,1
TXTRECT 16,16,640,400:TXTSIZE 13
PRINT "RUBIK CLOCK":PRINT
PRINT "This program is a computer version of the Rubik Clock puzzle."
PRINT:PRINT "Set the button pattern and turn the wheels ";
PRINT "until all the clocks are at 12."
PRINT "(The solution can be found in RUBICLOC.DOC)"
PRINT:PRINT "Press any key to start.":g=GET
TXTRECT 0,0,640,400:CLG 0
ENDPROC