samples/04_physics_and_collisions/04_box_collision/app/main.rb
def render

    # Sets a black background on the screen (Comment this line out and the background will become white.)
    # Also note that black is the default color for when no color is assigned.
    outputs.solids << grid.rect

    # The position, size, and color (white) are set for borders given to the world collection.
    # Try changing the color by assigning different numbers (between 0 and 255) to the last three parameters.
    outputs.borders << state.world.map do |x, y|
      [x * state.tile_size,
       y * state.tile_size,
       state.tile_size,
       state.tile_size, 255, 255, 255]
    end

    # The top, bottom, and sides of the borders for collision_rects are different colors.
    outputs.borders << state.world_collision_rects.map do |e|
      [
        [e[:top],                             0, 170,   0], # top is a shade of green
        [e[:bottom],                          0, 100, 170], # bottom is a shade of greenish-blue
        [e[:left_right],                    170,   0,   0], # left and right are a shade of red
      ]
    end

    # Sets the position, size, and color (a shade of green) of the borders of only the player's
    # box and outputs it. If you change the 180 to 0, the player's box will be black and you
    # won't be able to see it (because it will match the black background).
    outputs.borders << [state.x,
                        state.y,
                        state.tile_size,
                        state.tile_size,  0, 180, 0]
  end
# Outputs solids and borders of different colors for the world and collision_rects collections.
Outputs solids and borders of different colors for the world and collision_rects collections.
Outputs solids and borders of different colors for the world and collision_rects collections .
def render
    outputs.solids << grid.rect
    outputs.borders << state.world.map do |x, y|
      [x * state.tile_size,
       y * state.tile_size,
       state.tile_size,
       state.tile_size, 255, 255, 255]
    end
    outputs.borders << state.world_collision_rects.map do |e|
      [
        [e[:top],                             0, 170,   0], 
        [e[:bottom],                          0, 100, 170], 
        [e[:left_right],                    170,   0,   0], 
      ]
    end
    outputs.borders << [state.x,
                        state.y,
                        state.tile_size,
                        state.tile_size,  0, 180, 0]
  end
def render outputs . solids << grid . rect outputs . borders << state . world . map do | x , y | [ x * state . tile_size , y * state . tile_size , state . tile_size , state . tile_size , 255 , 255 , 255 ] end outputs . borders << state . world_collision_rects . map do | e | [ [ e [ :top ] , 0 , 170 , 0 ] , [ e [ :bottom ] , 0 , 100 , 170 ] , [ e [ :left_right ] , 170 , 0 , 0 ] , ] end outputs . borders << [ state . x , state . y , state . tile_size , state . tile_size , 0 , 180 , 0 ] end
Outputs solids and borders of different colors for the world and collision_rects collections.
Outputs solids and borders of different colors for the world and collision_rects collections .
# Sets a black background on the screen (Comment this line out and the background will become white.) # Also note that black is the default color for when no color is assigned. # The position, size, and color (white) are set for borders given to the world collection. # Try changing the color by assigning different numbers (between 0 and 255) to the last three parameters. # The top, bottom, and sides of the borders for collision_rects are different colors. # top is a shade of green # bottom is a shade of greenish-blue # left and right are a shade of red # Sets the position, size, and color (a shade of green) of the borders of only the player's # box and outputs it. If you change the 180 to 0, the player's box will be black and you # won't be able to see it (because it will match the black background).