Está atualmente a visualizar o Portugal versão do sítio.
Gostaria de mudar para o seu sítio local?
12 TEMPO DE LEITURA MIN

PYTHON

Code a multiplayer shoot-em up game

In the first of a two-part series, Andrew Smith takes you though coding a multi-player shooter in good old Python.

Part One!

Don’t miss next issue, subscribe on page 26!

OUR EXPERT

Andrew Smith is a software developer for NHS Digital, has a bachelors degree in software engineering and a master’s degree in computer networks.

The merciless forces of Hell have launched a deadly invasion in our region of deep space, and you have been recruited to repel this attack. Mankind is depending on you! Yes, this month we’re going to look at Star Fighter, a video game created by Francis Michael Tayag. Star Fighter has been written as a classic spaceship shoot-em up style arcade game, which is played as a single player taking on computergenerated opponents.

The video game project consists of game music, sound effects, animations, bullets shooting from the spaceship and enemy characters with associated attack patterns, not to mention a fully implemented menu system to configure game options. A player can also enter their name on a scoreboard at the end, which is saved. Many of these features will be covered in this month’s instalment. To get started we need a few things: Python, PyGame and the Star Fighter source code.

Installation and setup

To install Python, open a terminal window (Ctr+Alt+T) and type sudo apt-get python3 followed by sudo aptget install pip3 . Then install the PyGame module by typing pip3 install pygame . To make sure that you’re using PyGame version 2.0 (because Star Fighter does use a fairly recent version of PyGame), type python3 -m pip install pygame==2.0.0 . You should now have version 2.0 of PyGame installed.

Star-Fighter in-game shots from its hot Galaxian-style shooting action.

Finally grab a copy of the Star Fighter project source code by cloning the GitHub repository. Before typing the following to clone (copy) the GitHub repository, move into a folder on your system that you would like the project to be copied to. git clone http://github.com/zyenapz/Star-Fighter

You should now see a folder structure shown in the screenshot (see facing page, above right). Navigate into the SOURCE folder where you’ll find the main python file for the game, game.py. To experience playing the game, type the following: python3 ./game.py

Before continuing, take some time to learn what’s available to use in the game, such as the menu system which has been implemented, what the game controls are (mainly the cursor keys and Z key for firing) and in general how the game plays…. oh and of course, enjoy blasting the nefarious agents of Hell back to where they came from, before moving on with this tutorial.

Desbloqueie este artigo e muito mais com
Pode desfrutar:
Desfrute desta edição na íntegra
Acesso instantâneo a mais de 600 títulos
Milhares de edições anteriores
Sem contrato ou compromisso
INSCREVA-SE AGORA
30 dias de teste, depois apenas €11,99 / mês. Cancelar em qualquer altura. Apenas para novos subscritores.


Saiba mais
Pocketmags Plus
Pocketmags Plus

Este artigo é de...


View Issues
Linux Format
November 2021
VER NA LOJA

Outros artigos desta edição


WELCOME
Windows Insider
So after saying it would never exist, Microsoft
LINUX FORMAT
MEET THE TEAM
REGULARS AT A GLANCE
Newsdesk
THIS ISSUE: Sir Clive Sinclair Steam Deck improvements WSL malware EU RISC-V chips Old Ubuntu gets extended support
GAMING
Linux games get faster
SECURITY
WSL malware discovered
THE MOST WANTED
PostgreSQL is currently ranked the “most wanted” database
SINKING FEELING
I was talking to a company recently who
European RISC-V chip gets closer
Test samples of the EPI’s RISC-V processor have been delivered
Linux 5.15 NTFS
The forthcoming kernel will come with a driver for better Linux support of the NTFS filesystem
Ubuntu 14/16.04
Both LTS versions have their lifecycles extended to an impressive 10 years
Distro watch
What’s behind the free software sofa?
STREAMY WINDOWS
GStreamer is a powerful multimedia framework with over
HITTING THE M1
Jon Masters has been involved with Linux for more than 22 years
KERNEL WATCH
Jon Masters summarises the latest happenings in the Linux kernel, because someone has to
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
HotPicks
Czkawka>> Cozy>> Tomatoid5 >> Scrcpy >> VMPK >> Biblioteq >> Timefind >> SuperTuxKart >> Fheroes2 >> Reptyr >> Hover Zoom+
Cozy
AUDIO BOOKS PLAYER
Tomatoid5
Version: 0.1 Web: www.pling.com/p/1574941
Scrcpy
Version: 1.18 Web: https://github.com/ Genymobile/scrcpy
VMPK
Version: 0.8.4 Web: https://github.com/ pedrolcl/VMPK
Biblioteq
ARCHIVING TOOL
Timefind
WEB ARCHIVE TOOL
SuperTuxKart
Version: 1.3 RC Web: https://supertuxkart.net
Fheroes2
Version: 0.9.7 Web: https://github.com/ ihhub/fheroes2
Reptyr
TERMINAL RE-PARENT TOOL
Hover Zoom+
Version: 1.0.180 Web: https://github . com/extesy/hoverzoom
On the disc
Discover the highlights from this month’s packed DVD!
Finnix 123
Never underestimate terminal-based file managers. 64-bit SYSADMIN’S DELIGHT
Lakka 3.4 & LibreELEC 10
LEISURE APPLIANCES MIN SPECS: N/A 64-bit S ince
AND MORE!
THE LXF LIBRARY ● Advanced Bash Scripting Guide
REVIEWS
REVIEWS
FireCuda 530 2TB
Asus Tinker Board 2S
This is the little board that couldn’t, says a disappointed Les Pounder as he tries a board that’s definitely no Raspberry Pi
Zorin OS 16 Core
A way to move operating systems, or a desktop with an identity crisis? Neil Bothwick pretends to be a Windows lover while he tries Zorin OS
Rescatux 0.73
With its fairly descriptive name for a distro, Neil Bothwick finds out in just what situations it can rescue our little penguin
Deepin 20.2.3
Deepin is an independent distro originating in China. Neil Bothwick tries it to see what he can take away from the experience
American Truck Simulator
Management is firm: no new pay rises. So they’re terrified that Andy Kelly is planning to retrain as a highly paid truck driver
ROUNDUP
Static site generators
Web development is a complex activity, but you can publish a simple website with the help of static site generators and Markdown files
Installation
You generally install using a package manager, but in some cases you cut and paste
Configure your project files
To make a great webpage, you need the project files to be well structured
Usability
Using generators helps set the style
Programming language
Your choice may be dictated by the language
Frameworks
In some cases, you can use web frameworks with these static generators
Platform support
Things are always easier with a bit of support
Updating sites
Easy updates are vital
The Verdict
Static site generators
LINUX WINDOWS
Old rivalries have been forgotten and ancient boundaries blurred. Jonni Bidwell investigates this new Redmond-Penguin harmony
Platforms, Trusted Platforms and Windows 11
Windows hardware requirements have always promoted confusion, sand this time is no different…
Linux in Windows
Never mind Windows 11, the latest version of the Windows Subsystem for Linux is where it’s at
Year of the Linux desktop (on Windows)
Running graphical applications is impressive, so the next step is to try and run a complete desktop. What are you waiting for?
Duelling OSes
Linux has always tried to co-operate with Windows oddities, and despite common gripes, it does an amazing job
Pi USER
Astro Pi 2021/22 launches with new kit
Seven super-successful years on and the Astro Pi models get a hefty upgrade for the next competition
Node-RED 2.0
Les Pounder enjoys building things, and with Node-RED 2.0 he can construct the Internet of Things directly from his beloved Raspberry Pi
Controlling the Pi’s GPIO with Scratch
Les Pounder shows how we can use Scratch with simple electronics
Setting atomic-clock precise time on your Pi
Sean Conway makes use of a Raspberry Pi Hat to pass some time, by setting up a GPS receiver to establish an accurate clock
IN-DEPTH
INSIDE THE INTEL 4OO4
Mike Bedford shows you how to use an emulator to get hands-on experience of the microprocessor that started a revolution
LINUX FOR THE SOUL
Jonni Bidwell wants a free, enterprise-grade operating system and word on the street is AlmaLinux is the coolest one going…
TUTORIALS
Create efficient backups
Backups aren’t just a safety net for Trekkies such as Shashank Sharma, but a way of life. But they can take up quite a lot of space if not done right…
Network-share files quickly and easily
Nick Peers reveals how to share files over your local network without getting bogged down in networking protocols
MOBILE SHARING OPTIONS
You’ll find additional sharing options are available when
Running the classic Tandy TRS-80
Les Pounder travels back in time to when Doctor Who had a mop of curly hair and a trio of computers ruled our homes
How to build the Linux Format server
Start running your own server with the help of David Rutland and our new series on what to do with one once you’ve got it!
Build your own custom Ubuntu distro
Why settle for what the existing distributions have to offer? Michael Reed looks at Cubic, a tool for creating your own custom respin based on Ubuntu
Improve your shots using optical filters
Mike Bedford looks at the benefits of photographic filters and how to emulate them – but some effects can only be achieved optically
CODING ACADEMY
Create a RESTful server in Go
Learn the theory behind REST as Mihalis Tsoukalos explains how to develop a concurrent RESTful server in Go
Conversa
X
Suporte Pocketmags