Create games with python: online PyGameZero simulator

I’ve been really impressed with @lordmauve’s PyGameZero module that makes it fun and easy to create games with Python.

This post contains three example python games that you can edit and play online as a showcase of growing PyGameZero support for create.withcode.uk.

Create games with python: Flappy Bird with PyGameZero
Flappy Bird made with PyGameZero

Many students love creating and playing games and most of them have made some really creative animations and projects using Scratch’s graphical programming tools.

One of the big challenges for students is to make the transition from graphical block based programming to text based programming.

It’s harder to make mistakes with blocks but it can also be frustratingly slow if you want to make more advanced projects.

One thing that really helps is creating visual projects rather than just messing with text and numbers, although this often adds extra layers of complexity and confusion.

PyGame allows you to create games with python but can be intimidating for beginners

PyGame is a really powerful python module for creating games but it’s not ideal for beginner programmers as there are all sorts of things you have to understand and write before you can get anything worthwhile up and running.

PyGameZero keeps the fun and features of PyGame but makes it much simpler for beginners

PyGameZero is a fabulous module which is an abstraction of PyGame to make it simpler to create games and animations with code.

Abstraction means removing necessary detail in order to focus on the most important things.

PyGame is very powerful and feature rich but complex to use. PyGameZero is a simplified version that is ideal for creating working games with minimal code

I’ve been working through some of the great PyGameZero examples online and thought it’d be really good if students could try the code out online without having to download anything.

So, I’m working on PyGameZero support for create.withcode.uk so that students and teachers can write, run, debug and share python games online on any device.

It’s a work in progress, which means that there are some features that don’t quite work as they should yet but it’s at the stage where it works enough for you to be able to create games with python on chromebooks / laptops / desktops / tablets.

The next page has a python Space Invaders game that you can adapt and run in your browser.

Online python tkinter simulator: 3 games to help you create python GUIs

I made create.withcode.uk to let teachers and students write, run, debug and share python code online a few years ago in order to try to make it easier for students to experiment with code on any device.

Because create.withcode.uk runs python code in your web browser, you don’t need to install any software or download the code before you run it. You just press Ctrl + Enter to run the whole code, or Ctrl + Space to run it line by line.

This makes it much easier to try out code, tweak it and share it as you’re learning, but it’s only a simulation Python: it doesn’t contain all of the features of Python 3 running offline.

One feature that teachers and students have often requested is Tkinter support.

Tkinter is the GUI (Graphical User Interface) module that comes bundled with python. It lets you create programs that have buttons, text boxes and windows rather than just a text console.

I’m in the process of adding some Tkinter support for create.withcode.uk. It’s a work in progress but I’ve implemented enough for you to get some simple GUI programs working.

There are some great website for running python code online such as trinket.io and repl.it. As far as I know, create.withcode.uk is the only one to have an online python tkinter simulator so that you can test out code to build GUIs in your browser.

Here are some of the programs I’ve been using to test out python tkinter GUI support on create.withcode.uk:

Snake game: Online python tkinter simulator
Game 1: Snake in python tkinter
Bounce game: Online python tkinter simulator
Game 2: Bounce in tkinter
Colour Quiz: Online python tkinter simulator
Game 3: Colour Quiz in tkinter

Note:

These games are examples I’m using to test tkinter support on create.withcode.uk. I didn’t write them: the original authors are credited for each game in the source code and description. Please get in touch if you created these and want me to change the way I’ve attributed your work.

Tkinter isn’t really designed for making games – it’s useful for simple GUIs but there are better python modules out there for creating games (such as pygame). You can find some great books and resources here if you’re interested: https://inventwithpython.com/

Tkinter is a huge module so there’s no way I can simulate it all accurately in a web browser but if you have some code that works offline in ‘proper’ python that doesn’t yet work properly on create.withcode.uk, please share a link to it as a comment on this page and I can use it to help add more features and support.

Have fun!

Create.withcode.uk’s python data visualisation module now available offline

Some of the most popular resources on create.withcode.uk are the bitmap image challenges, which help students see how black and white or full colour images can be represented by 2D or 3D lists of data describing the colour of each pixel.

Data representation of images: Bitmap images
Python data visualisation of images: Bitmap images

A few people have asked if it’d be possible to have an offline version of the withcode python module that is supported by create.withcode.uk which allows you to quickly display a list of data as an image.

This could be useful for lessons or clubs where an Internet connection isn’t available or for use in other python projects.

You can now download a copy of withcode.py from https://github.com/pddring/withcode-py-offline and use it in IDLE / Mu / your favourite python IDE so that your code works in the same way as it would on create.withcode.uk