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.

Citiți o mostră, înregistrați-vă pentru a citi în continuare.

Mai multe de la Linux Format

Linux Format1 min citite
Important Notice!
DEFECTIVE DISCS: For basic help on running the disc or in the unlikely event of your Linux Format coverdisc being in any way defective, please visit our support site at www.linuxformat.com/dvdsupport. Unfortunately, we’re unable to offer advice on us
Linux Format5 min cititeComputers
Guix System v1.2.0
Guix System is a stateless meta distribution whose origins can be traced back to a research paper. The operating system, which has had its 1.2.0 release, is built around the Guix package manager, which is one of the most advanced open source package
Linux Format4 min cititeComputers
Usability
Finding the right balance between functionality and ease of use is a big ask when working with such expansive applications. We can’t dock points from any of these tools for presenting a cluttered interface. This is because each of these applications