Batmaster

In-game screen.

Program listing on 48K Spectrum.

Text Listing

1 BORDER 3:
 POKE 23693,0:
 LET l=0:
 LET x=8:
 CLS :
 LET s=0:
 FOR d=-4 TO 0:
 FOR c=-7 TO 0:
 PRINT AT d+7,28+c*4; PAPER 1-c-d-6*(c+d<-5),:
 NEXT c:
 NEXT d:
 LET a=x+1:
 LET b=16:
 RESTORE :
 READ o$,o,q,k,g,x:
 PRINT AT 19,o;"   " AND o-x; INK 7;AT 19,x;o$;o$;o$:
 READ e,f,p,c,z,c,d,t,a,b,h,w,s,u,l:
 PRINT AT f+d,4*INT ((e+c)/4);"    " AND h;AT f,e;" "; INK 7;AT b,a;"o"; PAPER 2;AT 0,0;(l-u)*40+s,"L:";l+1,:
 BEEP w+(z OR p)/50,24*(h-w):
 POKE (w=0)*23620,14-9*u:
 DATA CHR$ 131,x,IN 61438-174,q-64*(q>17),(k=9)+2*(k=8)-(k<2)-(k=0),x+g*(x+g<30)*(x>=-g),a,b,(e=0)-(e=31),c+2*p,ATTR (b-d,a+c)>0,c-2*c*(f=18)*(e+c+c=x+1)*(p=0),d-d*2*(z+(f=18)*(e=x+1+c)),ATTR (b-d,a+c)=0,a+c*t,b-d*t,z*(f<9)*(f>1),b=21,s+h,s=40,l+u

Download the game

About the game

A simple breakout clone coded in one line. Keys are 6-left, 7-right, 0-move bat at double speed. Object of the game is to clear all the bricks on each screen and achieve as many points as possible. Each brick is worth one point. The status line at the top of the screen shows the current score and level number. Each level has forty bricks. You can guide the ball to the left or right by hitting the very corner of the bat onto it. Again, many thanks to Einar Saukas for greatly improving the game via a multitude of optimisations and game ideas, not to mention numerous serious bugfixes.

Technical Notes

Writing a simple BASIC breakout clone in one line was not quite as easy as I first thought. There were two problems to overcome. The first problem is what I call "bishops on a chessboard". That is, if the ball is only permitted to travel diagonally then it will only visit half of the squares on the character mapped screen. So, if the bricks are only one character wide, then only half of them can be reached by the ball. A simple solution is to make the bricks two squares wide, or wider. In this game, the bricks are 4 squares wide, so they can all be reached by the ball. Second problem was collision detection between ball and bat. If ATTR() is used for collision detection like in this game, then if you print the ball and bat in the same statement, you may find that the ball often goes right through the bat. This is because both the ball and bat have moved on the same iteration, and the collision detection has missed them passing each other. The workaround used in this game is to firstly PRINT the bat, and then check collision with the ball before allowing the ball to move or bounce off, and then PRINTing the ball in a seperate statement.

One other problem was collision detection with the bricks. In an earlier version of the game, sometimes two bricks could be destroyed in one iteration, but only one point would be added to the score in that case. This issue was resolved by Einar, in order to pave the way for a multi-level game.

Later, after more space had been freed up in the program listing, a side-bounce effect was added allowing the player to redirect the ball left or right if hit directly on the corner of the bat. Eventually the bat size was reduced from 4 to 3 to make this side-bounce effect symmetrical, and the game a little harder. Finally the PAPER colour for the status row was changed to red, so it actually looks like the ball is bouncing off something at the top of the screen, and the sound effects were slightly refined. The end result is a program listing that is one character short of the one-liner competition limits.

Back to Sinclair stuff index