Following on from Missile Dodge (see my other videos), I decided to write a new one-line game from scratch.
One thing that always bothered me about my original one line games was the lack of playing area - there wasn't enough space in one line to draw anything useful. I really wanted to make a Pacman type game, but couldn't find a way.
I wondered if I could draw a Pacman-style maze using a pseudo random number algorithm.
I haven't found that yet, but I did discover the Binary Maze algorithm (see http://en.wikipedia.org/wiki/Maze_generation_algorithm#Simple_algorithms and http://www.astrolog.org/labyrnth/algrithm.htm ).
So here's a game which draw a maze, and then lets you try to escape out the bottom or right edges (the binary maze is always guaranteed to have a route to an exit on the bottom or right edges).
Use the arrow keys to move. NB. If the emulator you use has an option to map the Windows keyboard to the TRS-80 keyboard you may need to turn it off to get the arrow keys to work properly.
0 IFC=0THENCLS:FORC=1TO480:R=RND(2):PRINTCHR$(320-144*R);CHR$(161+15*R);:NEXT:GOTOELSEK=PEEK(14400):P=X+(K=32ANDX>0)-(K=64):Q=Y+(K=8ANDY>0)-(K=16):IFPOINT(P,Q)THENGOTOELSERESET(X,Y):X=P:Y=Q:SET(X,Y):IFX>126ORY>44THENPRINT"WELL DONE"ELSEGOTO
A couple of explanatory notes:
(1) The shenanigans with CHR$() on the convoluted expression is to select one of two graphics characters without using an IF THEN clause. For details of the graphics characters see http://www.trs-80.com/wordpress/zaps-patches-pokes-tips/graphics/ The first is selecting between a space (ASCII 32) and a horizontal line (176). The second is selecting between a full block (191) and the horizontal line (176).
(2) PEEK(14400) is looking at the keyboard memory map, and picks up the arrow keys. See my Missile Dodge video for details and links.
maybe easy to play, but not easy to write. well done indeed.
lodcr 2 months ago
That looks really easy to do.
ppunterFlightsimdude 1 year ago