Richard Jones' Log

Sun, 28 Jan 2007
So busy...

Too busy, it seems, to be able to put in a solid entry to the most recent game programming challenge: the LD48 8.5 warmup 24-hour challenge. Yes, a game in 24 hours :)

It was a bit of fun though. I put pyglet's 2d scene code through its paces. I'm quite happy that I was able to throw together something pretty and playable in a short amount of time *and* code.

All up I spent about 6 hours on the game. A couple of those were spent debugging pyglet's xlib key handling. A little more on fixing a sprite texture border issue and generally fixing some aspects of the 2d scene code.

The game is checked into the pyglet SVN repos in the "examples/ld24-lander" directory. A screenshot (big) is over here.

Yes, it's Lunar Lander. Completing the game (time limit, fuel limit, ...) is left as an exercise for the reader :)

Sun, 21 Jan 2007
A better python cheese shop, what you can do

Rene Dudfield posts some of his ideas about that he'd change in the Cheese Shop.

I'd like to help people out by supplying some thoughts about how to address his points:

1. What has changed in this release of software?
A number of package maintainers -- including myself but also those responsible for the "zope." packages -- are now including a change note in the setup.py description field which lists the changes for a given release. This field may be formatted in ReStructuredText so you can get pretty fancy.
2. Faster browsing.
This one's tricky as the browse interface is by nature quite complex. Given the browse combinations possible, caching would be very hard. The interface itself has been optimised a couple of times, but anyone is welcome to have a go at it and make it even faster.
3. Screen shots.
See point #1 about ReST. There's nothing stopping you adding in a link to screenshots -- or even embedding images -- in your package's description.

If you're interested in working on the interface I'm always happy to accept contributions, and even happier to accept volunteers to help look after it (I'm still the only one :). There's info on how to go about this linked from the Cheese Shop itself through the Developers link in the sidebar.

Tue, 16 Jan 2007
PyCon sprinting ideas

I've got two ideas for the sprint time at PyCon. I'd like to do something fun this time, rather than Yet Another PyPI Sprint.

My choices:

  1. Do some work on pyglet.
  2. Write a game. This could be a collaboration or could be competitive. I'm not sure of the details yet.

I'm more interested in the second one - but it'd need participants to make it work. For pyglet I can just sit in the corner :)

I could run a pyglet tutorial as well.

PyWeek #4 in April!

PyWeek#4 (a cold cup 'o tea) is has been scheduled the first week of April:

Start: 00:00UTC Sunday 1st April
Finish: 00:00UTC Sunday 8th April

REGISTRATION IS NOT YET OPEN
Registration will open at the start of March. Visit the PyWeek website for more information.

THE PYWEEK CHALLENGE:

  1. Invites all Python programmers to write a game in one week from scratch either as an individual or in a team,
  2. Is intended to be challenging and fun,
  3. Will hopefully increase the public body of python game tools, code and expertise,
  4. Will let a lot of people actually finish a game, and
  5. May inspire new projects (with ready made teams!)

Entries must be developed during the challenge, and must incorporate some theme decided at the start of the challenge. The rules for the challenge are at the website.

category: Python | permanent link
Mon, 15 Jan 2007
PyCon confirmed

I arrive Dallas FT Worth on Feb 22nd at 2:50PM. Haven't figured how to get to hotel yet. Staying for sprints (most likely pyglet-related) and leaving Mar 2nd for Columbus OH. Staying there for 2 days then off to Champaign IL for another 2 days then back home. If anyone would like to get together at any of those places, let me know :)

Sat, 13 Jan 2007
Another pyglet update

pyglet's tile/sprite bits got event handling in the last couple of days. I reckon it's pretty cool and should greatly simplify development of sprite/tile based games (that use the mouse). It looks like (given a view):

# attach the following event handler to the view
@event(view)
# only highlight cells
@for_cells()
def on_mouse_enter(cells, x, y):
   ' The mouse is hovering over the indicated cells. '

@event(view)
@for_cells()
def on_mouse_leave(cells):
   ' The mouse has stopped hovering over these cells. '

@event(view)
# just for the car sprite
@for_sprites([car])
def on_mouse_press(sprites, button, x, y, modifiers):
    ' Car has been clicked '
 
# also:
def on_mouse_release(sprites_or_cells, button, x, y, modifiers):
    pass
def on_mouse_drag(sprites_or_cells, x, y, dx, dy, buttons, modifiers):
    pass
def on_view_enter(sprites_or_cells, x, y):
    ''' sprite or cell has entered the View (even if potentially
    obscured by another cell / sprite) '''
def on_view_leave(sprites_or_cells, x, y):
    ' sprite or cell has left the View '

@event says what event dispatcher to hook the handler on to. The @for_cells() call tells the dispatcher to generate events for all map cells for all maps in the view. We could have passed a list of maps to interrogate as @for_cells([m1, m2, m3]). We also could have said @for_cells(is_base=True) to have it only generate events for cells that have properties['is_base'] == True. If we didn't say @for_cells then we'd get events for sprites too. For example:

@for_cells()             # for any map cell
 
@for_cells([map, map])   # may have multiple maps
# event could be generated for every cell in the map(s)
 
@for_cells([map], name=value, name=value)
# looks up property by name on Cell, then Tile, then TileSet
 
@for_cells([map], id='exit_door')
# could be defined on Cell or Tile -- "id" special-cased as an attribute
 
@for_cells([map], red_base=True)
 
@for_cells([map], type='grass')
# would be defined on Tiles by convention - but there's nothing
# stopping an exceptional Cell having a "type" property
 
@for_cells([map], group='grass')
# would be defined on TileSets by convention
 
@for_sprites()          # all sprites are active
 
@for_sprites([list of sprites])      # limited list of sprites active


# filters may be chained: 
@event(view)
@for_cells([map1], ...)
@for_cells([map2], ...)
def on_mouse_press(cell, ...):
    ...

There's a practical demonstration of this and another new feature -- adding drawing effects to Cells, Tiles, etc (any "Drawable") -- in tests/scene2d/RECT_FLAT_MOUSE.py

category: Python | permanent link
Thanks, Aleecia

Thanks, Aleecia, what a pleasant surprise!

category: Noise | permanent link
Thu, 11 Jan 2007
pyglet update

Over Christmas and the New Year I've finally had some chances to get my hands dirty and contribute some more pyglet code (beyond the meagre xlib code I added many moons ago). I've been working on the 2D scene code:

  • rendering of rect and hex maps to a viewport (usually whole window)
  • loading a tileset and map from an XML spec
  • running a simple simulator driving a sprite around that map

Points of interest:

  • you can have many maps of differing dimensions and offsets in layers
  • views may be anchored, allowed to scroll and asked to stick to map boundaries
  • map cells may have a tile (image) and/or properties (or nothing)
  • map / tileset loading is done through a new generic resource loader which is easily extensible

Still to do:

  • events for sprites / tiles -- mouse enter/leave, button press, mouse drag (this has been designed and partially implemented)
  • sprite collision
  • resource saving

Alex has been incredibly productive working on the layout code (which now has funky event generation), but I'll let him describe that work. It's so cool.

I hope to start the "intro to pyglet" tutorial soon...

category: Python | permanent link
Tue, 09 Jan 2007
We're back!

The DNS for mechanicalcat.net is resolving again! It's a long, annoying story, but hopefully won't happen again. Sorry for any inconvenience caused.

p.s. I can start talking about the cool stuff going on in pyglet now :)

Wed, 03 Jan 2007
Heroes fans, rejoice!

Greg Beeman has a weblog. He's one of the two director/producers on the show and is blogging about the creation of each episode as it airs. There's an incredible insight into the processes and people behind the shows in each blog entry. I can't wait for the DVDs :)

category: Noise | permanent link
Mon, 01 Jan 2007
Bruce the Presentation Tool updated

Anthony and I (amongst others) used Bruce the Presentation Tool during our talks at OSDC back in December. Of course a large part of writing the talks consisted of hacking on the presentation tool to add new cool features. Anthony's put in the hard yards and cleaned up that hacking, releasing version 1.2 for your presentational pleasure.

This release has the new driver script, "socrates.py" which enables writing presentations in a much more terse, plain-text file. There's heaps of other stuff too like support for spawning external processes, code page highlighting (very cool for walking through code samples), ...