samples/04_physics_and_collisions/03_entities/app/main.rb
# Provides each enemy in enemies collection with rectangular border,
# as well as a label showing id and when they were created
Provides each enemy in enemies collection with rectangular border,
as well as a label showing id and when they were created
Provides each enemy in enemies collection with rectangular border as well as a label showing id and when they were created
def render args
  args.outputs.borders << args.state.enemies.map(&:rect)
  args.outputs.labels  << args.state.enemies.flat_map do |enemy|
    [
      [enemy.x + 4, enemy.y + 29, "id: #{enemy.entity_id}", -3, 0],
      [enemy.x + 4, enemy.y + 17, "created_at: #{enemy.created_at}", -3, 0] 
    ]
  end
  args.outputs.solids << args.state.bullets.map(&:rect)
end
def render args args . outputs . borders << args . state . enemies . map ( & :rect ) args . outputs . labels << args . state . enemies . flat_map do | enemy | [ [ enemy . x + 4 , enemy . y + 29 , "id: #{enemy.entity_id}" , - 3 , 0 ] , [ enemy . x + 4 , enemy . y + 17 , "created_at: #{enemy.created_at}" , - 3 , 0 ] ] end args . outputs . solids << args . state . bullets . map ( & :rect ) end
Provides each enemy in enemies collection with rectangular border,
as well as a label showing id and when they were created
Provides each enemy in enemies collection with rectangular border as well as a label showing id and when they were created
# When you're calling a method that takes no arguments, you can use this & syntax on map. # Numbers are being added to x and y in order to keep the text within the enemy's borders. # frame enemy was created # Outputs bullets in bullets collection as rectangular solids
args