Paddleship

A 10-line TurboBASIC XL program for the Atari 8-bit computer
Written for 2014 NOMAM programming competition

Bill Kendrick, February 11-12, 2014

An entry for the NOMAM 2014 10-line TurboBASIC XL game competition.


Objective

In the game, you control a ship flying in space. It must bump into another ship, that appears randomly on the screen; doing so scores a point, and causes a new ship to appear elsewhere on the screen. A limited amount of time is allotted. When the time runs out, the game ends and your score is shown.

The ship is controlled with a paddle controller. The ship's direction changes depending on the position of the paddle knob. If kept in the center, the ship's direction does not change; otherwise, the ship will continuously rotate in the direction the paddle is turned, and at a higher rate if the paddle is turned further from its center position.

Pressing the fire button on the paddle causes the ship to thrust forward in the direction it's facing. If it reaches an edge of the screen, it stops moving in that direction (though it may continue moving perpendicular to the edge; e.g. if you are moving towards the top-left, and hit the top edge first, you will stop moving up, but will continue moving left until you hit the left edge, at the top-left corner).


Development


References used: Turbo Basic Command List, Mapping the Atari, De Re Atari

This game was developed in one evening, while simultaneously tending to a 2-year-old toddler who enjoys banging on electronic devices. I followed these steps:

  1. Fired up TurboBASIC XL on my Atari 1200XL computer (best. keyboard. ever.)
  2. Loaded and ran "FONT 3", a relatively usable font editor that I wrote in plain Atari BASIC in 1990
  3. Decided to make it a paddle game, since those are rare and novel
  4. Began drawing a tank... no, let's make this a space game... began drawing a ship
  5. Created the N- and NE-facing versions of the ship
  6. Struggled a little to make the NNE version of the ship
  7. Duplicated the N, NNE, and NE versions of the ship (using combinations of my font editor's flip, mirror, and rotate features) to get versions of the ship in the 13 other directions I needed
  8. Created a program in TurboBASIC XL that read the bytes from the font file and saved them out to disk as a BASIC listing that could be ENTER-ed off of the disk.
  9. Began writing the main game. Couldn't decide what bitmap or text graphics mode to use. Finally decided on GRAPHICS 7 to get reasonably small pixels to use as stars, in a variety of colors, which I could toy with via palette manipulation to make them 'sparkle' (line 100)
  10. Consulted my print version of De Re Atari and both my print version, and the Atari Archives version of Mapping the Atari, to remind myself how to use Player/Missile Graphics
  11. Found, converted to 80 columns, and printed a copy of Turbo Basic Command List, to remind myself what tricks I can use, and how to copy memory blocks around (hint, it's the "MOVE" command)
  12. Got a PMG ship to appear on the screen. Began writing code to rotate and move it.
  13. Modified the earlier TBXL program to also dump out a string containing directional info that can be used for each of the 16 directions the ship faces:
  14. Now that I had actual movement values, got the ship to move around the screen.
  15. With the program's code 10 lines long, I had a framework for a game, but it wasn't a game!
  16. Took some photos of the game and its code, and posted them to Facebook, lamenting my situation
  17. Decided the objective of the game would be to fly your ship to an object. This would be "fun" (or at least a challenge), because the paddle input makes it very difficult to fly the damned thing!
  18. Added the other Player, collision detection, the timer and score, and game-over feature. I had a game! It was 11-12 lines long, though!
  19. Reorganized the code a bunch to fit everything into 10 lines. Due to this, you'll notice some cases where:
  20. Created this web page, explaining what the code does, line-by-line, and describing the development process.

Line-by-line Breakdown of the Source Code


Source-code from when the ship moved, but before it was a game.

Set-up

10 GRAPHICS 23:PM=(PEEK(106)-32):POKE 54279,PM:POKE 53277,3:POKE 559,46:H=53248:DPOKE 704,16522:PM=(PM+2)*256:MS=32
11 DIM F$(136),D$(24):F$="{80 characters of ATASCII gibberish}":F=ADR(F$)
12 F$(81)="{56 characters of ATASCII}":D$="{24 characters of ATASCII}":FOR I=0 TO 256
20 DPOKE PM+I*2,0:COLOR RAND(3)+1:PLOT RAND(160),RAND(96):PLOT I/2,0:NEXT I:X=80:Y=24:XM=0:YM=0:SC=0:D=4:T=0:COLOR 0:GOSUB 1000:V=0

Main Loop

100 POKE H,X+48:MOVE F+8+INT(D)*8,PM+16+Y,8:MOVE F,PM+8+Y,8:MOVE F,PM+24+Y,8:DPOKE 708,RAND(65536):POKE 710,RAND(255)
110 SOUND 1,100,10,V:D=D-(PADDLE(0)-128)/128:IF D<0:D=D+16:ELSE :IF D>=16:D=D-16:ENDIF :ENDIF :ID=INT(D+1):IF PTRIG(0)=0
120 XM=XM+ASC(D$(ID))-2:YM=YM-ASC(D$(ID+4))+2:SOUND 0,0,0,10:ELSE :SOUND 0,0,0,0:ENDIF :IF ABS(XM)>MS:XM=SGN(XM)*MS:ENDIF
130 IF ABS(YM)>MS:YM=SGN(YM)*MS:ENDIF :X=X+XM/8:Y=Y+YM/8:IF Y<0:Y=0:ENDIF :T=T+0.25:PLOT 128-T,0:IF T=128 THEN ? SC:DPOKE H,0:END
140 IF Y>96:Y=96:ENDIF :IF X<0:X=0:ENDIF :IF X>160:X=160:ENDIF :IF PEEK(53261):SC=SC+1:GOSUB 1000:ENDIF :V=V-SGN(V):GOTO 100

Subroutine

1000 MOVE F,PM+16+YY+128,8:POKE H+1,RAND(160)+48:YY=RAND(96):MOVE F+8,PM+16+YY+128,8:POKE 53278,0:V=15:RETURN

Download


To-Do


Bill Kendrick, 2014, nbs@sonic.net, New Breed Software
Other games I wrote for NOMAM 2014