straightliner, 4 days, 22 hours, 24 minutes
Well thanks to the suggestions on the pyglet mailing list and in the comments here, I think I got the effects I want with OpenGL, as well as some extra effects that are suggesting themselves as I play around with the functions. This will be a rather minor accomplishment compared to say, Crysis, but a rather extreme one compared to my previous undertakings, so I'm pretty happy!The game is turning into kind of a cross between Pac-Man and 2D Marble Madness. Up next for tomorrow is figuring out a good way to test the player's position against the track so that you fall off if you stray too far from the rails. It's just a top-down tile map so this shouldn't be too bad. Then I should have a basically winnable and losable level, after that I need more stuff, and especially sound, and everything else. Very detailed I know.
I'm taking a different approach from the last compo I was in (the 7DRL a couple of weeks ago, where I thought I was designing a space shuttle or something) and not spending much time on structuring the code. I'm probably swinging a little bit too far in the opposite direction here, but it's working out OK so far. However for laughs and the sake of posterity I want to post my current level-loading class:
def __init__(self):
for file in os.listdir('data/levels'):
with open('data/levels/' + file) as f:
d = f.readlines()
d = [line.strip().split(' ') for line in d if not line.startswith('#')]
dx = [[LEVEL_KEY[t[0:2]] for t in row] for row in d]
dx = [
[(t, images.__dict__[t], x*TILE, W_H-TILE-y*TILE) for x, t in enumerate(row)]
for y, row in enumerate(dx)]
dx = [[CustomSprite(*data, batch=batch, group=tile_group) for data in row] for row in dx]
self.__dict__[file] = dx
d = [[LEVEL_KEY.get(s[2:3], None) for s in row ] for row in d]
d = [
[(s, images.__dict__[s], x*TILE, W_H-TILE-y*TILE) for x, s in enumerate(row) if not s == None]
for y, row in enumerate(d)]
d = [[CustomSprite(*data, batch=batch, group=sprite_group) for data in row] for row in d if row]
d = [item for sublist in d for item in sublist]
self.__dict__[file + '_sprites'] = d
for item in d:
if item.kind == 'player':
self.player = item
Yes...I did say I was maybe going too far in the opposite direction, right?
(log in to comment)
richard on 2010/03/30 02:14:
Maybe after this comp you might want to look into Cocos2d - it has a tile mapping system with loading and saving of the tile maps. Oh, and it does scrolling (with easy optional constraints) and zooming ;)