Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created November 12, 2016 20:25
Show Gist options
  • Save anonymous/9c249b3b1729e2727b6c5bab54764ab4 to your computer and use it in GitHub Desktop.
Save anonymous/9c249b3b1729e2727b6c5bab54764ab4 to your computer and use it in GitHub Desktop.
Shoes.app title:"datbuoy", width: 280, height: 600 do
def draw_board(rect_x,rect_y,numbers_x,numbers_y,text_y, colour)
a_to_j = [*?A..?J]
battleship_board = []
for board_y in 0..9
battleship_board.push([])
for board_x in 0..9
battleship_board[board_y].push(0)
end
end
# to test board:
# battleship_board[1][2] = 1
for y in 0..9
for x in 0..9
if battleship_board[y][x] == 0
rect(top: rect_y, left: rect_x, radius:10)
fill colour
else
button(top: rect_y, left: rect_x, height: 27, width: 23)
end
rect_x += 23
end
grid_label_y = para (y + 1)
grid_label_y.style(top: numbers_y)
grid_label_x = para a_to_j[y]
grid_label_x.style(top: text_y, left: numbers_x, font: "trebuchet ms")
numbers_x += 23
numbers_y += 22.5
rect_x = 25
rect_y += 23
end
end
draw_board(25, 25, 26.5, 20, 3, red)
draw_board(25, 350, 26.5, 345, 329, blue)
line 0,290,280,290
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment