samples/05_mouse/02_mouse_move/app/main.rb
def calc_move_zombies
    state.zombies.each do |z| # for each zombie in the collection
      z.y = z.y.towards(360, 0.1) # move the zombie towards the center (640, 360) at a rate of 0.1
      z.x = z.x.towards(640, 0.1) # change 0.1 to 1.1 and see how much faster the zombies move to the center
    end
    state.zombies = state.zombies.reject { |z| z.y == 360 && z.x == 640 } # remove zombies that are in center
  end
# Moves all zombies towards the center of the screen.
# All zombies that reach the center (640, 360) are rejected from the zombies collection and disappear.
Moves all zombies towards the center of the screen.
All zombies that reach the center (640, 360) are rejected from the zombies collection and disappear.
Moves all zombies towards the center of the screen . All zombies that reach the center ( 640 360 ) are rejected from the zombies collection and disappear .
def calc_move_zombies
    state.zombies.each do |z| 
      z.y = z.y.towards(360, 0.1) 
      z.x = z.x.towards(640, 0.1) 
    end
    state.zombies = state.zombies.reject { |z| z.y == 360 && z.x == 640 } 
  end
def calc_move_zombies state . zombies . each do | z | z . y = z . y . towards ( 360 , 0.1 ) z . x = z . x . towards ( 640 , 0.1 ) end state . zombies = state . zombies . reject { | z | z . y == 360 && z . x == 640 } end
Moves all zombies towards the center of the screen.
Moves all zombies towards the center of the screen .
# for each zombie in the collection # move the zombie towards the center (640, 360) at a rate of 0.1 # change 0.1 to 1.1 and see how much faster the zombies move to the center # remove zombies that are in center