Changeset 37
- Timestamp:
- 16/03/08 23:12:08 (10 months ago)
- Location:
- muckaround/freetower
- Files:
-
- 1 added
- 3 modified
-
source/game.py (added)
-
source/level.py (modified) (2 diffs)
-
source/people.py (modified) (2 diffs)
-
test.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
muckaround/freetower/source/level.py
r36 r37 39 39 SECTION_SIZE = 10 40 40 41 def __init__(self, levels, sections): 41 def __init__(self, game, levels, sections): 42 self.game = game 42 43 self.levels = levels 43 44 self.sections = sections … … 162 163 class LevelRenderable(Level): 163 164 164 def __init__(self, levels, sections, video):165 Level.__init__(self, levels, sections)166 self.video = video165 def __init__(self, game, levels, sections): 166 Level.__init__(self, game, levels, sections) 167 self.video = game.video 167 168 168 169 def render(self): -
muckaround/freetower/source/people.py
r36 r37 1 1 class Person(object): 2 2 3 def __init__(self, levelobj, level, section): 3 4 self.levelobj = levelobj 4 5 self.level = level 5 6 self.section = section 6 self.destination = None # the current target destination 7 8 self.target = None # the final destination 9 self.destination = None # the short term destination (pathfinding) 7 10 self.path = None # path saved for the destination 8 11 … … 11 14 # self.is_tired = False 12 15 16 self.state = None 17 18 def think(self): 19 if not self.state: 20 self.think_of_something() 21 22 def think_of_something(self): 23 pass 24 13 25 class NormalPerson(Person): 14 26 pass 27 15 28 16 29 class ApartmentOwner(Person): -
muckaround/freetower/test.py
r36 r37 9 9 from source.structures import * 10 10 from source.transports import * 11 from source.game import Game 11 12 12 13 def main(): 13 video = Video() 14 video.init() 15 level = LevelRenderable(video=video, levels=50, sections=100) 14 game = Game() 15 game.init_video() 16 game.level = LevelRenderable(game, levels=50, sections=100) 17 18 level = game.level 16 19 17 20 for a in xrange(40): … … 23 26 24 27 level.set_section(3, 10, FoodStore) 25 26 28 level.add_transport(Stairs, 0, 30, direction=1) 27 29 level.add_transport(Lift, 0, 20, height=6) … … 29 31 t = time.time() 30 32 frames = 0 31 while not video.window.has_exit: 33 while not game.video.window.has_exit: 34 game.think(1) 35 game.input() 36 game.render() 37 32 38 frames += 1 33 video.window.dispatch_events()34 video.window.clear()35 level.render()36 37 # meh = level.find_path(38 # TransportExit(None, level=0, section=0),39 # TransportExit(None, level=5, section=50),40 # maxcost=3041 # )42 # print '\n'.join([repr(b) for b in meh])43 44 x, y = video.window._mouse_x, video.window._mouse_y45 x = float(x) / Level.SECTION_SIZE46 y = float(y) / Level.LEVEL_SIZE47 48 glBegin(GL_LINES)49 glVertex2f(0, 0)50 glVertex2f(x, y)51 glEnd()52 53 video.flip()54 55 39 if frames % 100 == 0: 56 40 print frames / (time.time() - t)