Пример #1
0
def build_background_grid():
    parent = Node()

    # Parameters to pass to the creation of ShapeNode
    params = {
        "path": Path.rect(0, 0, GRID_SIZE, GRID_SIZE * ROWS),
        "fill_color": "clear",
        "stroke_color": "lightgrey"
    }

    anchor = Vector2(0, 0)

    # Building the columns
    for i in range(COLUMNS):
        n = ShapeNode(**params)
        pos = Vector2(i * GRID_SIZE, 0)

        n.position = pos
        n.anchor_point = anchor

        parent.add_child(n)

    # Building the rows
    params["path"] = Path.rect(0, 0, GRID_SIZE * COLUMNS, GRID_SIZE)
    for i in range(ROWS):
        n = ShapeNode(**params)
        pos = Vector2(0, i * GRID_SIZE)

        n.position = pos
        n.anchor_point = anchor

        parent.add_child(n)

    return parent
Пример #2
0
	def setup(self):
		self.image = SpriteNode(Texture(image), z_position = -12, position = self.bounds.center(), parent = self)
		self.background = ShapeNode(path = Path.rect(0,0,self.image.size.w,self.image.size.h), position = self.image.position, z_position = -15, parent = self, fill_color = (1,1,1,.1))
		self.offset = Point(-50, 50)
		self.cursor = Node(parent = self)
		ShapeNode(path = Path.rect(0,0,1,20), parent = self.cursor, fill_color = (0,0,0))
		ShapeNode(path = Path.rect(0,0,20,1), parent = self.cursor, fill_color = (0,0,0))
		self.cursorlabel = LabelNode("", parent = self, position = (self.bounds.w/2.0, self.bounds.h*.9))
		self.selected = []
		self.selected_nodes = []
		self.selectbutton = ShapeNode(Path.rect(0,0,150,50), parent = self, position = (self.bounds.w*.2, self.bounds.h*.9), fill_color = (0,0,0), stroke_color = (1,1,1))
		LabelNode("Select", parent = self.selectbutton)
		
		self.printbutton = ShapeNode(Path.rect(0,0,150,50), parent = self, position = (self.bounds.w*.8, self.bounds.h*.9), fill_color = (0,0,0), stroke_color = (1,1,1))
		LabelNode("Print", parent = self.printbutton)
Пример #3
0
    def setup(self):
        '''Called to initialize the game'''

        self.center = (self.size.w / 2, self.size.h / 2)
        self.player = Player(parent=self, speed=PLAYER_SPEED)
        self.controller = Controller(padding=40, scale=1.2, parent=self)
        self.firebtn = FireBtn(70, parent=self)
        self.background_color = '#003f68'
        self.objects = list()
        self.lasers = list()
        self.comets = list()
        self.pos = (.0, .0)
        self.firing = False

        self.player_sequence = Sequence(
            [Shot(x_offset=40, y_offset=20),
             Shot(x_offset=-40, y_offset=20)],
            origin=self.player,
            delay=0.2)

        self.spawn_area = ShapeNode(Path.rect(*self.bounds),
                                    alpha=0,
                                    parent=self,
                                    scale=2,
                                    position=self.size / 2)
Пример #4
0
    def __init__(self, coords, location, piece, light):
        self.coords = coords
        self.location = location
        self.piece = piece
        self.light = light
        square = Path.rect(0, 0, t_lth, t_lth)

        #Creates lattice effect
        if sum(coords) % 2 == 0:
            tile_colour = '#3e3e3e'
        else:
            tile_colour = '#d3d3d3'

        #Creates square
        ShapeNode.__init__(self,
                           square,
                           tile_colour,
                           '#adadad',
                           position=location)

        #Below decides whether there is a piece and its info
        if self.piece["type"] == "p":
            self.position_chg = -0.05
        else:
            self.position_chg = -0.2

        if piece["side"] == "n":
            pass

        elif self.piece["side"] == "w":
            self.marker = LabelNode(piece["type"],
                                    ('Academy Engraved LET', t_lth),
                                    color='white',
                                    position=(0, t_lth * self.position_chg))
            self.add_child(self.marker)

        elif self.piece["side"] == "b":
            self.marker = LabelNode(piece["type"],
                                    ('Academy Engraved LET', t_lth),
                                    color='black',
                                    position=(0, t_lth * self.position_chg))
            self.add_child(self.marker)

        #Decides whether the square lights up or not (during move selection)
        if self.light == True:
            self.light_square = ShapeNode(square,
                                          "#2f77ff",
                                          "#300cdd",
                                          position=(0, 0),
                                          alpha=0.3)
            self.add_child(self.light_square)
Пример #5
0
 def __init__(self, i, j, **vargs):
     self.touched = 0
     super().__init__(Path.rect(0, 0, S, S),
                      'white',
                      position=(i * S, j * S),
                      **vargs)