samples/04_physics_and_collisions/02_moving_objects/app/main.rb
# sets default values and creates empty collections
# initialization only happens in the first frame
sets default values and creates empty collections
initialization only happens in the first frame
sets default values and creates empty collections initialization only happens in the first frame
def defaults args
  fiddle args
  args.state.enemy.hammers ||= []
  args.state.enemy.hammer_queue ||= []
  args.state.tick_count = args.state.tick_count
  args.state.bridge_top = 128
  args.state.player.x  ||= 0                        
  args.state.player.y  ||= args.state.bridge_top
  args.state.player.w  ||= 64
  args.state.player.h  ||= 64
  args.state.player.dy ||= 0
  args.state.player.dx ||= 0
  args.state.enemy.x   ||= 800                      
  args.state.enemy.y   ||= 0
  args.state.enemy.w   ||= 128
  args.state.enemy.h   ||= 128
  args.state.enemy.dy  ||= 0
  args.state.enemy.dx  ||= 0
  args.state.game_over_at ||= 0
end
def defaults args fiddle args args . state . enemy . hammers ||= [ ] args . state . enemy . hammer_queue ||= [ ] args . state . tick_count = args . state . tick_count args . state . bridge_top = 128 args . state . player . x ||= 0 args . state . player . y ||= args . state . bridge_top args . state . player . w ||= 64 args . state . player . h ||= 64 args . state . player . dy ||= 0 args . state . player . dx ||= 0 args . state . enemy . x ||= 800 args . state . enemy . y ||= 0 args . state . enemy . w ||= 128 args . state . enemy . h ||= 128 args . state . enemy . dy ||= 0 args . state . enemy . dx ||= 0 args . state . game_over_at ||= 0 end
sets default values and creates empty collections
initialization only happens in the first frame
sets default values and creates empty collections initialization only happens in the first frame
# initializes player's properties # initializes enemy's properties
args