GB
  
You are currently viewing the United Kingdom version of the site.
Would you like to switch to your local site?
16 MIN READ TIME

Coding Cosmic Invaders in BBC Basic

Nate Drake invites you to stave off the alien menace by coding your very own Space Invaders clone in Basic, because it’s 2025!
OUR EXPERT Nate Drake is a tech journalist specialising in cybersecurity and retro gaming. His first experience of video games was the cocktail cabinet version of Space Invaders in his father’s local.

Part four!

Catch up with previous issues –see page 64!

Part four!

Catch up with previous issues –see page 64!

S o far in this series, we have covered how the classic programming language Basic S (Beginners’ All Purpose Symbolic Instruction Code) can still be used today to code games like Mark Buckwell’s Cosmic Invaders.

In the first part, we created code to establish a basic title screen. The next tutorial covered loading elements such as the player ship and bases, and the invaders.

If you followed the steps in the third part and/or ran the sample script COSMIC10.bas, your player ship is now capable of firing missiles. The script also has some rudiments of collision detection in that missiles are capable of destroying invaders and shields on impact.

In this final part, we focus on the code for the alien bombs, related collision detection, and scoring.

As always, we recommend using the b2 BBC Micro emulator, available as a Snap package via the Ubuntu Software Center. Once installed, use Edit > OSRDCH Paste (+Return) to paste any of the code samples listed here from the clipboard. Enter RUN to begin.

Bombs array!

Fortunately, for this coding tutorial we already have a copy of the completed game. Access this via http://bit.ly/cosmicinvaders to paste and run it in b2 or your chosen BBC Basic emulator.

Park your player behind one of the shields and focus on the alien bombs. As you’ll see, these consist of simple # characters that drop down, seemingly at random. As the bombs enter different bands on the screen, they change colour. If they collide with a shield, that portion of the shield is damaged. If they collide with the player’s ship, they lose a life. For efficiency, only the current bottom row of aliens drops bombs.

If you take the time to examine the original CosmicInvaders.bas script, you’ll see that there are several bomb dropping procedures, chief of which is PROC_Bombs:

820 DEF PROC_Bombs

830 LOCAL D% : IF Bomb%<MBomb% THEN PROC_

New_Bomb

840 IF Bomb%=0 GOTO 910

850 FOR D%=1 TO MBomb%

860 IF Bombs%(D%,1)<>0 THEN PROC_Look_Bomb

870 NEXT

880 FOR D%=1 TO MBomb%

890 IF Bombs%(D%,1)=23 THEN PRINTTAB(BBombs%

Unlock this article and much more with
You can enjoy:
Enjoy this edition in full
Instant access to 600+ titles
Thousands of back issues
No contract or commitment
Try for 99p
SUBSCRIBE NOW
30 day trial, then just £9.99 / month. Cancel anytime. New subscribers only.


Learn more
Pocketmags Plus
Pocketmags Plus

This article is from...


View Issues
Linux Format
May 2025
VIEW IN STORE

Other Articles in this Issue


LINUX FORMAT
LINUX FORMAT
The #1 open source mag Future Publishing Limited,
WELCOME
MEET THE TEAM
This issue, we’re all about taking Linux on the move, so what is the oddest place where you’ve found yourself using Linux?
Linux on the move
Just as Windows Mobile wasn’t Windows, and Apple’s
REGULARS AT A GLANCE
Rust drama gets more corrosive
KERNEL
Firefox T&Cs revision sparks controversy
Mozilla tries to back-pedal after backlash to changes concerning ownership and resale of user data.
Steam beats Amazon
Amazon’s gaming ambitions fail to topple Steam.
SOVEREIGN STANDARDS
OPINION
STABLE STORAGE
OPINION
Chromium loses uBlock Origin
Google’s Manifest V3 pushes users to alternative, less powerful ad blockers.
Brother firmware kerfuffle
Brother denies blocking third-party ink cartridges.
Matrix could shut down
Hosted bridges face imminent closure unless urgent funding is secured.
Distro watch
What’s behind the free software sofa?
ZINK OR SWIM
OPINION
RUST BUCKET
OPINION
Kernel Watch
Jon Masters summarises the latest happenings in the Linux kernel, so that you don’t have to.
ONGOING DEVELOPMENT
Confidential Compute patches continue to hit the kernel
Answers
Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com
Mailserver
Wise-Fise I just read through the last edition
Helpdex
shane_collinge@yahoo.com
LETTER OF THE MONTH
AI AI oh!
FreeFileSync
Version: 14.0 Web: https://freefilesync.org
GPU Screen Recorder
Version: 5.1.4 Web: https://git.dec05eba.com/gpu-screen-recorder
Picocrypt
Version: 1.46 Web: https://github.com/Picocrypt/Picocrypt
Vieb
Version: 12.2.0 Web: https://vieb.dev
Beaver Notes
Version: 3.9.0 Web: https://beavernotes.com
Ignition
Version: 1.1.1 Web: https://github.com/flattool/ignition
Gaia Sky
Version: 3.6.6 Web: https://zah.uniheidelberg.de/gaia/outreach/gaiasky
ET: Legacy
Version: 2.83.2 Web: www.etlegacy.com
PySolFC
Version: 3.2.0 Web: https://pysolfc.sourceforge.io
Darktable
Version: 5.0.1 Web: www.darktable.org
Tangram
Version: 3.3 Web: https://apps.gnome.org/Tangram/
INSTALL UBUNTU!
How fast can you install Ubuntu 25.04? Take our challenge and beat our install speed demons!
REVIEWS
Nvidia GeForce RTX 5090
There’s anew king in town, same as the last, says Jarred Walton
Netrunner 25
Nate Drake catches the latest Netrunner just in time. Will this Debian-based distro be able to keep up with his demands?
NuTyX 25.02.5
Nate Drake is crossing the Channel with this independently developed French Linux distro inspired by LFS. Will he sink or swim?
Rhino Linux 2025.2
Nate Drake takes the Rhino by the horns to discover whether this Ubuntu-based rolling distro is worth charging up.
Tails 6.12
Nate Drake dives into the murky world of the darknet with this Debian-based distro that routes connections through Tor.
Dwarf Fortress – Steam
Imploring Management not to tunnel too far, Lincoln Carpenter fears they’ll dig too greedily and too deep, and awake what lies in the darkness.
ROUNDUP
Ubuntu spin-offs
Michael Reed examines five desktop distributions that use Ubuntu as a base and take things off in five unique directions.
Installation
The first job is to get the distro up and running.
First-run experience
A first run needs useful signposting, particularly for beginners.
Desktop design and use
The base home environment.
Support and community
When you get stuck, can you get help?
Quality of documentation
Where these distros differ from Ubuntu, what information is available?
Adding software
The built-in applications will get you started, but you’ll always have to add more.
Base software
Included apps and utilities steer the distro in an initial direction.
Ubuntu spin-offs
he Linux Mint desktop doesn’t attempt to reinvent
MAKE LINUX MOBILE
MAKE LINUX MOBILE
Your Android phone is supporting the Google empire. Jonni Bidwell wants to help set it free, through the wonders of open source.
Android problems…
There are privacy, security, philosophical and environmental reasons to FOSSify your phone. As well as plain whimsy.
Reasons to deGoogle
It’s difficult to see where the free bits of Android stop and the Googley bits begin, so allow us to elucidate.
Installing LineageOS
Time to take off the gloves and jump straight into freeing your phone. It’s time to install LineageOS.
Full-fat mobile Linux
For that full Linux experience, we take a look at two of the finest non-Android mobile OSes – Ubuntu Touch and PostmarketOS,
Pi USER
The Pi 5 gets pseudo interlace support
Your old CRT can keep on ticking with a bit of digital magic.
The Argon40 Upton One laptop
Case maker expands into Pi-powered laptops.
DEEPSEEK SLOW DIVING
Les Pounder works with groups such as the
AlmaLinux 9.5
Les Pounder takes a look at a stunning Linux distro that offers a clean user interface, and is snappy even on a Raspberry Pi 5 4GB.
Argon One V5
If Scotty had a Raspberry Pi, he would probably also have this case to put it in, ponders Les Pounder.
Control a world of lights with CheerLights
Bringing cheer and joy wherever he goes, Les Pounder once again creates an illuminating project with a global reach.
IN DEPTH
Into the BLACKWELL
What lurks at the bottom of Nvidia’s deepest GPU technology? Jarred Walton is our man for technological spelunking.
TUTORIALS
Draw in the terminal
Shashank Sharma’s takeaway from years of writing is that if it’s to be done, it can be done from the terminal.
Safe and secure backups to any cloud
Nick Peers takes a deep dive into Duplicati, a backup tool that ensures anything you store in the cloud remains completely private.
Auto-generate ODF documents
Marco Fioretti demonstrates how you can create the same office files that you can make with LibreOffice – but without LibreOffice!
Custom open source health monitoring
Deciding to spy on himself for once, Michael Reed examines the ways we can keep a record of our activities using various pieces of software.
The hardware that made Linux great
Part Two! Don’t miss part three in next month’s issue!
Upgrade it: Home hobbyist 3D printers
Amateur wanderer, part-time teacher and hardcore 3D printerist Alastair Jennings offers his advice for those looking to buy.
Creality K1C
High-quality prints and superb material choice.
Original PRUSA MK4S
Serious about 3D printing? This is a beast.
Anycubic Kobra S1 Combo
Great for accurate multi-filament 3D printing
Snapmaker Artisan
A very versatile machine for hobbyists.
QIDI Plus4
Perfect for those do-it-yourself home improvements.
Anycubic Photon Mono M7 Pro
Top pick for finely detailed 3D printing.
HACKING ACADEMY
HACKING SKILLS AND THRILLS
Nate Drake is a technology journalist specialising in
GitHub hides malware disguised as games
Threat actors are targeting children with new campaign.
Badbox is back!
Million devices affected.
Malvertising
GitHub involved again.
N600 (PAU09) Wi-Fi N USB
Nate Drake heads up to the roof to test whether Panda’s Wi-Fi adaptor offers the best range and performance for budding hackers.
Juicing your hacks up
JUICE SHOP
Kali Linux laid bare
Nate Drake speaks to two of the leading lights of the most famous Linux hacking distro of all time.
CODING ACADEMY
Quickly evaluate poker hands in Rust
David Bolton introduces some more Rust concepts and explains how his poker hand evaluation program works.
ADVERTISEMENT
LINUX FORMAT
GAMES RADAR
WWW.GAMESRADAR.COM
LINUX FORMAT
www.magazinesdirect.com
LINUX FORMAT
magazinesdirect.com
TECHRADAR
www.techradar.com
MAGAZINES DIRECT
magazinesdirect.com
MAGAZINES DIRECT
magazinesdirect.com
TOM'S hardware
MAGAZINES DIRECT
magazinesdirect.com
CODE CLUB
www.codeclub.org.uk
EFF
EFF.ORG
GO COMPARE
Chat
X
Pocketmags Support