comparison gamelib/state.py @ 23:1e90a3e4618e

Add code for blitting Scene.
author Simon Cross <hodgestar+bzr@gmail.com>
date Sun, 22 Aug 2010 18:07:48 +0200
parents 8e709824306d
children 0f25f7b9b37a
comparison
equal deleted inserted replaced
22:8e709824306d 23:1e90a3e4618e
1 """Utilities and base classes for dealing with scenes.""" 1 """Utilities and base classes for dealing with scenes."""
2 2
3 from albow.resource import get_image, get_sound 3 from albow.resource import get_image, get_sound
4 4 from pygame.locals import BLEND_ADD
5 5
6 def initial_state(): 6 def initial_state():
7 """Load the initial state.""" 7 """Load the initial state."""
8 state = State() 8 state = State()
9 # TODO: populate state 9 # TODO: populate state
38 # map of thing names -> Thing objects 38 # map of thing names -> Thing objects
39 self.things = {} 39 self.things = {}
40 self._background = get_image([self.FOLDER, self.BACKGROUND]) 40 self._background = get_image([self.FOLDER, self.BACKGROUND])
41 41
42 def draw_background(self, surface): 42 def draw_background(self, surface):
43 pass 43 surface.blit(self._background, (0, 0), None, BLEND_ADD)
44 44
45 def draw_sprites(self, surface): 45 def draw_things(self, surface):
46 pass 46 for thing in self.things.itervalues():
47 thing.draw(surface)
47 48
48 def draw(self, surface): 49 def draw(self, surface):
49 self.draw_background(surface) 50 self.draw_background(surface)
50 self.draw_sprites(surface) 51 self.draw_things(surface)
51 52
52 53
53 class Thing(object): 54 class Thing(object):
54 """Base class for things in a scene that you can interact with.""" 55 """Base class for things in a scene that you can interact with."""
55 56
57 pass 58 pass
58 59
59 def interact(self, item): 60 def interact(self, item):
60 pass 61 pass
61 62
63 def draw(self, surface):
64 pass
65
62 66
63 class Item(object): 67 class Item(object):
64 """Base class for inventory items.""" 68 """Base class for inventory items."""
65 69
66 def __init__(self): 70 def __init__(self):
67 pass 71 pass
72 # needs cursor
68 73