Exemplo n.º 1
0
 def __init__(self, grid: GridView, tile: model.Tile):
     """Display the tile on the grid.
     Internally there are actually two graphics objects:
     A background rectangle and text within it. The
     background rectangle has a visible outline until
     the first time it moves.
     """
     self.grid = grid
     self.win = grid.win
     self.row = tile.row
     self.col = tile.col
     self.value = tile.value
     ul, lr = grid.tile_corners(self.row, self.col)
     background = graphics.Rectangle(ul, lr)
     background.setFill(RAMP[self.value])
     background.setOutline(TILE_OUTLINE_NEW)
     self.background = background
     cx = (ul.getX() + lr.getX()) / 2.0
     cy = (ul.getY() + lr.getY()) / 2.0
     center = graphics.Point(cx, cy)
     label = graphics.Text(center, str(self.value))
     label.setSize(36)
     self.label = label
     background.draw(self.win)
     label.draw(self.win)
Exemplo n.º 2
0
    def __init__(self, text, p1, p2):
        self.text = text

        self.rect = graphics.Rectangle(p1, p2)
        self.text = graphics.Text(self.rect.getCenter(), text)

        self.clicked = False
        self.visible = False
Exemplo n.º 3
0
 def loadNation(self, nation, player: bool):
     self.nation = nation
     self.attackButton.visible = player
     self.recruitButton.visible = player
     self.recruit_amount.undraw()
     self.text = graphics.Text(self.rect.getCenter(),
                               self.nation.name + " - Money: " + str(self.nation.money) + " - Soldiers: " + str(
                                   self.nation.soldiers))
     self.draw()
Exemplo n.º 4
0
    def __init__(self, points):
        self.shape = Shape.Shape(points)
        self.name = "test"

        newPoints = []
        for point in self.shape.points:
            newPoints.append(graphics.Point(point.x, point.y))

        center = graphics.Point(self.shape.polygon.centroid.coords.xy[0].pop(),
                                self.shape.polygon.centroid.coords.xy[1].pop())

        self.mapText = graphics.Text(center, self.name)
Exemplo n.º 5
0
 def lose(self, score=0):
     """Display 'Game Over' and close after next keystroke"""
     center = graphics.Point(self.width / 2.0, self.height / 2.0)
     if score:
         goodbye = "Game over. Your score: {}".format(score)
     else:
         goodbye = "Game over"
     splash = graphics.Text(center, goodbye)
     splash.setFace("times roman")
     splash.setSize(36)  # The largest font size supported by graphics.py
     splash.setTextColor("red")
     splash.draw(self.win)
     self.get_key()
     self.close()
Exemplo n.º 6
0
 def __init__(self, grid, t):
     self.grid = grid
     self.win = grid.win
     self.r = t.r
     self.c = t.c
     self.val = t.val
     left, right = grid.tile_corners(self.r, self.c)
     white = g.Rectangle(left, right)
     white.setFill(xo_colors[self.val])
     self.bg = white
     x = (left.getX() + right.getX()) / 2
     y = (left.getY() + right.getY()) / 2
     center = g.Point(x, y)
     label = g.Text(center, self.val)
     label.setSize(36)
     if self.val in nums:
         label.setFill("white")
     self.label = label
     white.draw(self.win)
     label.draw(self.win)
     self.x = x
     self.y = y
Exemplo n.º 7
0
 def new_message(self, text):
     self.text = graphics.Text(self.rect.getCenter(), text)
     self.draw()