Permalink
Browse files

down from 152 roodi warnings to 14

  • Loading branch information...
1 parent e30111a commit 875d46523d614a9899730872fcfebf29c6c0bbeb @bgoodspeed committed Nov 12, 2010
View
@@ -32,36 +32,17 @@ def make_domain_data
end
def make_hook_and_event_bindings
- always_on_keymap = key_press_hooks( [:escape, :quit], [ :q, :quit],
- [ :c, :capture_ss], [ :d, :toggle_dialog_layer], [ :m, :toggle_menu], [ :p, :pause]
- )
-
- menu_killed_hooks = key_press_hooks( [ :i, :interact_with_facing],
- [ :space, :use_weapon], [ :b, :toggle_bg_music]
- )
-
+ always_on_keymap = key_press_hooks( [:escape, :quit], [ :q, :quit], [ :c, :capture_ss], [ :d, :toggle_dialog_layer], [ :m, :toggle_menu], [ :p, :pause] )
+ menu_killed_hooks = key_press_hooks( [ :i, :interact_with_facing], [ :space, :use_weapon], [ :b, :toggle_bg_music] )
menu_active_hooks = standard_keymap(:menu_left, :menu_down, :menu_right, :menu_up, :menu_enter, :menu_cancel)
battle_hooks = standard_keymap(:battle_left, :battle_down, :battle_right, :battle_up, :battle_enter, :battle_cancel)
-
-
- battle_layer_hooks = [
- event_hook(battle_layer, :tick, :update)
- ]
-
- player_hooks = [
- event_hook(player, :key_press, :key_pressed),
- event_hook(player, :key_release, :key_released),
- event_hook(player, :tick, :update)
- ]
-
- npc_hooks = npcs.collect {|npc|
- event_hook(npc, :tick, :update)
- }
+ battle_layer_hooks = [ event_hook(battle_layer, :tick, :update) ]
+ player_hooks = [ event_hook(player, :key_press, :key_pressed), event_hook(player, :key_release, :key_released), event_hook(player, :tick, :update) ]
+ npc_hooks = npcs.collect {|npc| event_hook(npc, :tick, :update) }
@event_handler = @trigger_factory.make_event_handler
@event_manager = @factory.make_event_manager
@event_system = @factory.make_event_system(self, always_on_keymap, menu_killed_hooks, menu_active_hooks, battle_hooks, battle_layer_hooks, player_hooks, npc_hooks)
-
end
def initialize(factory=GameInternalsFactory.new, trigger_factory = TriggerFactory.new)
@@ -5,7 +5,6 @@ class AnimatedSpriteHelper
def initialize(filename, position, surface_factory=SurfaceFactory.new)
@all_char_postures = surface_factory.load_surface(filename)
-
set_colorkey_from_corner(@all_char_postures)
@all_char_postures.alpha = 255
@@ -14,7 +13,6 @@ def initialize(filename, position, surface_factory=SurfaceFactory.new)
@avatar_x_dim = position.dimension.x
@avatar_y_dim = position.dimension.y
-
@image = surface_factory.make_surface([@avatar_x_dim, @avatar_y_dim])
@image.fill(@all_char_postures.colorkey)
@image.colorkey = @all_char_postures.colorkey
@@ -20,14 +20,14 @@ def missions
all_missions.select {|m| m.available? }
end
+ #XXX anything of type Milestone must be able to generate events
+ # so that we can check for new mission availability
+ # per dialog/city visitation/battle/stat upgrade seems reasonable times to
+ # fire the recalculation of the available missions
+ # on the other hand, checking every tick or every step taken implies
+ # scheduling & polling rather than event driven
+ # or the events have to run really fast?
def all_missions(game=@game)
- #XXX anything of type Milestone must be able to generate events
- # so that we can check for new mission availability
- # per dialog/city visitation/battle/stat upgrade seems reasonable times to
- # fire the recalculation of the available missions
- # on the other hand, checking every tick or every step taken implies
- # scheduling & polling rather than event driven
- # or the events have to run really fast?
[
Mission.new(:ten_upgrades, "Upgrade yourself",
[],
@@ -3,20 +3,13 @@
class ReloaderHelper
def replace(game, json_player)
#TODO I literally don't do anything right now.
-
-
# puts "player is at #{game.player.px} and #{game.player.py} at load time"
# uni = json_player.universe
# orig_uni = game.universe
# universe = Universe.new(uni.current_world_idx, uni.worlds, orig_uni.game_layers, orig_uni.sound_effects)
-#
-# puts "universe has current world: #{universe.current_world_idx}"
# universe.replace_world_data(orig_uni)
-#
# universe.reblit_backgrounds
-# puts "backgrounds rebuilt"
# posn = PositionedTileCoordinate.new(SdlCoordinate.new(json_player.px, json_player.py), SdlCoordinate.new(json_player.hero_x_dim, json_player.hero_y_dim))
-#
# player = Player.new(posn, universe, json_player.party, json_player.filename, game.screen.w/2, game.screen.h/2)
# #TODO update tile coords for player
# game.universe = universe
@@ -27,6 +20,5 @@ def replace(game, json_player)
# game.universe.menu_layer.toggle_activity
# game.rebuild_hud
# game.reset_menu_positions
-# puts "reloading should be done"
end
end
@@ -61,6 +61,13 @@ def blit_to(palette, target)
end
end
+ def blit_datum(palette, screen, px, py, xi, yi)
+ datum = palette[data_at(xi,yi)]
+ unless datum.nil?
+ datum.blit(screen, px,py, xi, yi)
+ end
+ end
+
def blit_foreground(palette, screen, px, py)
xoff = x_offset_for_world(px)
yoff = x_offset_for_world(py)
@@ -74,12 +81,7 @@ def blit_foreground(palette, screen, px, py)
starty.upto(endy) do |yi|
startx.upto(endx) do |xi|
-
- datum = palette[data_at(xi,yi)]
- unless datum.nil?
-
- datum.blit(screen, px,py, xi, yi)
- end
+ blit_datum(palette, screen, px, py, xi, yi)
end
end

0 comments on commit 875d465

Please sign in to comment.