Sie sehen gerade die Germany Version der Website.
Möchten Sie zu Ihrer lokalen Seite wechseln?
13 MIN LESEZEIT

PYGAME

Classic pseudo-3D racing road effects

With a bag of 10p pieces in hand, Andrew Smith whisks us back to the classic arcade days to recreate pseudo-3D racing games.

OUR EXPERT

Andrew Smith is a software developer @ NHS Digital, has a Bachelors degree in Software Engineering and an MSc in Computer Networks.

C ue the budget wibbly-wobbly ‘going back in time’ special effects, as for this coding tutorial we’re going to look at some the old-school techniques used in some of the classic racing video games such as Road Rash (1991), Outrun (1986) and Pole Position (1982). Designed to work smoothly on low-powered hardware, these are smart visual tricks that create a fake 3D effect.

What is known as pseudo-3D techniques were used to create a simulated 3D racing effect. The games would often be played by a single player or two players against computer opponents. The Pseudo 3D Road project (created by Ray Tomely) that we will be looking at, even though not a full video game, is a selection of examples of pseudo-3D techniques demonstrating ways to generate the 3D effect. You will see that once the project has been downloaded, these programming techniques are located in different folders that each demonstrate a pseudo-3D effect.

Getting started

To get started we will need a few things: Python, PyGame and the Pseudo 3D road project. To install Python, open a terminal window (Ctrl+Alt+T) and type sudo apt-get python3 followed by sudo apt-get install pip3 . Then install the PyGame module by typing pip3 install pygame .

Finally grab a copy of the Pseudo 3D road project from https://raytomely.itch.io/pseudo-3d-roadcollectionby clicking the Download button on the page. Once downloaded, extract the contents of the pseudo_3d_road_collection.rar file into an accessible location on your system.

As an example, the whole project has been put into a folder called PythonProjects which was created before downloading the project. The source code and project can be retrieved from the LXF281 DVD. This tutorial will focus on the source code located in the folder called simple_road. If you’re not already in that folder, type cd simple_road to get into it.

To edit and view the source code you can either use a default text editor installed on your flavour of Linux (Ubuntu for example) or you could use something more specific such as Notepad++, PyCharm or VS Code. The choice is entirely up to you. For this tutorial, we will be using gedit to view and edit the source files. When using this method to view/edit source files, it maybe helpful to open up two console windows where one will be used for editing/viewing source files and the other is a terminal window for executing the PyGame code.

Schalten Sie diesen Artikel und vieles mehr frei mit
Sie können genießen:
Genießen Sie diese Ausgabe in voller Länge
Sofortiger Zugang zu mehr als 600 Titeln
Tausende von früheren Ausgaben
Kein Vertrag und keine Verpflichtung
Versuch für €1.09
JETZT ABONNIEREN
30 Tage Zugang, dann einfach €11,99 / Monat. Jederzeit kündbar. Nur für neue Abonnenten.


Mehr erfahren
Pocketmags Plus
Pocketmags Plus

Dieser Artikel stammt aus...


View Issues
Linux Format
October 2021
ANSICHT IM LAGER

Andere Artikel in dieser Ausgabe


WELCOME
Customised heart
One of the strengths of the open source
MEET THE TEAM
This issue we’re customising our Linux desktops. What’s your go-to desktop of choice and do you have a top customising tip for our dear readers?
REGULARS AT A GLANCE
Google slams Linux kernel
The tech behemoth believes the Linux kernel is in need of major investment to improve security
LibreOffice 7.2 released
The latest version of the venerable office suite is now available. Will more businesses choose to use it?
Devs love Linux (but prefer Windows)
Latest Stackoverflow results offer interesting insights
SCORES ON THE DOORS
Keith Edmunds is MD of Tiger Computing Ltd,
HERD IN THE CLOUD
Matt Yonkovit is Percona’s Head of Open Source
Mozilla gets chatty
Mozilla Common Voice adds 16 new languages to its roster
Russian RISC-V designed CPUs
Eight cores, 2GHz and coming to laptops by 2025
Krita 5.0 beta released
Digital painting application receives a big update
VIRTUAL SUMMER
Lubosz Sarnecki is a senior software engineer working
Distro watch
What’s down the side of the free software sofa?
IT’S ABOUT TIME, TOO
Jon Masters has been involved with Linux for
KERNEL WATCH
Jon Masters summarises the latest happenings in the Linux kernel, so that you don’t have to
ONGOING DEVELOPMENT
Matthew Wilcox has worked hard on a patch
Answers
Got a burning question about open source or the kernel? Whatever your level, email it to lxf.answers@futurenet.com
MAILSERVER
WRITE TO US Do you have a burning
Helpdex
shane_collinge@yahoo.com
LETTER OF THE MONTH
Just do it Like most people, I would
PDF Mix Tool
Alexander Tolstoy is so excited after replacing ‘ls’
DroidCam
Version: 1.8 Web: https://github.com/dev47apps/droidcam D roidCam is a
Fractal
Version : 4.4 Web : https://gitlab . gnome.org/GNOME/fractal
Polyfoto
Version: GIT Web: https://github.com/shanedrabing/polyfoto T he photo
ImprovedTube
Version: 3.232 Web: https://github.com/code4charity/YouTube-Extension : H ere
LSD
Version : 0.20.1 Web : https://github . com/Peltoche/lsd
Pam_usb
Version : 0.7.3 Web : https://github.com/mcdope/pam_usb S ecurity
Billiards
Version : GIT Web: https://github.com/tailuge/billiards T he world
Blues Brothers
Version : GIT Web : https://github.com/cyxx/blues B lues
EasyEffects
Version : 6.0.3 Web : https://github.com/wwmm/easyeffects I n
Latte Dock
Version : 0.10 Web : https://invent.kde.org/plasma/latte-dock T his
Linux Mint 20.2 “Uma”
Discover the highlights from this month’s packed DVD!
Elementary OS 6.0 “Odin”
FREE AS IN AWESOME MIN SPECS: 4GB RAM,
LINUX LOVES WINDOWS
Linux comes baked into Windows 11, so get the most out of Microsoft’s latest by using Linux!
REVIEWS
AMD Ryzen 7 5700G
The AMD APU makes a more-than-welcome return for Chris Szewczyk.
XPG Gammix S50
PCIe Gen 4 and TLC memory for a price you can afford? Jeremy Laird would never fall for that old tale…
Pop!_OS 21.04
A desktop distro that offers a different way of working… Neil Bothwick spends a night on the tiles with Pop!_OS
NixOS 21.05
A complete working distro created from a single configuration file sounds different, and Neil Bothwick discovers that it is
EndeavourOS 2021.08
Arch Linux is beginning to rival Ubuntu as the starting point for modern distros. Neil Bothwick looks at one such distro
Linux Mint 20.2
Jonni Bidwell is running low on mint metaphors and time, but the promise of some budget mojito mix expedited this review
Griftlands
Management love a tough negotiation but not with the staff, so Sam Greer will be getting a quick visit from the LXF shock troops right about now…
ROUNDUP
Digital art programs
Donning a big shirt and a beret, Michael Reed examines five open source art packages, and discovers how they can help him tap into his creativity
The range of painting tools
What features does the application have and what tasks can it handle?
Brush and pencil options
Brushes are a fundamental part of digital painting
User interface and experience
Is the creative process helped or hindered?
Image processing and retouching
Some of the software on test can edit existing images, such as photos
Documentation and tutorials
What resources exist to help you learn how to use the software?
Text handling
Often, when working with images, you’ll need to work with text, too
Working with lines and shapes
How is vector drawing handled in this month’s Roundup candidates?
The Verdict
Digital art programs
CUSTOMISE MINT 2O!
Linux Mint is fantastic, but it’s also flexible, malleable and tweakable. Jonni Bidwell shows you how to truly make it your own
The joy of tinkering
Sort out roll-backs so you can customise Linux Mint with impunity and immunity (to problems)
Tweaking Cinnamon
See how easy it is to make your mark on Linux Mint’s flagship desktop environment and beyond!
Installing KDE Plasma
Transform your desktop with the smooth, svelte, sumptuous experience that is KDE Plasma and go complete next-gen with the Wayland too!
Ultralight Mint
Embrace minimality and learn some keyboard gymnastics with the featherweight Sway desktop
Pi USER
New scheme to recycle old Raspberry Pis
Putting a stop to the running joke of everyone having a drawer full of unused Pis
SparkFun qwiic pHat
Les Pounder wants another slice of Raspberry Pi and he needs it real ‘qwiic’! Complaints about bad gags to the usual address…
Drawing shapes with maths and code
Les Pounder shows how we can use simple maths to draw patterns and shapes, just like a classic childhood toy
Pinhole photography with the HQ Camera
Interchangeable lenses enable us to experiment with that historical curiosity, the pinhole camera, Mike Bedford shows you how
Building a better file server with the Pi
Christian Cawley shows you how to get the most out of your Raspberry Pi-powered Nextcloud server
IN-DEPTH
IT’S A VIRTUAL SERVERWORLD
From his caravan in a field in North Wales, David Rutland takes you on a touring holiday through the world of virtual private servers
TUTORIALS
Better man pages
A fondness of reading is a good habit to inculcate, but Shashank Sharma believes it requires more than spending quality time with man pages
Add real power to your clipboard
Nick Peers dons his best hiking gear and goes hunting for a simple clipboard tool to rule them all. CopyQ is happy to oblige
Going back to 8-bit with the Atari 800
Les Pounder goes back to a time before E.T. cartridges were buried in the desert and 48KB was considered lots of RAM
Understanding the power of certificates
Stuart Burns walks through what certificates are, setting up a certificate server in your local network and how to use it
Create, edit and use custom mapping data
If you like Google Maps you’re going to love QGIS. Mike Bedford shows you how to get started and introduces some of its functionality
Get better Steam and Proton gaming
Michael Reed looks at what it takes to run a large variety of games under Steam, including those designed to run on Windows
CODING ACADEMY
Build a dynamic app security pipeline
Dynamic Analysis Security Testing takes centre stage in the third instalment of our Web Application Security series with Tim Armstrong.
Chat
X
Pocketmags Unterstützung