pacman 10 (Oric Atmos) by RAX
About
10 Line BASIC
=============
Category : PUR-80
TITLE : pacman
PLATFORM : Oric Atmos
LANGUAGE : BASIC 1.1b
AUTHOR : RAX
VIDEO :
CODE:
0---------1---------2---------3---------4---------5---------6---------7-----78 0D$="333b%%%b###//####APbVb5##?1)1?###?aaa?":FORA=1TO38:T=ASC(MID$(D$,A,1))-35 1POKE#B907+A,T:NEXT:D$="####_^Z27-7-71?-?+'13bb%a$CB3bb%?4E174E-7TF-_Ba2####": 2DIMM(30,20):DEFFNC(X)=(DANDX)/X+33:POKE#26A,10:LORES1:FORY=0TO12:FORX=0TO3''' 3D=ASC(MID$(D$,I+1,1))-35:FORK=0TO5:C=FNC(2^K):C=C-(C=33)*128:M(X*6+K,Y)=C'''' 4INK3:PLOT9+X*6+K,Y+4,C:NEXT:I=I+1:NEXTX,Y:X=9:Y=7:E=9:DEFFNR(X)=INT(RND(1)*X) 5R=4:B=161:P=130:REPEAT:K=PEEK(#208):M(Q,W)=32:Q=X:W=Y:Y=Y+(K=156)-(K=180)'''' 6X=X+(K=172)-(K=188):X=X-((X=1))*21+((X=22))*21:Z=SCRN(9+X,4+Y):PLAY7,0,2,S*10 7F=E:G=R:E=E+(D=0)-(D=1):R=R+(D=2)-(D=3):IFZ=161THENX=Q:Y=WELSE:S=S-(Z=34)'''' 8IFM(E,R)=161THENE=F:R=G:D=FNR(4)ELSE:PLOT9+F,4+G,M(F,G):PLOT9+E,4+R,35''''''' 9M(X,Y)=32:M=1-M:PLOT9+Q,4+W,32:PLOT9+X,4+Y,36+M:UNTILX=EANDY=RORS=P:RUN''''''RUN
CODE EXPLANATION:
================================
0D$="333b%%%b###//####APbVb5##?1)1?###?aaa?":FORA=1TO38:T=ASC(MID$(D$,A,1))-35
D$="333b%%%b###//####APbVb5##?1)1?###?aaa?" - chars/sprites data
FOR A = 1 TO 38 - chars modify loop
T=ASC(MID$(D$,A,1))-35 - get data from string
================================
1POKE#B907+A,T:NEXT:D$="####_^Z27-7-71?-?+'13bb%a$CB3bb%?4E174E-7TF-_Ba2####":
POKE#B907+A,T - change line of char/sprite
NEXT
D$="####_^Z27-7-71?-?+'13bb%a$CB3bb%?4E174E-7TF-_Ba2####" - level data
================================
2DIMM(30,20):DEFFNC(X)=(DANDX)/X+33:POKE#26A,10:LORES1:FORY=0TO12:FORX=0TO3
DIMM(30,20) - playgraund array
DEFFNC(X)=(DANDX)/X+33 - this function get bit from char (for level)
POKE#26A,10 - stop system blinking cursor and the sounds when press a key
LORES1 - set lo-res mod
FORY=0TO12 - print level loop Y
FORX=0TO3 - print level loop X
================================
3D=ASC(MID$(D$,I+1,1))-35:FORK=0TO5:C=FNC(2^K):C=C-(C=33)*128:M(X*6+K,Y)=C
D=ASC(MID$(D$,I+1,1))-35 - get char form level string
FORK=0TO5 - bits loop
C=FNC(2^K) - get curent bit from char
C=C-(C=33)*128 - calc sprite
M(X*6+K,Y)=C - save sprite in playground array
================================
4INK3:PLOT9+X*6+K,Y+4,C:NEXT:I=I+1:NEXTX,Y:X=9:Y=7:E=9:DEFFNR(X)=INT(RND(1)*X)
INK3 - set ink 3
PLOT9+X*6+K,Y+4,C - sprinte sprite on a screen
NEXT
I=I+1 - char index
NEXTX,Y
X=9 - palyer X
Y=7 - palyer X
E=9 - ghost X
DEFFNR(X)=INT(RND(1)*X) - define random function FNR
================================
5R=4:B=161:P=130:REPEAT:K=PEEK(#208):M(Q,W)=32:Q=X:W=Y:Y=Y+(K=156)-(K=180):
R=4 - ghost Y
B=161 - brick ascii char number
P=130 - max dots on level
REPEAT - game loop
K=PEEK(#208) - read key in K
M(Q,W)=32 - clear field on playgraund array
Q=X - old player x pos
W=Y - old player y pos
Y=Y+(K=156)-(K=180) - calc new Y pos
================================
6X=X+(K=172)-(K=188):Z=SCRN(9+X,4+Y):X=X-((X=1))*21+((X=22))*21
X=X+(K=172)-(K=188) - calc new X pos
Z=SCRN(9+X,4+Y) - scan screen on player pos in Z
X=X-((X=1))*21+((X=22))*21 - ix player on teleport pos - calc new X pos
PLAY7,0,2,S*10 - play little sound effect
================================
7F=E:G=R:E=E+(D=0)-(D=1):R=R+(D=2)-(D=3):IFZ=161THENX=Q:Y=WELSE:S=S-(Z=34)
F=E - old ghost pos X
G=R - old ghost pos Y
E=E+(D=0)-(D=1) - calc new ghost pos X
R=R+(D=2)-(D=3) - calc new ghost pos Y
IF Z=161 THEN - if player new pos is on brick then
X=Q - return old X and Y
Y=W
ELSE - else
: - nothing
S=S-(Z=34) - calc the points collected from the playing field
================================
8IFM(E,R)=161THENE=F:R=G:D=FNR(4)ELSE:PLOT9+F,4+G,M(F,G):PLOT9+E,4+R,35:
IF M(E,R)=161 THEN - if ghost on brick then
E=F - return old X
R=G - return old Y
D=FNR(4) - get new random ghost direction
ELSE - else
: - nothing
PLOT9+F,4+G,M(F,G) - remove ghost
PLOT9+E,4+R,35 - print ghost
================================
9M(X,Y)=32:M=1-M:PLOT9+Q,4+W,32:PLOT9+X,4+Y,36+M:UNTILX=EANDY=RORS=P:RUN
M(X,Y)=32 - clear field on playgraund array
M=1-M - pacman animation index
PLOT9+Q,4+W,32 - remove player
PLOT9+X,4+Y,36+M - print player
UNTIL X=E AND Y=R OR S=P - game loop ends when the position of the ghost and the player are the same or all points are stopped
RUN - restart game