Last active
February 12, 2021 12:28
-
-
Save fu-sen/7274454 to your computer and use it in GitHub Desktop.
15パズル ( 15 puzzle ) | MSX-BASIC https://msxjpn.jimdofree.com/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0/15-%E3%83%91%E3%82%BA%E3%83%AB/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' 15 puzzle | MSX-BASIC | |
' Copyright (c) 2003 Keiichi Shiga (BALLOON | FU-SEN) | |
' The MIT License (MIT) - https://mit.balloon.net.eu.org/#2003 | |
100 I$="123456789ABCDEF0":J$=I$:S=100 | |
110 CLS:FOR L=S TO 1 STEP -1 | |
120 U=INSTR(I$,"0"):R=RND(-TIME)*4+1 | |
130 ON R GOSUB 280,290,300,310 | |
140 IF C=U GOTO 120 | |
150 GOSUB 320:GOSUB 220:NEXT L:S=0 | |
160 GOSUB 220:PRINT:PRINT"SCORE ";S | |
170 IF I$=J$ THEN END | |
180 U=INSTR(I$,"0"):T=STICK(0) | |
190 ON T GOSUB 280,,290,,300,,310 | |
200 IF C=U GOTO 180 | |
210 GOSUB 320:S=S+1:GOTO 160 | |
220 LOCATE 0,0,0 | |
230 FOR Y=0 TO 3:FOR X=0 TO 3 | |
240 N=VAL("&H"+MID$(I$,X+Y*4+1,1)) | |
250 IF N=0 THEN PRINT ".. ";:GOTO 270 | |
260 PRINT USING "## ";N; | |
270 NEXT X:PRINT:NEXT Y:RETURN | |
280 C=U+(U>4)*4:RETURN | |
290 C=U-(U MOD 4>0):RETURN | |
300 C=U-(U<13)*4:RETURN | |
310 C=U+(U MOD 4<>1):RETURN | |
320 H$=MID$(I$,C,1):MID$(I$,C,1)="0" | |
330 MID$(I$,U,1)=H$:U=C:RETURN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment