示例#1
0
    def __init__(self, host, port, width, height):
        """
        Create a screen and define some game specific things.
        """
        self.host = host
        self.port = port
        self.width = width
        self.height = height

        self.players = {}

        pymlgame.init()
        self.screen = Screen(self.host, self.port, self.width, self.height)
        self.clock = Clock(15)
        self.running = True
        self.colors = [WHITE, BLUE, GREEN, CYAN, MAGENTA, YELLOW, RED]

        # surfaces
        self.corners = Surface(self.screen.width, self.screen.height)
        self.lines = Surface(
            int(self.screen.width / 2) - 2,
            int(self.screen.height / 2) - 2)
        self.rects = Surface(
            int(self.screen.width / 2) - 2,
            int(self.screen.height / 2) - 2)
        self.circle = Surface(
            int(self.screen.width / 2) - 2,
            int(self.screen.height / 2) - 2)
        self.filled = Surface(
            int(self.screen.width / 2) - 2,
            int(self.screen.height / 2) - 2)
示例#2
0
 def reset(self):
     """
     Fill the screen with black pixels
     """
     surface = Surface(self.width, self.height)
     surface.fill(BLACK)
     self.matrix = surface.matrix
示例#3
0
文件: map.py 项目: PyMLGame/pymlmario
    def render_naked_map(self):
        """
        Renders the naked map without destroyable objects

        :returns: Surface - The surface of the naked map
        """
        s = Surface(self.width, self.height)
        for y in range(self.height):
            for x in range(self.width):
                s.draw_dot((x, y), self._nakedmap[x, y])
        return s
示例#4
0
文件: map.py 项目: PyMLGame/pymlmario
    def render_pixmap(self):
        """
        Renders the current view of of the map.

        :returns: Surface - The surface of the map
        """
        s = Surface(self.width, self.height)
        for y in range(self.height):
            for x in range(self.width):
                s.draw_dot((x, y), self._pixmap[x, y])
        return s
示例#5
0
    def __init__(self):
        self.normal = Surface(2, 4)
        self.normal.draw_line((0, 0), (1, 0), RED)
        self.normal.draw_dot((0, 1), (127, 0, 0))
        self.normal.draw_dot((1, 1), (255, 127, 0))
        self.normal.draw_dot((0, 2), RED)
        self.normal.draw_dot((1, 2), BLUE)
        self.normal.draw_line((0, 3), (1, 3), BLUE)

        self.current = self.normal

        self.x = 2
        self.y = 8
        self.width = self.current.width
        self.height = self.current.height

        self.direction = 1  # 0: left, 1: right

        self.jumping = False
        self.moving = False
示例#6
0
    def __init__(self, host, port, width, height):
        """
        Create a screen and define some game specific things.
        """
        self.host = host
        self.port = port
        self.width = width
        self.height = height

        self.players = {}

        pymlgame.init()
        self.screen = Screen(self.host, self.port, self.width, self.height)
        self.clock = Clock(5)
        self.running = True
        self.colors = [WHITE, BLUE, GREEN, CYAN, MAGENTA, YELLOW, RED]
        self.color_length = math.ceil(self.screen.height / len(self.colors))

        # surfaces
        self.game_board = None
        self.init_game_board()

        self.dots = Surface(self.screen.width, self.screen.height)