Crosses
This commit is contained in:
parent
7ea7b56556
commit
cf80682890
@ -4,7 +4,7 @@ from kivy.uix.widget import Widget
|
|||||||
from kivy.core.window import Window
|
from kivy.core.window import Window
|
||||||
|
|
||||||
from point import Point
|
from point import Point
|
||||||
from polyomino import Square
|
from polyomino import Cross
|
||||||
from polyomino import Square_element
|
from polyomino import Square_element
|
||||||
|
|
||||||
from tools import remove_fromlist
|
from tools import remove_fromlist
|
||||||
@ -81,7 +81,7 @@ class Painter(Widget):
|
|||||||
|
|
||||||
# create new cross
|
# create new cross
|
||||||
if touch.button=="right":
|
if touch.button=="right":
|
||||||
new=Square(touch.x/Square_element.size,touch.y/Square_element.size)
|
new=Cross(touch.x/Square_element.size,touch.y/Square_element.size)
|
||||||
if not self.check_interaction_any(new,Point(0,0)):
|
if not self.check_interaction_any(new,Point(0,0)):
|
||||||
# add to list
|
# add to list
|
||||||
self.particles.append(new)
|
self.particles.append(new)
|
||||||
|
30
polyomino.py
30
polyomino.py
@ -68,6 +68,36 @@ class Square(Polyomino):
|
|||||||
def __init__(self,x,y,**kwargs):
|
def __init__(self,x,y,**kwargs):
|
||||||
super(Square,self).__init__(**kwargs,squares=[Square_element(x,y)])
|
super(Square,self).__init__(**kwargs,squares=[Square_element(x,y)])
|
||||||
|
|
||||||
|
# cross
|
||||||
|
class Cross(Polyomino):
|
||||||
|
def __init__(self,x,y,**kwargs):
|
||||||
|
super(Cross,self).__init__(**kwargs,squares=[\
|
||||||
|
Square_element(x,y),\
|
||||||
|
Square_element(x+1,y),\
|
||||||
|
Square_element(x-1,y),\
|
||||||
|
Square_element(x,y+1),\
|
||||||
|
Square_element(x,y-1)\
|
||||||
|
])
|
||||||
|
|
||||||
|
# redefine stroke to avoid lines between touching squares
|
||||||
|
def stroke(self):
|
||||||
|
Color(1,1,1)
|
||||||
|
Line(points=(
|
||||||
|
*((self.squares[0].pos.x-0.5)*Square_element.size,(self.squares[0].pos.y-0.5)*Square_element.size),
|
||||||
|
*((self.squares[0].pos.x-0.5)*Square_element.size,(self.squares[0].pos.y-1.5)*Square_element.size),
|
||||||
|
*((self.squares[0].pos.x+0.5)*Square_element.size,(self.squares[0].pos.y-1.5)*Square_element.size),
|
||||||
|
*((self.squares[0].pos.x+0.5)*Square_element.size,(self.squares[0].pos.y-0.5)*Square_element.size),
|
||||||
|
*((self.squares[0].pos.x+1.5)*Square_element.size,(self.squares[0].pos.y-0.5)*Square_element.size),
|
||||||
|
*((self.squares[0].pos.x+1.5)*Square_element.size,(self.squares[0].pos.y+0.5)*Square_element.size),
|
||||||
|
*((self.squares[0].pos.x+0.5)*Square_element.size,(self.squares[0].pos.y+0.5)*Square_element.size),
|
||||||
|
*((self.squares[0].pos.x+0.5)*Square_element.size,(self.squares[0].pos.y+1.5)*Square_element.size),
|
||||||
|
*((self.squares[0].pos.x-0.5)*Square_element.size,(self.squares[0].pos.y+1.5)*Square_element.size),
|
||||||
|
*((self.squares[0].pos.x-0.5)*Square_element.size,(self.squares[0].pos.y+0.5)*Square_element.size),
|
||||||
|
*((self.squares[0].pos.x-1.5)*Square_element.size,(self.squares[0].pos.y+0.5)*Square_element.size),
|
||||||
|
*((self.squares[0].pos.x-1.5)*Square_element.size,(self.squares[0].pos.y-0.5)*Square_element.size),
|
||||||
|
*((self.squares[0].pos.x-0.5)*Square_element.size,(self.squares[0].pos.y-0.5)*Square_element.size),
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# square building block of polyominos
|
# square building block of polyominos
|
||||||
|
Loading…
Reference in New Issue
Block a user