Linux Format

Code a classic card game in Python

OUR EXPERT

 Calvin Robinson is a former assistant principal and computer science teacher with and a degree in computer games design and programming.

Over our series of tutorials for games programming in Python, we’ve created a Lunar Lander-style module game, a side-scrolling platformer, Pac-Man, Pong, Game of Life and a shooter. This issue we’re going to recreate another classic, Snap!

Traditionally a card game, the game presents a number of images and the player has to react with haste in order to win. Since we’re developing an electronic version of Snap, we’ll use emoji images instead of playing cards, but you could also adapt this to suit your personal preference.

First, we’ll need to make sure that we’ve got Python downloaded and installed. On a Debian-based distro it’s a simple sudo apt-get update followed by sudo apt-get install python3 . To code in Python we can either use the IDLE or any text-based editor. Type touch snap. py in Terminal to create an empty Python file for this project that we can use as soon as we’ve got everything else set up.

With Python installed and set up, we’ll also need to download , a module from by manually downloading the Zip file, or use git clone https://lawsie.github.io/guizero . Either way, you’ll need to save the guizero folder in the same parent directory as your .py Python file. For instance, snap.py would be saved in Docs, as well as guizero being copied into Docs. is built on , but is even more accessible. As with any programming, we don’t want to re-invent the wheel; if someone has put together a package to make our lives easier then it makes sense to take full advantage of it.

You’re reading a preview, subscribe to read more.

More from Linux Format

Linux Format1 min read
Ultimate Desktop Upgrade!
LXF316 will be on sale Tuesday 28th May 2024 Word processors that can help craft that novel you’ve always been talking about and organise large projects. Revive the old roleplaying system for a digital age as we recreate our own play-by-mail gaming
Linux Format4 min read
Linux
The #1 open source mag Future Publishing Limited, Quay House, The Ambury, Bath, BA1 1UA Email contact@linuxformat.com EDITORIAL Editor-in-chief Neil Mohr Art editor Fraser McDermott Production editor Katharine Davies Group editor-in-chief Graham Bar
Linux Format2 min read
Platform Support And Editions
Kali has a huge variety of install options, and these include images for ARM-based computers and pre-made virtual K machine images for most of the popular virtualisers. It’s even possible to install a version of Kali on to an Android-powered device.

Related Books & Audiobooks