Friday, May 16, 2014

Squadron4 a simple Python game using curses

How Squadron4 got made

This week I was lucky, and got some spare time, so I wrote a little program - from scratch, over 2 days - (but less than 24h ; so basically it's like the 24h comics challenge but for game programming).

I was also lucky because my development machine is an old (from 2004-2005) iBook g4 powerpc based, running 10.4.11 and the default installed python running on it was a version 2.3 ... But, very supremely cool website is keeping an archive of their latest release (python 2.7.6) for powerpc (ppc) platform (running 10.3.9 and higher)! This was really totally awesome of them to do so.

So now I'm running python 2.7.6 and I also installed pygame 1.9.1 (but haven't had time to test it yet).

What is "Squadron4"?

A very basic platform game written in Python 2.7 using the standard curses library - with only one level (but since the program use random location, technically this could be considered as an infinite number of levels).

Work best with a terminal window of 80x24 - during the test phase, I had the best game experience with this relatively small area, and it's also incidentally the default size of the terminal in OS X.

The goal of this game is for the player ( the little '@' symbol) to collect the four flags represented by symbol '1','2','3' and '4' that are disseminated over the 4 corners of the game area.

But the challenge for the player in the flag collection is to avoid (or trap) the chasers (symbols : 'c', 'd', 'e', 'f') that are after him ; to render the flag collection even more challenging in the middle area 4 balls are bouncing endlessly and can't be destroyed (but they can be trapped).

The task has to be done before the countdown (which start at 1000) reach 0.

When the player decides to use a "magnet block" (by pressing 'f' or space bar) the countdown is reduced by 20, so part of the tactic is to use them wisely.

When the four flags are collected - they are seen in the lower status bar between brackets - the game ends, and the high score is presented.

The idea of the game is to see the interaction between 4 different moving objects :

  •     one controlled by the player (symbol : '@')
  •     4 bouncing balls (symbol : 'o')
  •     4 chasers that will track the player (symbols : 'c', 'd', 'e', 'f')
  •     and magnet blocks fired by the player to trap the chasers (symbol : 'B')

Keys for the player '@' :

  •     Arrow keys to move
  •     'f' or space bar to launch a magnet Block
  •     'q' to Quit the program

How to win?

A tactic to win, is to use the obstacle blocks which are part of the decor, or to launch some magnet blocks to trap the chasers. If the chasers are getting too close, they will prevent the player's movements, or may actually completely prevents all movements ; then the only option is to quit the game (by pressing 'q'), or to wait for the countdown to reach 0.

Where is squadron4?

It is hosted at - and here are :
  • the link of the whole project.
  • the link to the Python source :
  • and some screenshots of the game:

Sometime player wins :

Sometime player loses:

No comments: