Rem Jezzball, by Atari2600land
Rem Comments by Kurt_Woloch
Rem Playfield definition
playfield:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X..............................X
X..............................X
X..............................X
X..............................X
X..............................X
X..............................X
X..............................X
X..............................X
X..............................X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
End
Rem Initialisation of coordinates - missile0 is the "ball", player0 is the "player"
missile0x = 30: missile0y = 40
player0x = 17: player0y = 16
Rem initialisation of various variables.
Rem a = pfpixel coordinate of player
Rem b = pfpixel coordinate of player
Rem c{0} = wall is being drawn vertically
Rem c{1} = wall is being drawn horizontally
a=1 : b=1 : c{0}=0
c{1}=0
n{0}=1
main
REM define shape of the player, depending on where the player is heading
if c{1} then player0:
%1111
%1111
%1111
%0000
%1111
%1111
%1111
End
if !c{1} then player0:
%1001
%1001
%1001
%1001
%1001
%1001
%1001
End
REM check if ball has hit a wall; if so, let it bounce off, then continue without further checking
if collision(missile0,playfield) && n{0} then n{0}=0 : n{1}=1 : goto main_1b
if collision(missile0,playfield) && n{1} then n{1}=0 : n{2}=1 : goto main_1b
if collision(missile0,playfield) && n{2} then n{2}=0 : n{3}=1 : goto main_1b
if collision(missile0,playfield) && n{3} then n{3}=0 : n{0}=1 : goto main_1b
main_1b
REM depending on the current direction of the ball (in n{0 through 3}), move ball
if n{0} then missile0x=missile0x+1 : missile0y=missile0y+1
if n{1} then missile0x=missile0x+1 : missile0y=missile0y-1
if n{2} then missile0x=missile0x-1 : missile0y=missile0y-1
if n{3} then missile0x=missile0x-1 : missile0y=missile0y+1
REM go back to start if reset switch depressed
If switchreset Then reboot
REM draw the screen
drawscreen
REM define color of player 0 and playfield, and height of missile, and width / number of copies
COLUP0=100 : COLUPF=130 : missile0height=3 : NUSIZ0=$20
REM If wall is being drawn, go to wall-draw routine
if c{0} then goto fired
REM set c{2} and {3} to 0
c{2}=0 : c{3}=0
REM set d, e, h and i to adjacent rows and columns of the player
REM in order to see if those pixels are free
d = b - 1: e = b + 1: h = a - 1: i = a + 1
REM turn main pixel for player position on
pfpixel a b on
REM check joystick for left, right, up and down
REM for each direction, if it applies, check corresponding playfield pixel if free
REM if it is free, increase f by 1
REM if f has reached 10, move player in that direction
REM This causes the player to move every 10 frames
if joy0left && a>0 && !pfread(h,b) then f=f+1
if f>10 && !c{4} then pfpixel a b off : a=a-1 : player0x=player0x-4 : f=0
if f>10 && c{4} then a=a-1 : player0x=player0x-4 : f=0 : c{4}=0
if joy0right && a<31 && !pfread(i,b) then f=f+1
if f>10 && !c{4} then pfpixel a b off : player0x=player0x+4 : a=a+1 : f=0
if f>10 && c{4} then a=a+1 : f=0 : player0x=player0x+4 : c{4}=0
if joy0up && b>0 && !pfread(a,d) then f=f+1
if f>10 && !c{4} then pfpixel a b off : player0y=player0y-8 : b=b-1 : f=0
if f>10 && c{4} then b=b-1 : f=0 : player0y=player0y-8 : c{4}=0
if joy0down && b<10 && !pfread(a,e) then f=f+1
if f>10 && !c{4} then pfpixel a b off : player0y=player0y+8 : b=b+1 : f=0
if f>10 && c{4} then b=b+1 : f=0 : player0y=player0y+8 : c{4}=0
REM if fire was pressed and jostick is not held left or right, set c{0} to 1, but only if it is not set yet
if joy0fire && !joy0left && !joy0right && !c{0} then c{0}=1
REM if fire was pressed and jostick is held left or right, set c{1} to 1
if joy0fire && joy0left then c{1}=1
if joy0fire && joy0right then c{1}=1
REM go back to main loop
GoTo main
REM the following routine gets jumped to if a wall is in the process of being built
fired
REM if wall draws horizontally, set o to current line of the ball, else set it to current column of the ball
if !c{1} then o=(missile0x-17)/4 else o=(missile0y-1)/4
REM set next positions wall will be drawn to
if !c{1} then l=d-1 : m=e+1 else l=h-1 : m=i+1
REM The next statement doesn't do anything... it sets c{0} if it is already set
REM and joystick 0 is fired... so the state of c{0} never changes and the statement doesn't make
REM sense.
if !joy0fire && c{0} then c{0}=1
REM expand wall to the next 2 playfield pixels which aren't drawn yet
if !c{1} then pfpixel a d on : pfpixel a e on
if c{1} then pfpixel h b on : pfpixel i b on
REM set c{2} or c{3} if the wall has reached its boundary in one of the directions
if !c{1} && pfread(a,m) then c{2}=1
if !c{1} && pfread(a,l) then c{3}=1
if c{1} && pfread(m,b) then c{2}=1
if c{1} && pfread(l,b) then c{3}=1
REM increase g (delay variable)
g = g + 1
REM if g is greater than 10 (after 10 frames), make the pixels just drawn "permanent"
REM by increasing the wall boundaries (if not reached already) so that the next blocks become
REM the new ones
if g>10 && !c{1} && !c{2} && !pfread(a,m) then e=e+1
if g>10 && !c{1} && !c{3} && !pfread(a,l) then d=d-1
if g>10 && c{1} && !c{2} && !pfread(m,b) then i=i+1
if g>10 && c{1} && !c{3} && !pfread(l,b) then h=h-1
REM and reset g to 0
If g > 10 Then g = 0
REM if the ball hits the playfield and is on the row/column where the new wall gets drawn,
REM reset the game
if collision(missile0,playfield) && !c{1} && a=o then reboot
if collision(missile0,playfield) && c{1} && b=o then reboot
REM if the wall has reached both sides, end wall drawing
if c{2} && c{3} then c{0}=0 : c{1}=0 : c{4}=1
REM go back to main loop
GoTo main