Skip to content

Instantly share code, notes, and snippets.

@ashbb
Created February 7, 2012 14:48
Show Gist options
  • Select an option

  • Save ashbb/1760029 to your computer and use it in GitHub Desktop.

Select an option

Save ashbb/1760029 to your computer and use it in GitHub Desktop.
I got an email from Germany.
module Mod
def check_neighbour? a, b
return true if @circles.empty?
@circles.each{|c| return false if c.left/40 == a and c.top/40 == b}
@circles.each do |c|
x, y = c.left/40, c.top/40
return true if (x-1 == a and y == b) or (x == a and y-1 == b) or (x+1 == a and y == b) or (x == a and y+1 == b)
end
return false
end
end
Shoes.app :width => 640, :height => 400, :resizable => false do
extend Mod
background aliceblue
# Spielfeld 8 x 8, Rechtecke
@board = Array.new(8) do |x|
Array.new(8) do |y|
rect(x*40, y*40, 40, :fill => burlywood)
end
end
@move = white
@circles = []
click do |c, x, y|
a = x/40
b = y/40
if a <= 7 and b <= 7 and check_neighbour?(a, b)
@circles << oval(a*40, b*40, 40, :fill =>@move)
color = send COLORS.keys[rand(COLORS.keys.size)]
@circles.each do |c|
c.style :fill => color
end if @circles.size > 1
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment