Esempio n. 1
0
 def updatefpslabel(self, *args):
     if Globals.debugMode:
         self.fpslabel.opacity = 1
         self.fpslabel.text = 'rfps:' + str(Clock.get_rfps())
     else:
         self.fpslabel.opacity = 0
         return False
Esempio n. 2
0
    def update(self, *ignore):
        self.player.update()
        self.fps_lab.text = 'FPS: ' + str(Clock.get_rfps())

        boxes_on_point = 0
        for box in self.boxes:
            box.update()
            if box.tile in self.level.blockpoints:
                boxes_on_point += 1

        if boxes_on_point == len(self.boxes):
            print('Level {} beat!'.format(self.level.level))
Esempio n. 3
0
 def __init__(self, **kwargs):
     super(Top, self).__init__(**kwargs)
     self.size = Window.size
     with self.canvas:
         Color(0, 0, 0, 1)
         Rectangle(size=self.size)
     self.fpslabel = Label(text='rfps:' + str(Clock.get_rfps()),
                           size=[100, 50],
                           opacity=0)
     self.fpslabel.pos = 0, 0
     menu = Menu(size=self.size)
     self.add_widget(menu)
     self.add_widget(self.fpslabel)
Esempio n. 4
0
    def __init__(self, level):
        super(Game, self).__init__()
        self.level = Level.load_level(level)
        self.background = Sprite(source='img/background.PNG')
        self.size = self.background.size
        self.player = None
        self.boxes = []

        # Initiate the game by creating tiles
        Tile.make_tiles(self.size, self.level)

        # Add bg widget first to not cover other sprites
        self.add_widget(self.background)

        # Add proper widgets for every non-empty tile in the Tile.List
        for tile in Tile.List:
            if tile.type != 'empty':
                if Tile.get_tile(tile.number - Tile.V).walkable:
                    self.add_widget(Sprite(
                        source=Tile.image_files[tile.type],
                        pos=(tile.x, tile.y)), index=2)
                else:
                    self.add_widget(Sprite(
                        source=Tile.image_files[tile.type + '_edge'],
                        pos=(tile.x, tile.y - SPRITE_EDGE_OFFSET)))

        for tile in self.level.boxspawn:
            self.boxes.append(Box(tile, self))

        self.player = Player(self.level.playerspawn, self)

        self.fps_lab = Label(
            text='FPS: ' + str(Clock.get_rfps()),
            pos=(2, self.height - 110),
            font_name=APP_FONT,
            font_size=18,
            color=(240, 240, 240, 0.8))

        self.add_widget(self.fps_lab)

        self.add_widget(Label(
            text="Level {}".format(self.level.level),
            pos=(0, self.height - 80),
            font_name=APP_FONT,
            font_size=18,
            color=(240, 240, 240, 0.8)))

        # Schedule an interval for the game update function
        Clock.schedule_interval(self.update, 1.0/60.0)
Esempio n. 5
0
File: main.py Progetto: hellux/897
 def update(self):
     self.label.top = HEIGHT
     self.label.right = WIDTH
     if self.debug:
         data = [
             ["fps", int(Clock.get_fps())],
             ["rfps", int(Clock.get_rfps())],
         ]
         self.label_text = "{}, {}.{} version {}".format(
             __title__, __domain__, __android_package__, __version__)
         for element, value in data:
             self.label_text += "\n[color=888888]{}:[/color] {}".format(
                 element, value)
     elif self.fps:
         self.label_text = "fps: {:.0f}".format(Clock.get_fps())
Esempio n. 6
0
    def update(self, dt):
        #print(Clock.get_rfps())
        self.camera.update(self)
        self.game_map.update(self)
        self.e_container.update(self)
        self.wave_manager.update(self)
        self.user_interface.update(self)

        self.decal_engine.update(self)

        self.debug.text = self.player.components['Action'].state
        self.debug2.text = str(len(self.e_container.children)) + ' ' + str(self.player.components['Action'].get_value(self.player, 'velocity_multiplier'))
        fps = Clock.get_rfps()
        self.debug3.text = str(fps)
        self.debug4.text = str(self.player.components['Action'].exp)
Esempio n. 7
0
    def flick(self, time_passed):
        self.statistic['data']['period'].append(time_passed * 2)
        self.statistic['data']['error'].append(
            math.fabs(
                (1 / time_passed - self.rect_flip_freq) / self.rect_flip_freq))
        fps = Clock.get_rfps()
        # Ignore FPS of a few first frames which are 0
        # (fps of Kivy needs some initial frame before reporting the value for us)
        if fps > 0:
            self.statistic['data']['fps'].append(fps)
        size = self.get_size()
        pos = self.get_pos()
        with self.canvas:
            self.canvas.clear()
            if self.state:
                Color(*appearance.COLOR['WHITE'])
            else:
                Color(*appearance.COLOR['BLACK'])
            Rectangle(pos=pos, size=size)

            if self.state:
                self.remove_widget(self.label_2)
                self.label_1.pos = self.get_label_pos(
                    self.label_1.texture_size)
                self.label_1.font_size = size[
                    1] * appearance.TILE_FONT_SIZE_RATIO
                self.label_1.size = self.label_1.texture_size
                self.label_1.color = appearance.LABEL_COLOR['BLACK']
                self.add_widget(self.label_1)
            else:
                self.remove_widget(self.label_1)
                self.label_2.pos = self.get_label_pos(
                    self.label_2.texture_size)
                self.label_2.font_size = size[
                    1] * appearance.TILE_FONT_SIZE_RATIO
                self.label_2.size = self.label_2.texture_size
                self.label_2.color = appearance.LABEL_COLOR['WHITE']
                self.add_widget(self.label_2)

            if appearance.SHOW_TILE_FREQUENCY_LABEL:
                self.remove_widget(self.label_frequency)
                self.label_frequency.pos = pos
                self.add_widget(self.label_frequency)
            self.state = not self.state
Esempio n. 8
0
 def _print_fps(self, *largs):
     print('FPS: %2.4f (real draw: %d)' % (
         Clock.get_fps(), Clock.get_rfps()))
Esempio n. 9
0
 def _print_fps(self, *largs):
     print 'FPS: %2.4f (real draw: %d)' % (
         Clock.get_fps(), Clock.get_rfps())
Esempio n. 10
0
 def delta_time(self):
     self.current_fps = Clock.get_rfps()
     if self.current_fps == 0:   #to prevent division by zero error
         self.current_fps = 60
     self.fps_adj_factor = self.fps / float(self.current_fps)
Esempio n. 11
0
 def __get_fps(self, timing):
     return False
     print Clock.get_rfps()
Esempio n. 12
0
 def update(self,*args):
     self.label_fps.text = 'fps:'+ str(Clock.get_fps())
     self.label_rfps.text = 'rfps:'+ str(Clock.get_rfps())
Esempio n. 13
0
 def update_fps(self, x):
     self.ids.show_fps.text = 'FPS: {:05.2f} - {:05.2f}'.format(
         Clock.get_fps(), Clock.get_rfps())
Esempio n. 14
0
 def fps(self):
     self.fps_current = Clock.get_rfps()
     if self.fps_current == 0:   #to prevent division by zero error
         self.fps_current = self.fps_normal
     self.fps_adj_factor = self.fps_normal / float(self.fps_current) 
 def update(self, dt):
     self.boottime = Clock.get_boottime()
     self.fps = Clock.get_fps()
     self.rfps = Clock.get_rfps()
     self.frames_drawn = Clock.frames_displayed
     self.frames_total = Clock.frames