Python Beginners – Space Defender

                                       ImageToday in the Python group we looked at how a few simple changes can change the look and feel of a game. Our space Defender game uses code recycled from last weeks Bunnies And Badgers game combined with a few new sprites to make a completely new game. We also looked at how to use Geometry when moving sprites around the screen.





The above code calculates how many pixels the x and y coordinates of our sprite needs to be changed for it to move 10 pixels in the direction of angle_z. You can learn more about Sin and Cos here.

Python Beginners- Week 6: Lists

Today the Python group began looking at the Hangman Game from Invent Your Own Computer Games with Python ( There are many new concepts in this game so we are going to spend the next few weeks looking at these.

We looked at Lists which are a way of storing a number of values in one variable. We had some fun writing code snippets mainly based around X-Factor. They are available here

We looked at some new ways of working with strings such as multi-line strings.  We also learned about new types of functions called methods.

Next week we will be looking at a new type of loop called a for loop.

Here are my slides from today. python session6

Python Beginners- Week 5: Adventure Game and Comparing Python Functions to Scratch Blocks

Today we finished our adventure game. Here is the source for it.

#This is my adventure game

import time

def scene1():
 print('You are standing on a trail in a forrest')
 print('Before you the trail splits in two')
 print('Which way will you go right or left?''\n')
def makeChoice():
 choice = ''
 while choice != '1' and choice != '2':
 print('Press 1 followed by enter to choose the first option')
 print('Press 2 followed by enter to choose the second option')
 choice = input()
 return choice

def scene2A():
 print('\n''You come to a stream with bridge')
 print('You can cross and follow the trail that leads from the bridge')
 print('or follow the trail that leads along the nearside of the river''\n')

def scene2B():
 print('\n''you come to a steep hill')
 print('you can climb over the hill')
 print('or you can follow the trail which leads around it','\n')

def goodEnd():
 print('You travel along until you hear people''\n')
 print('They sound like they are having fun''\n')
 print('You suddenly see them and realise it\'s your friends having a picnic')
 print ('they share their food and drinks with you and you have a great time')

def badEnd():
 print('You travel along''\n')
 print ('on and on''\n')
 print('you have no idea where you are''\n')
 print('suddenly you realise you are back where you started')
#main program starts here
playAgain = 'yes'
while playAgain == 'yes' or playAgain == 'y':


#use the makeChoice function to get
 #the player to decide which way to go
 firstChoice = makeChoice()

#this if else statement will show the next
 #scene based on the players choice
 if firstChoice == '1':

secondChoice = makeChoice()

#this if else statement will show the next
 #scene based on the players choice
 if secondChoice == '1':

print('Do you want to play again? (yes or no)')
 playAgain = input()

We also took a look at Snap which is an extended re-implementation of Scratch that allows us to build our own blocks. Snap is available at We compared our Python code to a similar Snap script.


We compared Python functions to Scratch blocks and made a few blocks of our own using Snap. Here are my slides from today. python session5

Python Beginners – Week 4: Adventure Game

This week we looked at creating a game from the beginning and at the steps we might go through to complete it. We looked at flowcharts and pseudocode and then we broke down the program into bite size pieces and wrote functions for these. We got about half way through this and hopefully we’ll complete it next week. Here is a screenshot of what we have completed so far.

screenshotHere are my slides from this week. python session4

Python Beginners – Week 3: Functions

This week the Python group looked at Functions, Escape Characters and Boolean Operators. We also started to rewrite the Dragon’s Realm game which we will continue with after the break. Don’t forget to look at chapters 5 and 6 of “Invent Your Own Computer Games with Python” . Here are my slides from today- python session3

Python Beginners-Week 2: Our First Real Game

We had a good turn out at the python group again today. We did a lot of typing which some of the younger Ninjas found hard going. We won’t be doing that much again for a few weeks. We did a number guessing game which contained some concepts which are used in most computer programs. Our number guessing game is explained in chapter four of “Invent Your Own Computer Games with Python” by Al Sweigart