Forum Archive

Frame for tetris

Karina

Hello everyone
I'm new to pythonista and programming, trying to write tetris
For now i have buttons⬅️⬆️⬇️➡️ and a frame. But yhe frame is to much in the corner and i can't move it
Here's the code

import arrows
from scene import *

colors = ['purple', 'red', 'blue', 'orange', 'yellow', 'green',
'lightblue']
sw = get_screen_size()[0]
sh = get_screen_size()[1]

class Board(ShapeNode):
     def __init__(self, parent=None, *args, **kwargs):
          self.rect_w = sw/2
          self.rect_h = sh-100
          path = ui.Path.rect(0, 0, self.rect_w, self.rect_h)
          path.line_width = 10
          super().__init__(path,
                           fill_color='white',
                           stroke_color='purple',
                           parent=parent,
                           *args, **kwargs)

     def draw_lines(self):
          stroke(0, 0, 0)
          stroke_weight(2)
          line(l*30+50, self.rect_h+50, l*30+50, 50)

class Game(Scene):
     def setup(self):
          self.background_color = 'white'
          Board(parent=self)
          self.add_buttons()

     def add_buttons(self):
          ars = arrows.Main()
          self.present_modal_scene(ars)

if __name__ == '__main__':
     run(Game())

In the line path = ui.Path.rect(0, 0, self.rect_w, self.rect_h) if i change first two args from zero, nothing changes. So what they do? And how i can change pos of the frame?

cvp

@Karina try this

          Board(position=(sw/2,sh/2), parent=self) 
Karina

@cvp 👍 and what 2 first args do in ui.Path.rect()?
Thanks for help🤗

cvp

@Karina I think that as used here in ShapeNode path, x and y are not used, only width and height. If you draw an ui.path in general, x and y set path position, but not here.

Karina

@cvp Thank you now the frame where it needs to be.
Then I need to draw vertical lines in the frame, but it doesn’t work. And if change z_position - nothing.

import arrows
from scene import *


colors = ['purple', 'red', 'blue', 'orange', 'yellow', 'green', 'lightblue']
sw = get_screen_size()[0]
sh = get_screen_size()[1]


class Board(ShapeNode):
    def __init__(self, parent=None, *args, **kwargs):
        self.rect_w = sw/2
        self.rect_h = sh-100
        path = ui.Path.rect(0, 0, self.rect_w, self.rect_h)
        path.line_width = 10
        super().__init__(path, 
                         z_position=-1,
                         fill_color='white',
                         stroke_color='purple',
                         parent=parent,
                         *args, **kwargs)



    def draw_lines(self):
        fill(0, 0, 0)
        stroke_weight(2)
        rect(sw-200, sh/2, 100, 100)
        for l in range(int(self.rect_w/30)):
            line_path = ui.Path.rect(sw/3 - self.rect_w/2 + 30*l, sh/2 + self.rect_h/2, 
                                     self.rect_w, self.rect_h)




class Game(Scene):
    def setup(self):
        self.background_color = 'white'
        self.board = Board(position=(sw/3, sh/2), parent=self)
        self.add_buttons()



    def draw(self):
        self.board.draw_lines()


    def add_buttons(self):
        ars = arrows.Main()
        self.present_modal_scene(ars)



if __name__ == '__main__':  
    run(Game()) 

But beyond the purple frame I can draw😐

cvp

@Karina sincerely, not sure this is what you want. If not, sorry and forget quickly this post

class Board(ShapeNode):
    def __init__(self, parent=None, *args, **kwargs):
        self.rect_w = sw/2
        self.rect_h = sh-100
        path = ui.Path.rect(0, 0, self.rect_w, self.rect_h)
        path.line_width = 2
        d = int(self.rect_w/30)
        for l in range(int(self.rect_w/d)):
            x = l*d
            path.move_to(x,0)
            path.line_to(x,self.rect_h) 
.
.
.

Comment temporarily your draw_lines process, to watch the result

Karina

@cvp It’s nearly what I need, I just want it in grey color. But when I put it into the draw_lines and not Board’s init, it doesn’t work. And I don’t want to overload init

cvp

@Karina it does not work because you pass the path to super.init and thus when you draw the lines, the path is already built

This is not really an overload

cvp

@Karina please read some @jonB explanations in this topic

ccc

@Karina said:

colors = ['purple', 'red', 'blue', 'orange', 'yellow', 'green', 'lightblue']
sw = get_screen_size()[0]
sh = get_screen_size()[1]

colors = ‘purple red blue orange yellow green lightblue'.split()
sw, sh = get_screen_size()

Mosa14177

The new version of

Karina

@ccc with sw sh okay, but what this colors = ‘purple red blue orange yellow green lightblue'.split() gives?

cvp

@ccc said:

colors = ‘purple red blue orange yellow green lightblue'.split()

@Karina Try and print colors, you will see

['purple', 'red', 'blue', 'orange', 'yellow', 'green', 'lightblue'] 

Thus what you want 😀

mikael

@Karina, just to be clear, there is nothing wrong with colors = ['purple', 'red', 'blue', 'orange', 'yellow', 'green', 'lightblue'] – for all-string arrays of this size, the str.split() version may just be more convenient to type.

Karina

@ccc @cvp @mikael I got it with the colors, but to me it’s the same amount of writing
And what means the error ‘ ‘ object has no attr _suspend_updates? When it appears?

cvp

@Karina said:

same amount of writing

Not really, with @ccc advice, you don't need to type quotes and comma's

ccc

object has no attr _suspend_updates

https://docs.python.org/3/library/functions.html are cool things to study as you learn Python. One of those is dir(object) which lists all the variables and methods of object. The message above means that dir(object) does not contain _suspend_updates but some code is assuming that it does. Practice a lot with dir(object) because it will help you to anticipate bugs.

mikael

@Karina, _suspend_updates is new to me, but it sounds like it is a scene-internal attribute. In addition to the detective work with dir as @ccc suggested, it is a good idea to look at/share the full traceback.

Karina

@ccc @mikael I thought maybe you have met it then I’ll know what to do. And in google I also didn’t found about this error.
And if I see in dir that there is no _suspend_updates how it will help me? I just don’t understand what to do to avoid this bug

ccc
  1. Give us some code that generates this error --and/or--
  2. Give us the full multiline error message (stack trace) so we can understand the context of the error.

We do not even know the datatype of object.

cvp

@Karina said:

_suspend_updates

Karina

Here's the code

from scene import *

sw, sh = get_screen_size()
rect_w = sw/3
rect_h = sh-100

class Board(ShapeNode):
     def __init__(self, stroke_color, line_width, parent, *args, **kwargs):

          self.stroke_color = stroke_color
          path=ui.Path.rect(0, 0, rect_w, rect_h)
          path.line_width = line_width
          self.parent = parent

super.__init__(path,
                         fill_color='white',
                         stroke_color=self.stroke_color,
                         parent=parent,
                        *args, **kwargs)


class Game(Scene):
     def setup(self):
          self.background_color = 'white'
          grey_rect = Board(stroke_color='grey', line_width=2, parent=self)
          rect.line_width = 10
          board = Board(position=(sw/2, sh/2), stroke_color='purple', path=rect, parent=self)


run(Game())

The idea is to create a rect in grey color line_width 2, and draw with it grey lines. Then draw above a purple rect above. I would draw that on paper, but i don't know how to add photos here
And the error - TypeError, 'Board' object has no attribute '_suspend_updates'

cvp

@Karina some small errors:
- super without parenthesis
- rect.line_width but rect is not yet defined
- mix of positional and keyword parameters

cvp

@Karina not yet fully solved but this (incomplete) script works


from scene import *

sw, sh = get_screen_size()
rect_w = sw/3
rect_h = sh-100

class Board(ShapeNode):
     def __init__(self, stroke_color='grey', line_width=1, parent=None, *args, **kwargs):
          #self.stroke_color = stroke_color
          path=ui.Path.rect(0, 0, rect_w, rect_h)
          path.line_width = line_width
          #self.parent = parent
          super().__init__(path,
                         fill_color='white',
                         stroke_color=stroke_color,
                         parent=parent,
                        *args, **kwargs)


class Game(Scene):
     def setup(self):
          self.background_color = 'white'
          grey_rect = Board(stroke_color='grey', line_width=2, parent=self)
          #rect.line_width = 10
          board = Board(stroke_color='purple', line_width=10, parent=self, position=(sw/2, sh/2))


run(Game()) 
Karina

@cvp what do you mean super without parenthesis?
About rect - I tried different ways to initiate board and forgot to delete rect.line_width

cvp

@Karina you wrote

super.__init__ 

instead of

super().__init__ 
Karina

@cvp what did you change that it works now?

Karina

For now it’s like this

from scene import *
import arrows

sw, sh = get_screen_size()
rect_w = sw/3
rect_h = sh-100

class Board(ShapeNode):
    def __init__(self, stroke_color='grey', line_width=1, parent=None, *args, **kwargs):
            path = ui.Path.rect(0, 0, rect_w, rect_h)
            path.line_width = line_width
            super().__init__(path,
                             fill_color='white',
                             stroke_color=stroke_color,
                             parent=parent,
                             *args, **kwargs)

            if stroke_color == 'grey':
                print(stroke_color)
                d = int(rect_w/30)
                for l in range(int(rect_w/d)):
                    x = l*d
                    path.move_to(x, 0)
                    path.line_to(x, rect_h)


class Game(Scene):
    def setup(self):
        self.background_color = 'white'
        grey_rect = Board(line_width=2, parent=self, position=(sw/2, sh/2))
        board = Board(stroke_color='purple', line_width=10, parent=self, position=(sw/3, sh/2))
        self.add_buttons()

    def add_buttons(self):
        ars = arrows.Main()
        self.present_modal_scene(ars)


run(Game())  

I use another pos in grey_rect to see that both are drawn, it shouldn’t be in the end like that
But here there’s no vertical grey lines, though they in init. And it prints ‘grey’, so he gets in that for

cvp

@Karina said:

what did you change that it works now?

Check the differences in positional/keyword parameters in

def __init__(...
cvp

@Karina said:

But here there’s no vertical grey lines, though they in init.

Put the draw lines before the super().init....

            if stroke_color == 'grey':
                print(stroke_color)
                d = int(rect_w/30)
                for l in range(int(rect_w/d)):
                    x = l*d
                    path.move_to(x, 0)
                    path.line_to(x, rect_h)

            super().__init__(path,
                             fill_color='white',
                             stroke_color=stroke_color,
                             parent=parent,
                             *args, **kwargs) 

cvp

@Karina 😥 and a small correction

        #grey_rect = Board(line_width=2, parent=self, position=(sw/2, sh/2))
        board = Board(stroke_color='purple', line_width=10, parent=self, position=(sw/3, sh/2))
        grey_rect = Board(line_width=2, parent=self, position=(sw/3, sh/2)) 

Karina

@cvp that correction I can do 😅
It was at the beginning before super, but somehow didn’t work. So I put after. And what changes if it’s after super?

Karina

@cvp By the way do you know how to allow multi_touch? This for another thing that is nearly ready

cvp

@Karina said:

And what changes if it’s after super?

If you do "after super().init..", you already have passed the path to node creation and all lines are added to the object path but not to the path of the node it-self

cvp

@Karina said:

how to allow multi_touch?

A "must have" of @mikael : gestures

mikael

@Karina, is this recent thread relevant to your multi-touch question?

Karina

@mikael yes, I want to do smth like that. I’ll also look in github, but I didn’t use it before

Karina

@cvp @mikael sorry, I have another problem. I still can’t writing smth by myself🙂

I tried here to add a block on the board, but it doesn’t show it. But prints the position

```
from scene import *
import random
import arrows

sw, sh = get_screen_size()
rect_w = sw/3 #343.33
rect_h = sh-100 #668
side = int(rect_w/10)
colors = ['red']

class Board(ShapeNode):
def init(self, stroke_color='lightgrey', line_width=1, parent=None, args, *kwargs):
path = ui.Path.rect(0, 0, rect_w, rect_h)
path.line_width = line_width

        if stroke_color == 'lightgrey':
            d = int(rect_w/10)
            for l in range(int(rect_w/d)):
                x = l*d
                path.move_to(x, 0)
                path.line_to(x, rect_h)

        super().__init__(path,
                         fill_color='white',
                         stroke_color=stroke_color,
                         parent=parent,
                         *args, **kwargs)

class Game(Scene):
def setup(self):
self.background_color = 'white'
grey_rect = Board(line_width=2, parent=self, position=(sw/3, sh/2), z_position=0)
self.board = Board(stroke_color='purple', line_width=15, parent=self, position=(sw/3, sh/2), z_position=-1)
self.add_buttons()
self.add_figure()

def add_buttons(self):
    ars = arrows.Main()
    self.present_modal_scene(ars)

def add_figure(self):
    x = random.choice(range(10)) * side
    y = rect_h
    block = SpriteNode('pzl:Yellow7', (x, y), z_position=1, size=Size(side, side), parent=self.board)
    print(block.position)

run(Game()) ```

cvp

@Karina try the gray_rect as parent for yours blocks because it is above the board

        self.grey_rect = Board(line_width=2, parent=self, position=(sw/3, sh/2), z_position=0) 

and don't forget child position is versus the center of the parent node

    def add_figure(self):
        r = random.choice(range(10)) 
        x = r * side - rect_w/2 + side/2
        y = rect_h/2 - side/2
        block = SpriteNode('pzl:Yellow7', position=(x, y), size=Size(side, side), parent=self.grey_rect)

        #print(block.position)

cvp

@Karina Here, if you let self.board as parent and use r = 10, you can see that your block is partially hidden by the grid

        r = 10
        x = r * side - rect_w/2 + side/2
        y = rect_h/2 - side/2
        block = SpriteNode('pzl:Yellow7', position=(x, y), size=Size(side, side), parent=self.board)#self.grey_rect)

Karina

@cvp so the center is (0, 0)?

cvp

@Karina said:

so the center is (0, 0)?

Yes

cvp

@Karina read also the doc about anchor_point

Karina

@cvp did so that the block moves down, but for ⬅️➡️ my touch_began doesn’t work. I did this

def touch_began(self, touch):
        print('touch_began') 

And nothing in the console

cvp

@Karina where did you insert your touch_began? I put it in the game class and print is ok
class Game(Scene): def touch_began(self, touch): print('touch_began') def setup(self): . . .

cvp

@Karina I want to add that, sincerely, I don't have any experience in scene module. I always have to try/test before that I can answer something. By example, for position, I've tried some values before to be able to answer something intelligent 😇

Karina

@cvp it’s in the game class that inherited scene. And update in the class he sees

Karina
from scene import *
import random
import arrows

sw, sh = get_screen_size()
rect_w = sw/3  #343.33
rect_h = 612 #668
side = int(rect_w/10)
colors = ['red']


class Board(ShapeNode):
    def __init__(self, stroke_color='lightgrey', line_width=1, parent=None, *args, **kwargs):
            path = ui.Path.rect(0, 0, rect_w, rect_h)
            path.line_width = line_width

            if stroke_color == 'lightgrey':
                d = int(rect_w/10)
                for l in range(int(rect_w/d)):
                    x = l*d
                    path.move_to(x, 0)
                    path.line_to(x, rect_h)

            super().__init__(path,
                             fill_color='white',
                             stroke_color=stroke_color,
                             parent=parent,
                             *args, **kwargs)



class Game(Scene):
    def setup(self):
        self.background_color = 'white'
        self.grey_rect = Board(line_width=2, parent=self, position=(sw/3, sh/2), z_position=0)
        self.board = Board(stroke_color='purple', line_width=15, parent=self, position=(sw/3, sh/2),    z_position=-1)

        self.seconds = 0
        self.figures = {}
        self.add_buttons()
        self.add_figure()


    def update(self):
        self.seconds += self.dt
        if self.seconds > 0.5:
            for f in self.figures:
                self.figures[f][1] -= side/2
                f.position = self.figures[f]
                self.seconds = 0
                if f.position.y == - rect_h/2 + side/2:
                    self.add_figure()
                    self.figures.pop(f)


    def touch_began(self, touch):
        print('touch_began')


    def add_buttons(self):
        ars = arrows.Main()
        self.present_modal_scene(ars)


    def add_figure(self):
        x = random.choice(range(10)) * side - rect_w/2 + side/2
        y = rect_h/2 - side/2
        block = SpriteNode('pzl:Yellow7', (x, y), z_position=1, size=Size(side, side), parent=self.grey_rect)
        self.figures[block] = [x, y]


run(Game())  

Maybe you’ll check if it works?

Karina

You’re talking about that position in the beginnig, when I couldn’t move the purple rect from the corner?)

cvp

@Karina said:

Maybe you’ll check if it works?

I don't have the arrows module thus no button, but if I touch anywhere in game, it prints touch_began

Karina

And if with arrows? Maybe it looks on that touch_began

from scene import *
import sound


def sw(): return get_screen_size()[0]
def sh(): return get_screen_size()[1]
def bw(): return 100
def bh(): return 100

right = left = down = up = None

icons = {
         'iob:arrow_down_b_256' : (sw()/4*3, 60),
         'iob:arrow_up_b_256' : (sw()/4*3, bh() + 60),
         'iob:arrow_left_b_256' : (sw()/4*3 - 95, bh()),
         'iob:arrow_right_b_256' : (sw()/4*3 + 95, bh())
          }


class Arrow(ShapeNode):
    def __init__(self,
                 picture,
                 path=None,
                 size=Size(120, 120),
                 corner_radius=8,
                 border_size=20,
                 borderColor='#3f0917',
                 position=(0,0),
                 parent=None,
                 *args, **kwargs):

                    #for border
                    self.picture = picture
                    self.corner_radius = corner_radius
                    self.border_size = border_size
                    self.borderColor = borderColor

                    self.position = position
                    self.size = size

                    #for super()
                    self.x, self.y = position
                    self.w, self.h = size

                    super().__init__(fill_color='white',
                                    path=ui.Path.rounded_rect(self.x, 
                                                               self.y,
                                                               self.w/1.5, 
                                                               self.h/1.5,
                                                               self.corner_radius),
                                    stroke_color=borderColor,
                                    parent=parent,
                                    *args, **kwargs)

                    self._setup(self.picture)

    def _setup(self, pict):
        if self.picture:
            arrow = SpriteNode(self.picture,
                               position=Point(0, 0), 
                               size=(100, 100),
                               parent=self)



class Main(Scene):                               
    def setup(self):
        fill_color = self.background_color
        self.background_color = 'white'
        self.arrows = [Arrow(i, position=icons[i], parent=self) for i in icons] 


    def touch_began(self, touch):
        tapped = True
        for arw in self.arrows:
            if touch.location in arw.frame:
                sound.play_effect('rpg:Chop')
                arw.fill_color = '#969696'
                if 'right' in arw.picture:
                    global right
                    right = True


    def touch_ended(self, touch):
        for arw in self.arrows:
            if arw.fill_color == '#969696':
                arw.fill_color = 'white'
                right = left = down = up = None



if __name__ == '__main__':              
    run(Main(), PORTRAIT) 
cvp

@Karina sorry, not at home, I’ll try later

cvp

@Karina doc says for your

        ars = arrows.Main()
        self.present_modal_scene(ars) ```

Doc says "Scene.present_modal_scene(other_scene)
Present another scene on top of this one. This can be useful for overlay menus etc.
While the scene is being presented, it receives all touch events."

cvp

@Karina please try this

from scene import *
import random
from  arrows import *

sw, sh = get_screen_size()
rect_w = sw/3  #343.33
rect_h = 612 #668
side = int(rect_w/10)
colors = ['red']

bw = 100
bh = 100

right = left = down = up = None

icons = {
         'iob:arrow_down_b_256' : (sw/4*3, 60),
         'iob:arrow_up_b_256' : (sw/4*3, bh + 60),
         'iob:arrow_left_b_256' : (sw/4*3 - 95, bh),
         'iob:arrow_right_b_256' : (sw/4*3 + 95, bh)
          }


class Board(ShapeNode):
    def __init__(self, stroke_color='lightgrey', line_width=1, parent=None, *args, **kwargs):
            path = ui.Path.rect(0, 0, rect_w, rect_h)
            path.line_width = line_width

            if stroke_color == 'lightgrey':
                d = int(rect_w/10)
                for l in range(int(rect_w/d)):
                    x = l*d
                    path.move_to(x, 0)
                    path.line_to(x, rect_h)

            super().__init__(path,
                             fill_color='white',
                             stroke_color=stroke_color,
                             parent=parent,
                             *args, **kwargs)



class Game(Scene):
    def setup(self):
        self.background_color = 'white'
        self.grey_rect = Board(line_width=2, parent=self, position=(sw/3, sh/2), z_position=0)
        self.board = Board(stroke_color='purple', line_width=15, parent=self, position=(sw/3, sh/2),    z_position=-1)

        self.seconds = 0
        self.figures = {}
        self.add_buttons()
        self.add_figure()


    def update(self):
        self.seconds += self.dt
        if self.seconds > 0.5:
            for f in self.figures:
                self.figures[f][1] -= side/2
                f.position = self.figures[f]
                self.seconds = 0
                if f.position.y == - rect_h/2 + side/2:
                    self.add_figure()
                    self.figures.pop(f)



    def touch_began(self, touch):
        tapped = True
        for arw in self.arrows:
            if touch.location in arw.frame:
                sound.play_effect('rpg:Chop')
                arw.fill_color = '#969696'
                if 'right' in arw.picture:
                    global right
                    right = True


    def touch_ended(self, touch):
        for arw in self.arrows:
            if arw.fill_color == '#969696':
                arw.fill_color = 'white'
                right = left = down = up = None


    def add_buttons(self):
        #ars = arrows.Main()
        #self.present_modal_scene(ars)
        self.arrows = [Arrow(i, position=icons[i], parent=self) for i in icons] 


    def add_figure(self):
        x = random.choice(range(10)) * side - rect_w/2 + side/2
        y = rect_h/2 - side/2
        block = SpriteNode('pzl:Yellow7', (x, y), z_position=1, size=Size(side, side), parent=self.grey_rect)
        self.figures[block] = [x, y]


run(Game())   
Karina

@cvp So the Tetris didn’t receive touches?
I thought to put the moving ➡️⬅️ into arrows, but it would be much more confusing

cvp

@Karina said:

I thought to put the moving ➡️⬅️ into arrows, but it would be much more confusing

Sorry, I don't understand.

The touch_began in Game is called. Then, you could check which arrow (like you do) and process the move of the block (left, right,down)

Karina

@cvp I thought to write how to move blocks right and left in the touch_began of arrows. But no matter, you did it easier👍

Karina

@cvp I did also moving blocks down, in cycle for, one by one each block. Is there a way think of a figure as a single block?

Karina
from scene import *
import random, sound
from arrows import *

sw, sh = get_screen_size()
rect_w = sw/3  #343.33
rect_h = 612 #668
side = int(rect_w/10)
colors = ['red']

x = side/2
y = rect_h/2 - side/2
dot =  [[
         [x, y]
                ]]

line = [
         [[x, y], [x+side, y]],
         [[x, y], [x, y-side]]
                               ]

shapes = [dot, line]


class Board(ShapeNode):
    def __init__(self, stroke_color='lightgrey', line_width=1, parent=None, *args, **kwargs):
            path = ui.Path.rect(0, 0, rect_w, rect_h)
            path.line_width = line_width

            if stroke_color == 'lightgrey':
                d = int(rect_w/10)
                for l in range(int(rect_w/d)):
                    x = l*d
                    path.move_to(x, 0)
                    path.line_to(x, rect_h)

            super().__init__(path,
                             fill_color='white',
                             stroke_color=stroke_color,
                             parent=parent,
                             *args, **kwargs)



class Game(Scene):
    def setup(self):
        self.background_color = 'white'
        self.grey_rect = Board(line_width=2, parent=self, position=(sw/3, sh/2), z_position=0)
        self.board = Board(stroke_color='purple', line_width=15, parent=self, position=(sw/3, sh/2),    z_position=-1)

        self.seconds = 0
        self.figure = {}
        self.add_buttons()
        self.add_figure()


    def update(self):
        self.seconds += self.dt
        if self.seconds > 0.2:
            for f in self.figure:
                self.figure[f][1] -= side/2
                f.position = self.figure[f]
                self.seconds = 0
                if f.position.y == - rect_h/2 + side/2:
                    self.figure.pop(f)
                    self.add_figure()
                    break


    def touch_began(self, touch):
        tapped = True
        for arw in self.arrows:
            if touch.location in arw.frame:
                sound.play_effect('rpg:Chop')
                arw.fill_color = '#969696'

                for f in self.figure:
                    if -rect_w/2 < self.figure[f][0] + side < rect_w/2:
                        if 'right' in arw.picture:
                            self.figure[f][0] += side

                    if -rect_w/2 < self.figure[f][0] - side < rect_w/2:
                        if 'left' in arw.picture:
                            self.figure[f][0] -= side

    def touch_ended(self, touch):
        for arw in self.arrows:
            if arw.fill_color == '#969696':
                arw.fill_color = 'white'
                right = left = down = up = None;


    def add_buttons(self):
        self.arrows = [Arrow(i, position=icons[i], parent=self) for i in icons] 


    def add_figure(self):
        figure = random.choice(shapes)
        #for example, var=0 for horizontal line, 1 - for vertical
        var = random.choice(range(len(figure)))
        print(figure[var])
        global x 
        global y
        x = random.choice(range(10)) * side - rect_w/2 + side/2
        y = rect_h/2 - side/2
        for pos in figure[var]:
            print(pos)
            block = SpriteNode('pzl:Gray3', pos,            color=colors[shapes.index(figure)] , size=(side, side), parent=self.grey_rect)
            self.figure[block] = pos


run(Game())  

There are a lot of bugs cause I move the blocks one by one. And I added colors but they mix with the original color

ronw

check out Baclinc for the best seo services
Also Content writers in Mumbai