Permalink
Browse files

Merge pull request #8 from lczerner/more_cleanup

More cleanup
  • Loading branch information...
heinervdm committed Dec 9, 2012
2 parents 247a80f + b8ebb1c commit c7592a3af3095dd53b15f65b61b5ce81816fc34b
Showing with 771 additions and 5,041 deletions.
  1. +13 −20 MANIFEST.in
  2. +0 −3 monorail/ai.pyx
  3. +15 −17 monorail/control.py
  4. +6 −8 monorail/controlview.py
  5. +13 −14 monorail/event.py
  6. +1 −2 monorail/eventview.py
  7. +11 −12 monorail/frame.py
  8. +66 −67 monorail/hud.py
  9. +12 −13 monorail/koon/app.py
  10. +9 −10 monorail/koon/build.py
  11. +9 −10 monorail/koon/cfg.py
  12. +9 −9 monorail/koon/geo.py
  13. +13 −15 monorail/koon/gfx.py
  14. +39 −40 monorail/koon/gui.py
  15. +3 −4 monorail/koon/input.py
  16. +7 −8 monorail/koon/res.py
  17. +6 −7 monorail/koon/snd.py
  18. +8 −9 monorail/koon/tests/test_cfg.py
  19. +0 −1 monorail/koon/tests/test_geo.py
  20. +5 −6 monorail/koon/tests/test_gfx.py
  21. +33 −34 monorail/koon/tests/test_gui.py
  22. +6 −7 monorail/koon/tests/test_input.py
  23. +1 −2 monorail/koon/tests/test_res.py
  24. +1 −2 monorail/koon/tests/test_snd.py
  25. +0 −4,207 monorail/mac_ai/ai.c
  26. BIN monorail/mac_ai/ai.so
  27. +51 −52 monorail/menu.py
  28. +18 −18 monorail/monkey.py
  29. +39 −40 monorail/monorail.py
  30. +10 −11 monorail/pickups.py
  31. +21 −22 monorail/pickupsview.py
  32. +20 −21 monorail/player.py
  33. +12 −13 monorail/playerview.py
  34. +54 −55 monorail/scenarios.py
  35. +23 −24 monorail/settings.py
  36. +2 −5 monorail/setup.py
  37. +2 −0 monorail/setup_py2app.py
  38. +6 −7 monorail/sndman.py
  39. +27 −28 monorail/tests/test_ai.py
  40. +18 −19 monorail/tests/test_control.py
  41. +4 −5 monorail/tests/test_frame.py
  42. +2 −3 monorail/tests/test_geo.py
  43. +0 −1 monorail/tests/test_menu.py
  44. +2 −3 monorail/tests/test_pickups.py
  45. +2 −3 monorail/tests/test_pickupsview.py
  46. +7 −8 monorail/tests/test_player.py
  47. +2 −3 monorail/tests/test_playerview.py
  48. +4 −5 monorail/tests/test_scenarios.py
  49. +2 −3 monorail/tests/test_settings.py
  50. +22 −23 monorail/tests/test_tiles.py
  51. +46 −47 monorail/tests/test_world.py
  52. +47 −50 monorail/tiles.py
  53. +9 −10 monorail/tilesview.py
  54. +26 −27 monorail/world.py
  55. +3 −4 monorail/worldview.py
  56. +4 −4 setup.py
View
@@ -1,25 +1,17 @@
-include README README.md setup.py build.py LICENSE.txt MysticMine
+include README
+include README.md
+include setup.py
+include build.py
+include LICENSE.txt
+include MysticMine
+include Makefile
-include locales/gettext.sh locales/messages.pot locales/de_DE.po locales/en_US.po locales/ru_RU.po
+include data/800x600/edmunds.ttf
+data/800x600/font_default.fnt
+data/800x600/font_default.png
+data/800x600/resources.cfg
-include data/800x600/edmunds.ttf data/800x600/font_default.fnt data/800x600/font_default.png data/800x600/resources.cfg
-
-include monorail/fonts/freesansbold.ttf
-
-include monorail/__init__.py monorail/ai.pyx monorail/control.py monorail/controlview.py monorail/event.py
-include monorail/eventview.py monorail/frame.py monorail/hud.py monorail/menu.py monorail/monkey.py
-include monorail/monorail.py monorail/pickups.py monorail/pickupsview.py monorail/player.py
-include monorail/playerview.py monorail/profile.py monorail/scenarios.py monorail/settings.py
-include monorail/setup.py monorail/setup_py2app.py monorail/setup_py2exe.py monorail/sndman.py
-include monorail/tiles.py monorail/tilesview.py monorail/world.py monorail/worldview.py
-
-include monorail/koon/__init__.py monorail/koon/app.py monorail/koon/build.py monorail/koon/cfg.py monorail/koon/geo.py
-include monorail/koon/gfx.py monorail/koon/gui.py monorail/koon/input.py monorail/koon/res.py monorail/koon/snd.py
-
-include monorail/tests/__init__.py monorail/tests/test_ai.py monorail/tests/test_control.py monorail/tests/test_frame.py
-include monorail/tests/test_geo.py monorail/tests/test_menu.py monorail/tests/test_pickups.py monorail/tests/test_pickupsview.py
-include monorail/tests/test_player.py monorail/tests/test_playerview.py monorail/tests/test_scenarios.py
-include monorail/tests/test_settings.py monorail/tests/test_tiles.py monorail/tests/test_world.py
+recursive-include monorail *.py *.pyx *.lvl *.ttf
recursive-include data/800x600/gfx *
recursive-include data/800x600/levels *
@@ -28,3 +20,4 @@ recursive-include data/800x600/music *
recursive-include data/800x600/snd *
recursive-include assets *
+recursive-include locales *
View
@@ -1,7 +1,4 @@
-#!/usr/bin/env python
-
import copy
-
import tiles
import pickups
View
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
import random
from koon.input import Mouse
@@ -25,7 +23,7 @@ def game_tick( self, indev ):
# for debugging
if hasattr(self, "views"):
self.views[0].game_tick( indev )
-
+
# check each goldcar's keys
for controller in self.controllers:
controller.do_tick( indev )
@@ -38,7 +36,7 @@ def game_tick( self, indev ):
tile_x = (-mouse_y + (mouse_x+32)/2 - X_OFFSET/2 + Y_OFFSET) / 32
tile_y = (mouse_y + (mouse_x-32)/2 - X_OFFSET/2 - Y_OFFSET) / 32
-
+
tile = self.playfield.level.get_tile( tile_x, tile_y )
if tile is not None and tile.is_switch():
@@ -58,7 +56,7 @@ def game_tick( self, indev ):
if not had_it:
tile.switch_it()
- if self.contains_ai:
+ if self.contains_ai:
self._update_prediction_trees()
def add_controllers( self, controllers ):
@@ -79,7 +77,7 @@ def add_controllers( self, controllers ):
if not isinstance( controller, HumanController ):
self.contains_ai = True
-
+
i += 1
def _update_prediction_trees( self ):
@@ -103,7 +101,7 @@ def _update_prediction_trees( self ):
## if prediction_tree.root_node is not None:
## print prediction_tree.root_node._best_score,
i += 1
-
+
def _get_other_prediction_trees( self, car ):
"""Return all prediction trees that are not from car.
"""
@@ -115,7 +113,7 @@ def _get_other_prediction_trees( self, car ):
if car_it is not car:
trees.append( prediction_tree )
- i += 1
+ i += 1
return trees
@@ -128,15 +126,15 @@ def get_tree( self, car ):
return prediction_tree
i += 1
- return None
-
-class Controller:
+ return None
+
+class Controller:
"""Controller of a goldcar
public members:
- prediction_tree: the prediction tree of the goldcar
"""
-
+
def __init__( self, goldcar ):
"""goldcar can be None"""
self.goldcar = goldcar
@@ -176,11 +174,11 @@ def __init__( self, goldcar, iq = 1.0 ):
self.prev_switch = None
self.best_dir = None
self.iq = iq
-
+
def do_tick( self, indev ):
if self.goldcar.switch is not None:
switch_node = self.find_switch_node()
-
+
# find best direction for switch
if switch_node is not None:
best_childs = switch_node.get_best_childs()
@@ -190,7 +188,7 @@ def do_tick( self, indev ):
self.best_dir = None
else:
self.best_dir = None
-
+
self.handle_switching()
# TODO: improve algorithm here!
@@ -204,7 +202,7 @@ def find_switch_node( self ):
if len(best_childs) > 0:
node_it = best_childs[0]
## if node_it._best_score < 0:
-## print node_it._best_score
+## print node_it._best_score
else:
node_it = None
else:
@@ -224,4 +222,4 @@ def handle_switching( self ):
else: # Stupid move
if random.randint(0,32) == 0:
self.goldcar.keydown()
-
+
View
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
import pygame
from pygame.locals import *
@@ -25,17 +23,17 @@ def game_tick( self, indev ):
self.generation += 1
if indev.key.went_down( K_g ):
self.show_best_score = not self.show_best_score
-
+
def draw( self, frame ):
return
-
+
i = 0
for tree in self.model.prediction_trees:
car = self.model.playfield.goldcars[i]
if tree.root_node is not None:
- if i == 0:
+ if i == 0:
font = gfx.Font( None, 20, (255,0,0) )
else:
font = gfx.Font( None, 20, (0,255,0) )
@@ -48,15 +46,15 @@ def draw( self, frame ):
x = tile.pos.x * 32 + tile.pos.y * 32 + frame.X_OFFSET + 32
y = -tile.pos.x * 16 + tile.pos.y * 16 + frame.Y_OFFSET + 16 + (i * 10 - 10)
- if self.show_best_score:
+ if self.show_best_score:
score = ai_node.get_best_score()
else:
score = ai_node.get_score()
-
+
## font.draw( "%02.2f" % score, frame.surface, (x,y),
## gfx.Font.CENTER, gfx.Font.MIDDLE )
font.draw( str(score), frame.surface, (x,y),
gfx.Font.CENTER, gfx.Font.MIDDLE )
-
+
i += 1
View
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
import pygame
import random
@@ -29,10 +28,10 @@ def update( self ):
def draw( self, frame ):
pos = (self.pos[0] + frame.X_OFFSET,
self.pos[1] + frame.Y_OFFSET + self.life - 50)
-
+
self.font.draw( self.text, frame.surface, pos,
align=gfx.Font.CENTER, valign=gfx.Font.MIDDLE )
-
+
def is_alive( self ):
return self.life >= 0
@@ -58,27 +57,27 @@ def update():
resman.get("game.fuse_sound").is_playing():
resman.get("game.fuse_sound").stop()
Event.instance.play_fuse = False
-
+
@staticmethod
def dynamite_fuse():
Event.instance.play_fuse = True
@staticmethod
def dynamite_tick():
- resman.get("game.dynamite_tick_sound").play()
+ resman.get("game.dynamite_tick_sound").play()
@staticmethod
def coin_pickup( score, carpos ):
- resman.get("game.coin_sound").play()
+ resman.get("game.coin_sound").play()
Event.instance.points.append( Point( score, carpos.get_screen_position() ) )
-
+
@staticmethod
def flag_pickup( score, carpos ):
resman.get("game.collect_sound").play()
Event.instance.points.append( Point( score, carpos.get_screen_position() ) )
-
+
@staticmethod
def carhit():
resman.get("game.carhit_sound").play()
@@ -181,14 +180,14 @@ def game_tick( self ):
def is_dead( self ):
return self.progress > 1.0
-
+
def render( self, surface, x_offset, y_offset ):
if self.progress <= 1.0:
pos = self.pos
gold_sprite = resman.get("game.copper_sprite")
gold_sprite.draw( surface, pos + Vec2D(x_offset, y_offset) )
-
-
+
+
def __init__( self, pos, end_tiles ):
self.particles = []
for tile in end_tiles:
@@ -201,7 +200,7 @@ def __init__( self, pos, end_tiles ):
Event.explosion()
-
+
def game_tick( self ):
for particle in self.particles:
particle.game_tick()
@@ -216,14 +215,14 @@ def draw( self, frame ):
if self.animTimer is None:
self.animTimer = gfx.LoopAnimationTimer( 20, 0, 16 ) # real maxframe is in draw
self.animTimer.set_frame( frame.time_sec, 0 )
-
+
if self.sprite is not None:
self.sprite.nr = self.animTimer.get_frame( frame.time_sec )
self.sprite.draw( frame.surface, self.pos + Vec2D(frame.X_OFFSET, frame.Y_OFFSET) )
if self.sprite.nr >= 15:
self.sprite = None
-
+
def is_alive( self ):
return self.sprite is not None or len(self.particles > 0)
View
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
import pygame
from pygame.locals import *
@@ -14,7 +13,7 @@ class EventView:
def __init__( self, model ):
self.model = model
-
+
def draw( self, frame ):
for point in self.model.points:
point.draw( frame )
View
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
from world import *
from player import *
@@ -31,14 +30,14 @@ def __init__( self, surface, time_sec, interpol ):
def get_views( self, model ):
if hasattr( model, 'views' ) and model.views is not None:
return model.views
- else:
+ else:
if isinstance( model, Level):
views = [LevelView( model )]
elif isinstance( model, Playfield ):
views = [PlayfieldView( model )]
- elif isinstance( model, GoldCar ):
+ elif isinstance( model, GoldCar ):
views = [GoldCarView( model )]
-
+
elif isinstance( model, Torch ):
views = [TorchView( model )]
elif isinstance( model, Diamond ):
@@ -71,13 +70,13 @@ def get_views( self, model ):
views = [FlagView( model )]
elif isinstance( model, Leprechaun):
views = [LeprechaunView( model )]
-
+
elif isinstance( model, Enterance ):
- views = [EnteranceView( model ), EnteranceTopView( model )]
+ views = [EnteranceView( model ), EnteranceTopView( model )]
elif isinstance( model, RailGate ):
views = [RailGateView( model )]
elif isinstance( model, Tile ):
- views = [TileView( model )]
+ views = [TileView( model )]
elif isinstance( model, GroundControl ):
views = [GroundControlView( model )]
elif isinstance( model, Event ):
@@ -92,23 +91,23 @@ def get_views( self, model ):
def draw( self, model ):
if model is None: return
-
+
for view in self.get_views( model ):
view.draw( self )
- def draw_z( self, models ):
+ def draw_z( self, models ):
views = []
for model in models:
for view in self.get_views( model ):
views.append( view )
-
+
if hasattr(view, "submodels"):
for submodel in view.submodels:
for subview in self.get_views( submodel ):
views.append( subview )
views.sort( key = lambda v: v.z )
-
+
for view in views:
view.draw( self )
-
+
Oops, something went wrong.

0 comments on commit c7592a3

Please sign in to comment.