10 Liners - Games in 10 lines of BASIC

Yes actual games with GFX,SFX and High Scores can be written in just 10 lines of BASIC code! One of the games below (Polar Attack), was discussed on the CocoCrew Podcast. Some good questions were raised so I thought I would record some notes for anyone curious. If you just want to see and play the games, keep on scrolling!

Why?

Why do this? Just for the fun of it really! Mini-games have their place and a novelty size constraint certainly stops feature creep! There are numerous challenges online to do with compactness of code - 1 line, 5 lines, 10 lines, 4k etc etc. These games weren't part of a competition. It started with just writing a reaction timer program which took 4 lines or so. This was to be core of a larger game. Then I wondered if I could make a smaller version with the 10 line limit. Turns out the MC10 is pretty good platform for this and I completed Polar Attack followed by Arm Grab and Llama race. All three were then ported to the Dragon and Tandy Coco.

Painful?

Not too often! On the games so far, it has been less about squashing to save space and more about reordering to avoid branching or to gain speed at a critical time.

The thing that made me sigh was getting a syntax error on a 250+ character line and having to track it down!

It's not a great method to create readable reusable code and porting between MC10 and Dragon/Tandy can be a chore it times - especially when editing long lines.

How?

Unintentionally, I had a rough common structure in each game.

  1. DIM variables : Setup 1 time data
  2. Reset variables for start of next turn
  3. Display
  4. Input : Player updates
  5. Game specific
  6. Game specific
  7. Game specific
  8. Game specific : GOTO 4
  9. Good outcome : pause : GOTO 2
  10. Bad outcome : pause : GOTO 2

General tips are to reuse as much as possible. Strings are easy to define once and reuse. Sound effects can be created by pushing variables e.g. Llama X position into the SOUND command gives a rising pitch as it gets closer to the finishing line.

Porting

The MC10's main strength is the ability to directly PRINT the extended character set. I used Notepad++ with ANSI encoding in order to keep the text format from jumping to Unicode. The disadvantages are shorter line length (128 characters) and no ELSE command. The latter is actually more of a problem. Branching is so vital to a game!

Dragon and Tandy are fairly similar - differences being the addresses of POKES and PEEKS on occasion. PAL / NTSC differences may show up some minor timing variations. Could be emulation tho... CHR$ and STRING$ take up more space than the MC10s PRINT but the longer line length helps with this. I've not resorted to using ELSE to gain some space... yet.

Should I?

Absolutely - I can't wait to play your 10-liner. Takes more lines if you need to - don't let it limit your game! Very much easier to conceive and complete than a large text adventure or arcade game.

Will you make more?

Yes - some ideas in the works but who knows when!

Gameplay Videos





Download Links

Dragon 32/64

Tandy Coco2

Tandy MC-10

No comments:

Post a Comment

Magic Mirror On The Screen

Well this doesn't need much explanation either... mirroring. Again the buttons aren't amazing but are functional.  The code is on  G...