コード例 #1
0
ファイル: render.py プロジェクト: kururugi/Udon
def init_window():
    global window
    w, h = config.WINDOW_RESOLUTION
    dprint("Initializing window")
    dprint("Window resolution:", config.WINDOW_RESOLUTION)
    window = pyglet.window.Window(width=w,
                                  height=h,
                                  caption="Udon",
                                  vsync=config.VSYNC)
コード例 #2
0
ファイル: render.py プロジェクト: Zer0-/Udon
def init_window():
    global window
    w, h = config.WINDOW_RESOLUTION
    dprint("Initializing window")
    dprint("Window resolution:", config.WINDOW_RESOLUTION)
    window = pyglet.window.Window(width=w,
                                  height=h,
                                  caption="Udon",
                                  vsync=config.VSYNC
                                  )
コード例 #3
0
    def get_visible_area(self):
        """Gets the coordinates of the first and last tiles
           to be visible by the viewport"""

        viewx, viewy = self.viewPosition
        #print viewx, viewy
        viewsizex, viewsizey = self.viewDimensions
        tilewidth, tileheight = self.tileDimensions
        #Using floats here rather than ints will screw up the calculation
        if DEBUG:
            for i in [viewx, viewy, tilewidth, tileheight]:
                if type(i) is not int:
                    print "Warning: In get_visible_area something is a float"

        #first we should check if we're
        # too far back from the entire map to see anything
        if viewx + viewsizex < 0 or viewy + viewsizey < 0:
            dprint(
                "the view is too far above/left of the field to see anything")
            return None

        #first, last tile indices to be visible in the viewport
        if viewx < tilewidth:
            firstVisibleHorizontally = 0
        else:
            firstVisibleHorizontally = (viewx / tilewidth) - 1

        if viewy < tileheight:
            firstVisibleVertically = 0
        else:
            firstVisibleVertically = (viewy * 2 / (tileheight)) - 1

        #now we check if we've overshot the field completely
        if firstVisibleHorizontally > self.tilemap.mapDimensions[0] \
                or firstVisibleVertically > self.tilemap.mapDimensions[1]:
            dprint(
                "You've overshot the field (too far down/right) to see anything"
            )
            return None

        lastVisibleHorizontally = ((viewx + viewsizex) / tilewidth)
        lastVisibleVertically = (viewy + viewsizey) / (tileheight / 2)
        #what if the map isn't even that big?
        if lastVisibleHorizontally > self.tilemap.mapDimensions[0]:
            lastVisibleHorizontally = self.tilemap.mapDimensions[0]

        if lastVisibleVertically > self.tilemap.mapDimensions[1]:
            lastVisibleVertically = self.tilemap.mapDimensions[1]

        return ((firstVisibleHorizontally, lastVisibleHorizontally),
                (firstVisibleVertically, lastVisibleVertically))
コード例 #4
0
ファイル: tilegrid.py プロジェクト: kururugi/Udon
    def get_visible_area(self):
        """Gets the coordinates of the first and last tiles
           to be visible by the viewport"""

        viewx, viewy = self.viewPosition
        #print viewx, viewy
        viewsizex, viewsizey = self.viewDimensions
        tilewidth, tileheight = self.tileDimensions
        #Using floats here rather than ints will screw up the calculation
        if DEBUG:
            for i in [viewx, viewy, tilewidth, tileheight]:
                if type(i) is not int:
                    print "Warning: In get_visible_area something is a float"

        #first we should check if we're
        # too far back from the entire map to see anything
        if viewx + viewsizex < 0 or viewy + viewsizey < 0:
            dprint("the view is too far above/left of the field to see anything")
            return None

        #first, last tile indices to be visible in the viewport
        if viewx < tilewidth:
            firstVisibleHorizontally = 0
        else:
            firstVisibleHorizontally = (viewx / tilewidth) - 1

        if viewy < tileheight:
            firstVisibleVertically = 0
        else:
            firstVisibleVertically = (viewy*2 / (tileheight)) - 1

        #now we check if we've overshot the field completely
        if firstVisibleHorizontally > self.tilemap.mapDimensions[0] \
                or firstVisibleVertically > self.tilemap.mapDimensions[1]:
            dprint("You've overshot the field (too far down/right) to see anything")
            return None

        lastVisibleHorizontally = ((viewx + viewsizex) / tilewidth)
        lastVisibleVertically = (viewy + viewsizey) / (tileheight/2)
        #what if the map isn't even that big?
        if lastVisibleHorizontally > self.tilemap.mapDimensions[0]:
            lastVisibleHorizontally = self.tilemap.mapDimensions[0]

        if lastVisibleVertically > self.tilemap.mapDimensions[1]:
            lastVisibleVertically = self.tilemap.mapDimensions[1]

        return (
            (firstVisibleHorizontally, lastVisibleHorizontally),
            (firstVisibleVertically, lastVisibleVertically)
        )
コード例 #5
0
ファイル: tilegrid.py プロジェクト: Zer0-/Udon
    def get_visible_area(self):
        """Gets the coordinates of the first and last tiles
           to be visible and rendered by the viewport"""

        viewx, viewy = self.viewPosition
        self.positionlabel.text = str((viewx, viewy))
        viewsizex, viewsizey = self.viewDimensions
        tilewidth, tileheight = self.getTileDimensions()
        tilewidth = int(tilewidth)
        tileheight = int(tileheight)

        #first we should check if we're
        # too far back from the entire map to see anything
        if viewx + viewsizex < 0 or viewy + viewsizey < 0:
            dprint("the view is too far above/left of the field to see anything")
            return None

        #first, last tile indices to be visible in the viewport
        if viewx < tilewidth:
            firstVisibleHorizontally = 0
        else:
            firstVisibleHorizontally = (viewx / tilewidth) - 1

        if viewy < tileheight:
            firstVisibleVertically = 0
        else:
            firstVisibleVertically = (viewy*2 / (tileheight)) - 1

        #now we check if we've overshot the field completely
        if firstVisibleHorizontally > self.mapDimensions[0] \
                or firstVisibleVertically > self.mapDimensions[1]:
            dprint("You've overshot the field (too far down/right) to see anything")
            return None

        lastVisibleHorizontally = ((viewx + viewsizex) / tilewidth)
        lastVisibleVertically = (viewy + viewsizey) / (tileheight/2)
        #what if the map isn't even that big?
        if lastVisibleHorizontally > self.mapDimensions[0]:
            lastVisibleHorizontally = self.mapDimensions[0]

        if lastVisibleVertically > self.mapDimensions[1]:
            lastVisibleVertically = self.mapDimensions[1]

        return (
            (firstVisibleHorizontally, lastVisibleHorizontally),
            (firstVisibleVertically, lastVisibleVertically)
        )