Everyone should write a game and this is the perfect venue for doing so - you've only got a week (a lot of game ideas can be written in a weekend) and there's lots of help available. And it's a lot of fun!
This will probably be the last of these posts before I make the project public. It has two code parts. The first is model:
def __init__(self, i, j, has_bomb):
self.i, self.j = i, j
self.has_bomb = has_bomb
def __init__(self, size, chance=.2):
self.size = size
self[:] = [[Cell(i, j, random.random() < chance)
for i in range(size)] for j in range(size)]
def count(self, cell):
'''Count the number of bombs near the cell.'''
for i in range(max(0, cell.i-1), min(self.size, cell.i+2))
for j in range(max(0, cell.j-1), min(self.size, cell.j+2)))
board = Board(20)
And the second is the withgui code:
with gui.canvas(width=320, height=320) as canvas:
for column in board:
for cell in column:
@canvas.image('cover.png', x=cell.i*16, y=cell.j*16)
def on_mouse(image, mouse, cell=cell):
count = board.count(cell)
image.value = 'bomb.png'
print 'GAME OVER!'
canvas.label(str(count), x=cell.i*16+8, y=cell.j*16+8,
Resulting in (youtube vid, sorry about the quality I'm new to this):
Reminder: Next MelbournePUG meeting: Tuesday 11th August
That's TOMORROW NIGHT!
The next meeting of the Melbourne Python Users Group will be on Tuesday the 11th of August starting at 6:30pm. We'll have use of their projector and time for several short presentations or lightning talks.
Martin Schweitzer "Primetime Wordfinding"... It's a rather novel algorithm that I (re)discovered(?)* for finding word matches when given a group of letters (eg. think of the puzzle in the age where you have a grid with 9 letters and have to find words). I then noticed that it had applications to other fields such as bioinformatics (which I won't go into in the talk [unless, of course, there is a particular interest]). It also has a very nice representation in Python - which I will mention.
Richard Jones ... a new cool thing I'm working on
5 minute lightning talks
Chris Miles "Intro to PSI (Python System Information)"
If you've seen something cool or are doing something cool then we'd like you to tell everyone about it! Presentations could be 5 minutes or up to 15 minutes if you'd like to ramble for a bit longer. I'll be getting up to talk a bit about my experiences playing with IronPython - what's cool and what's downright odd :)
If you've got an idea for a talk just add it to the wiki page.