samples/99_genre_dev_tools/tile_editor_starting_point/app/main.rb
def search_lines (point, input_type)
    point.x += state.centerX - 630 # increments x and y
    point.y += state.centerY - 360
    findX = 0
    findY = 0
    increment = state.gridSize / state.lineQuantity # divides grid by number of separators

    state.gridX.map do # perform an action on every element of collection
      |x|
      # findX increments x by 10 if point.x is less than that sum and findX is currently 0
      findX = x + 10 if point.x < (x + 10) && findX == 0
    end

    state.gridY.map do
      |y|
      # findY is set to y if point.y is less than that value and findY is currently 0
      findY = y if point.y < (y) && findY == 0
    end
    # position of a box is denoted by bottom left corner, which is why the increment is being subtracted
    grid_box = [findX - (increment.ceil), findY - (increment.ceil), increment.ceil, increment.ceil,
                "sprites/image" + state.tileSelected.to_s + ".png"] # sets sprite definition

    if input_type == :click # if user clicks their mouse
      if state.filled_squares.include? grid_box # if grid box is already filled in
        state.filled_squares.delete grid_box # box is cleared and removed from filled_squares
      else
        state.filled_squares << grid_box # otherwise, box is filled in and added to filled_squares
      end
    elsif input_type == :drag # if user drags mouse
      unless state.filled_squares.include? grid_box # unless grid box dragged over is already filled in
        state.filled_squares << grid_box # box is filled in and added to filled_squares
      end
    end
  end
# Performs calculations on the gridX and gridY collections, and sets values.
# Sets the definition of a grid box, including the image that it is filled with.
Performs calculations on the gridX and gridY collections, and sets values.
Sets the definition of a grid box, including the image that it is filled with.
Performs calculations on the gridX and gridY collections and sets values . Sets the definition of a grid box including the image that it is filled with .
def search_lines (point, input_type)
    point.x += state.centerX - 630 
    point.y += state.centerY - 360
    findX = 0
    findY = 0
    increment = state.gridSize / state.lineQuantity 
    state.gridX.map do 
      |x|
      findX = x + 10 if point.x < (x + 10) && findX == 0
    end
    state.gridY.map do
      |y|
      findY = y if point.y < (y) && findY == 0
    end
    grid_box = [findX - (increment.ceil), findY - (increment.ceil), increment.ceil, increment.ceil,
                "sprites/image" + state.tileSelected.to_s + ".png"] 
    if input_type == :click 
      if state.filled_squares.include? grid_box 
        state.filled_squares.delete grid_box 
      else
        state.filled_squares << grid_box 
      end
    elsif input_type == :drag 
      unless state.filled_squares.include? grid_box 
        state.filled_squares << grid_box 
      end
    end
  end
def search_lines ( point , input_type ) point . x += state . centerX - 630 point . y += state . centerY - 360 findX = 0 findY = 0 increment = state . gridSize / state . lineQuantity state . gridX . map do | x | findX = x + 10 if point . x < ( x + 10 ) && findX == 0 end state . gridY . map do | y | findY = y if point . y < ( y ) && findY == 0 end grid_box = [ findX - ( increment . ceil ) , findY - ( increment . ceil ) , increment . ceil , increment . ceil , "sprites/image" + state . tileSelected . to_s + ".png" ] if input_type == :click if state . filled_squares . include? grid_box state . filled_squares . delete grid_box else state . filled_squares << grid_box end elsif input_type == :drag unless state . filled_squares . include? grid_box state . filled_squares << grid_box end end end
Performs calculations on the gridX and gridY collections, and sets values.
Performs calculations on the gridX and gridY collections and sets values .
# increments x and y # divides grid by number of separators # perform an action on every element of collection # findX increments x by 10 if point.x is less than that sum and findX is currently 0 # findY is set to y if point.y is less than that value and findY is currently 0 # position of a box is denoted by bottom left corner, which is why the increment is being subtracted # sets sprite definition # if user clicks their mouse # if grid box is already filled in # box is cleared and removed from filled_squares # otherwise, box is filled in and added to filled_squares # if user drags mouse # unless grid box dragged over is already filled in # box is filled in and added to filled_squares
point
input_type