1. Adam Gardner
  2. operationlambda

Commits

philomory  committed 513c2be

Fixed issue 3

  • Participants
  • Parent commits 9a5a82c
  • Branches default

Comments (0)

Files changed (4)

File app/Game.rb

View file
     end
 
     def update_lasers
-      @map.switch_state = {:red => false, :blue => false, :purple => false}
+      @map.switch_state = {:red => 0, :blue => 0, :purple => 0}
       @map.lasers.each {|laser| laser.fireLaser}
       if (player_spot = @map[@player.x,@player.y]).lasered?
         color = (player_spot.laserbeams.values - [:none])[0]

File app/GameplayMap.rb

View file
       @crumbling = []
       @laser_state = {:red => true, :blue => true, :purple => true} #true is on, false is off.
       @gates = []
-      @switch_state = {:red => false, :blue => false, :purple => false}
+      @switch_state = {:red => 0, :blue => 0, :purple => 0}
       @time = level_hash[:time]
       #self.each_with_coords do |,x,y| # TODO: Abstract away Grid class and use it more widely.
       #  self[x,y] = KeyToThingHash[key].call(self,x,y)

File app/Things/Frame.rb

View file
       end #def initialize
       
       def updateState
-        @state = !@map.switch_state[@color]
+        @state = (@map.switch_state[@color] == 0)
         dest = nil
         if @edge == :north
           dest = self.south

File app/Things/Switch.rb

View file
             
       def laserGoingDirection_ofColor(direction,color)
         if SwitchAllows[@orientation].include?(direction)
-          SwitchAllows[@orientation].each {|dir| @laserbeams[dir] = color}
-          @map.switch_state[@color] = (color == @color)
+          # FIXME: Bug, does not react appropriately to two lasers of
+          # different colors coming in at once!
+          final_color = beam_composite(color,@laserbeams[direction])
+          @map.switch_state[@color] -= 1 if @laserbeams[direction] == @color
+          @map.switch_state[@color] += 1 if final_color == @color
+          SwitchAllows[@orientation].each {|dir| @laserbeams[dir] = final_color}
           self.send(direction).laserGoingDirection_ofColor(direction,color)
         end
       end #def laserGoingDirection_ofColor