Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Stupid, Clever, or Both?

Name: Anonymous 2007-10-24 2:02

I'm doing some expert programming of a tile-based game in which tile classes have references to anonymous functions that return the proper image for that tile. I figure I might as well not duplicate these. Should I make these functions onymous or just have a picture function manager that lets me get at them easily? It would be dead simple to create onymous functions for them at runtime, but it makes me feel funny to do it.

Name: Anonymous 2007-10-24 10:30

>>6
Oops, WTF was I doing, strict evaluation is going to rape you in the second case. You should be doing:
if 'image.png' in sprites:
    img = sprites['image.png']
else:
    img = sprites['image.png'] = LoadImage('image.png')

which is a lot uglier and more error prone than
img = GetSprite('image.png')

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List