Пример #1
0
        def on_debug_timer(self, dt):
                frame_time = self.display_widget.get_frame_time()
                status_output = "fps:%.1f frame_time:%.1fms" % (float(Clock.get_fps()), frame_time)
                self.set_debug_text(0, status_output)

                for i in xrange(debug.NUM_DEBUG_LINES):
                        debug_line = debug.get_line(self.state, i)
                        self.set_debug_text(1 + i, debug_line)
Пример #2
0
    def updateSystemInfo(self, nap):

        Logger.debug("Updating System Info...")

        self.getUptimeLabel().text = "[i]Running for:[/i] [b]{}[/b]".format(time.strftime('%H Hrs, %M Mins, %S Secs', time.gmtime(Clock.get_boottime())))
        self.getFPSLabel().text = "[i]Avg FPS:[/i] [b]{0:.2f}[b]".format(Clock.get_fps())

        Logger.debug("Updating System Info...Done!")
   def on_update(self):
      Window.set_title("Time For Some Girl Talk")

      self.info.text = str(Window.mouse_pos)
      self.info.text += '\nfps:%d' % kivyClock.get_fps()

      dt = kivyClock.frametime
      for flower in self.flowers:
         flower.on_update(dt)
   def on_update(self):
      self.info.text = str(Window.mouse_pos)
      self.info.text += '\nfps:%d' % kivyClock.get_fps()
      self.info.text += '\nbubbles:%d' % len(self.bubbles)

      dt = kivyClock.frametime
      
      kill_list = [b for b in self.bubbles if b.on_update(dt) == False]
      for b in kill_list:
         self.bubbles.remove(b)
         self.canvas.remove(b)
   def on_update(self):
      self.info.text = str(Window.mouse_pos)
      self.info.text += '\nfps:%d' % kivyClock.get_fps()
      pos = self.griff.get_pos()
      if pos == None:
         pos = "EVERYWHEEERREEEE!!"
      self.info.text += "\nWhere's Griff!?: %s" % str(pos)
      Window.set_title("Griff in Hell")

      dt = kivyClock.frametime
      for towny in self.people:
         towny.on_update(dt, self.griff.get_pos())        
Пример #6
0
        def on_timer(self, dt):
                if self.state:
                        cur_fps = Clock.get_fps()
                        if cur_fps > 0:
                                last_frame_delta = 1000000.0 / cur_fps
                                if self.min_frame_time_delta == 0 or last_frame_delta < self.min_frame_time_delta:
                                        self.min_frame_time_delta = last_frame_delta
                                else:
                                        last_frame_delta = self.min_frame_time_delta

                                if last_frame_delta < 33333:
                                        timer.run(self.state, last_frame_delta)
                                        self.redraw(last_frame_delta)

                if self.state:
                        Clock.schedule_once(self.on_timer, timeout=0)
   def on_update(self):      
      self.info.text = str(Window.mouse_pos)
      self.info.text += '\nfps:%d' % kivyClock.get_fps()
      self.info.text += '\nbubbles:%d' % (len(self.bubbles)+len(self.space_bubbles))

      dt = kivyClock.frametime
         
      kill_list = [b for b in self.bubbles.keys() if b.on_update(dt) == False]
      for b in kill_list:
         gen = self.bubbles.pop(b)
         gen.off()
         self.canvas.remove(b)
         
      space_kill_list = [b for b in self.space_bubbles.keys() if b.on_update(dt) == False]
      for b in space_kill_list:
         gen = self.space_bubbles.pop(b)
         gen.off()
         self.canvas.remove(b)
         
      for b in self.bubbles.keys():
         r = b.circle.size[0]
         gen = self.bubbles[b]
         #r in range [0,100]. We want gain in [0.1,0.5]
         gain = r/100.0*0.4+0.1
         gen.set_gain(gain)
         if self.psych:
            b.recolor()

      for b in self.space_bubbles.keys():
         b.decolor()
         r = b.circle.size[0]
         gen = self.space_bubbles[b]
         #r in range [0,100]. We want pitch [55,85]
         pitch = r/100.0*30+55
         gen.set_pitch(pitch)
         if self.psych:
            b.recolor()
Пример #8
0
Файл: misc.py Проект: 2xR/legacy
 def update(dt):
     label.text = "%.01f FPS" % Clock.get_fps()
Пример #9
0
	def print_fps(self, *args):
		print "FPS:", Clock.get_fps()
Пример #10
0
 def update_fps(self, *args):
     fps = Clock.get_fps()
     self.lbl.text = "{} Fps".format(int(fps))
Пример #11
0
 def update(self, dt):
     self.fps.myfps = "FPS: " + str(int(Clock.get_fps()))
     self.player.move(self.keyboard.keyevent, self.walls)
Пример #12
0
def _on_draw():
    global _toggle_state
    if _toggle_state == '':
        return

    win = getWindow()

    #
    # Show HELP screen
    #
    if _toggle_state == 'help':

        # draw the usual window
        win.on_draw()

        # make background more black
        set_color(0, 0, 0, .8)
        drawRectangle(size=win.size)

        # prepare calculation
        w2 = win.width / 2.
        h2 = win.height / 2.
        y = 0
        k = {'font_size': 20}
        ydiff = 25

        # draw help
        drawLabel('Kivy Keybinding',
                  pos=(w2, win.height - 100), font_size=40)
        drawLabel('Press F1 to leave help',
                  pos=(w2, win.height - 160), font_size=12)
        drawLabel('FPS is %.3f' % Clock.get_fps(),
                  pos=(w2, win.height - 180), font_size=12)
        drawLabel('F1 - Show Help',
                  pos=(w2, h2), **k)
        y += ydiff
        drawLabel('F2 - Show FPS (%s)' % str(win.show_fps),
                  pos=(w2, h2 - y), **k)
        y += ydiff
        drawLabel('F3 - Show Cache state',
                  pos=(w2, h2 - y), **k)
        y += ydiff
        drawLabel('F4 - Show Calibration screen',
                  pos=(w2, h2 - y), **k)
        if _can_fullscreen():
            y += ydiff
            drawLabel('F5 - Toggle fullscreen',
                      pos=(w2, h2 - y), **k)
        y += ydiff
        drawLabel('F6 - Show log',
                  pos=(w2, h2 - y), **k)
        y += ydiff
        drawLabel('F7 - Reload CSS',
                  pos=(w2, h2 - y), **k)
        y += ydiff
        drawLabel('F8 - Show widget tree',
                  pos=(w2, h2 - y), **k)
        y += ydiff
        drawLabel('F9 - Rotate the screen (%d)' % win.rotation,
                  pos=(w2, h2 - y), **k)
        y += ydiff
        drawLabel('F12 - Screenshot',
                  pos=(w2, h2 - y), **k)

        return True

    #
    # Draw cache state
    #
    elif _toggle_state == 'cachestat':
        # draw the usual window
        win.on_draw()

        # make background more black
        set_color(0, 0, 0, .8)
        drawRectangle(size=win.size)

        y = 0
        for x in Cache._categories:
            y += 25
            cat = Cache._categories[x]
            count = 0
            usage = '-'
            limit = cat['limit']
            timeout = cat['timeout']
            try:
                count = len(Cache._objects[x])
            except:
                pass
            try:
                usage = 100 * count / limit
            except:
                pass
            args = (x, usage, count, limit, timeout)
            drawLabel('%s: usage=%s%% count=%d limit=%s timeout=%s' % args,
                    pos=(20, 20 + y), font_size=20, center=False, nocache=True)

        return True

    #
    # Draw calibration screen
    #
    elif _toggle_state == 'calibration':
        step = 8
        ratio = win.height / float(win.width)
        stepx = win.width / step
        stepy = win.height / int(step * ratio)

        # draw black background
        set_color(0, 0, 0)
        drawRectangle(size=win.size)

        # draw lines
        set_color(1, 1, 1)
        for x in xrange(0, win.width, stepx):
            drawLine((x, 0, x, win.height))
        for y in xrange(0, win.height, stepy):
            drawLine((0, y, win.width, y))

        # draw circles
        drawCircle(pos=(win.width / 2., win.height / 2.),
                   radius=win.width / step, linewidth = 2.)
        drawCircle(pos=(win.width / 2., win.height / 2.),
                   radius=(win.width / step) * 2, linewidth = 2.)
        drawCircle(pos=(win.width / 2., win.height / 2.),
                   radius=(win.width / step) * 3, linewidth = 2.)

        return True


    #
    # Draw calibration screen 2 (colors)
    #
    elif _toggle_state == 'calibration2':

        # draw black background
        set_color(0, 0, 0)
        drawRectangle(size=win.size)

        # gray
        step = 25
        stepx = (win.width - 100) / step
        stepy = stepx * 2
        sizew = stepx * step
        sizeh = stepy * step
        w2 = win.width / 2.
        h2 = win.height / 2.
        for _x in xrange(step):
            x = w2 - sizew / 2. + _x * stepx
            drawLabel(chr(65+_x), pos=(x + stepx / 2., h2 + 190))
            c = _x / float(step)

            # grey
            set_color(c, c, c)
            drawRectangle(pos=(x, h2 + 100), size=(stepx, stepy))

            # red
            set_color(c, 0, 0)
            drawRectangle(pos=(x, h2 + 80 - stepy), size=(stepx, stepy))

            # green
            set_color(0, c, 0)
            drawRectangle(pos=(x, h2 + 60 - stepy * 2), size=(stepx, stepy))

            # blue
            set_color(0, 0, c)
            drawRectangle(pos=(x, h2 + 40 - stepy * 3), size=(stepx, stepy))
        return True


    #
    # Draw log screen
    #
    elif _toggle_state == 'log':

        # draw the usual window
        win.on_draw()

        # make background more black
        set_color(0, 0, 0, .8)
        drawRectangle(size=win.size)


        # calculation
        w2 = win.width / 2.
        h2 = win.height / 2.
        k = {'font_size': 11, 'center': False}
        y = win.height - 20
        y = h2
        max = int((h2 / 20))
        levels = {
            logging.DEBUG: ('DEBUG', (.4, .4, 1)),
            logging.INFO: ('INFO', (.4, 1, .4)),
            logging.WARNING: ('WARNING', (1, 1, .4)),
            logging.ERROR: ('ERROR', (1, .4, .4)),
            logging.CRITICAL: ('CRITICAL', (1, .4, .4)), }

        # draw title
        drawLabel('Kivy logger',
                  pos=(w2, win.height - 100), font_size=40)

        # draw logs
        for log in reversed(kivy_logger_history.history[:max]):
            levelname, color = levels[log.levelno]
            msg = log.message.split('\n')[0]
            x = 10
            s = drawLabel('[', pos=(x, y), **k)
            x += s[0]
            s = drawLabel(levelname, pos=(x, y), color=color, **k)
            x += s[0]
            s = drawLabel(']', pos=(x, y), **k)
            x += s[0]
            drawLabel(msg, pos=(100, y), **k)
            y -= 20
        return True
Пример #13
0
 def _print_fps(self, *largs):
     print 'FPS: %2.4f (real draw: %d)' % (
         Clock.get_fps(), Clock.get_rfps())
Пример #14
0
 def update(self, dt):
     self.background.move()
     miniball = self.miniball
     self.miniball.move()
     maxiball = self.maxiball
     maxiball.move()
     # powerup collision
     powerup = self.powerup
     powerup.move()
     d_maxi =  distance(powerup, maxiball)
     if d_maxi < powerup.hitbox + maxiball.hitbox:
         self.combo += 1
         sounds['powerup'].play()
         maxiball.color = powerup.fg_img.color
         maxiball.element = powerup.element
         if powerup.element == 'ice':
             for i in range(self.level):
                 self.rainboxes[i].frozen = 180
         print miniball.hitbox
         miniball.deployed = powerup.element == 'fire'
         print miniball.hitbox
         powerup.reset()
     # mistake mini
     d_mini =  distance(powerup, miniball)
     if d_mini < powerup.hitbox + miniball.hitbox:
         self.combo = 1
         sounds['hurt'].play()
         powerup.reset()
         if maxiball.element == 'stone':
             self.end_game()
         else: maxiball.element = 'stone'
         miniball.deployed = False
     # box collision
     for i in range(self.level):
         rainbox = self.rainboxes[i]
         rainbox.move()
         d_mini =  distance(rainbox, miniball)
         if d_mini < rainbox.hitbox + miniball.hitbox:
             print rainbox.hitbox, miniball.hitbox
             self.hits += 1
             self.cons += 1
             if self.cons == 10:
                 self.level += 1
                 sounds['levelup'].play()
             self.score += self.hits * self.combo
             sounds['hit'].play()
             rainbox.reset()
         # mistake maxi
         d_maxi =  distance(rainbox, maxiball)
         if d_maxi < rainbox.hitbox + maxiball.hitbox:
             self.cons = 0
             sounds['hurt'].play()
             rainbox.reset()
             if maxiball.element == 'stone':
                 self.end_game()
             else: maxiball.element = 'stone'
             miniball.deployed = False
     # labels update
     self.lbl_fps.text = 'FPS: %d' % Clock.get_fps()
     self.lbl_hits.text = 'HITS: x%d (%d)' % (self.cons, self.hits)
     self.lbl_combo.text = 'COMBO: x%d' % self.combo
     self.lbl_score.text = 'SCORE: %d' % self.score
     self.lbl_level.text = 'LEVEL: %d (%d)' % (self.level, self.seconds)
Пример #15
0
 def fps(self):
     return Clock.get_fps()
Пример #16
0
 def update_fps(self, dt):
     self.fps = str(int(Clock.get_fps()))
Пример #17
0
 def update_game(self, dt):
   self.counter += 1
   if self.ship.cooldown:
     self.ship.cooldown -= 1
   level = self.counter / 600
   if level == 20:
     self.ship.hp = 0
   if level > self.level:
     self.level = level
     self.root_widget.ids['level'].text = 'LEVEL: %s' % (self.level + 1)
     self.ship.hp = self.ship.hp_max
     self.update_health()
   self.level_mod = (1 - self.level/40.)
   self.spawn_drone()
   self.spawn_saucer()
   self.fire_drone()
   self.fire_saucer()
   for child in self.children:
     if not check_classname(child, 'Explosion'):
       # movement
       if child.dx or child.dy:
         child.x += child.dx
         child.y += child.dy
       # collision check
       if check_classname(child, 'Projectile'):
         projectile = child
         if projectile.player == 'human':
           for drone in self.drones:
             if projectile.collide_widget(drone):
               self.inc_score(projectile.score_bonus)
               self.explosion(drone.x, drone.y)
               self.remove_widget(projectile)
               self.remove_widget(drone)
               self.drones.remove(drone)
               # if self.sfx_explo.state == 'play':
                 # self.sfx_explo.stop()
               
           for saucer in self.saucers:
             if projectile.collide_widget(saucer):
               self.inc_score(projectile.score_bonus)
               self.explosion(saucer.x, saucer.y)
               self.remove_widget(projectile)
               self.remove_widget(saucer)
               self.saucers.remove(saucer)
               # if self.sfx_explo.state == 'play':
                 # self.sfx_explo.stop()
         elif projectile.player == 'computer':
           if projectile.collide_widget(self.ship):
             self.remove_widget(projectile)
             if not self.ship.is_shielded:
               self.ship.hp -= 1
               self.update_health() 
               self.blink()  
               
     # outside of screen        
     if child.y < - 200:
       self.remove_widget(child)
       if check_classname(child, 'Drone'):
         self.drones.remove(child)
       elif check_classname(child, 'Saucer'):
         self.saucers.remove(child)
     if child.y > self.height + 200:
       self.remove_widget(child)
       if check_classname(child, 'Drone'): 
         self.drones.remove(child)
       elif check_classname(child, 'Saucer'):
         self.saucers.remove(child)
   # background scrolling      
   self.rect_bg1.y -= 3
   self.rect_bg2.y -= 3
   if self.rect_bg1.y < - self.height:
     self.rect_bg1.y = self.rect_bg2.y + self.rect_bg2.height
   if self.rect_bg2.y < - self.height:
     self.rect_bg2.y = self.rect_bg1.y + self.rect_bg1.height
   # fps update  
   self.root_widget.ids['fps'].text = 'FPS: %.2f' % Clock.get_fps()
   # game over
   if self.ship.hp <= 0:
     go_popup = GameOver(self.root_widget)
     go_popup.set_score(self.score)
     go_popup.open()
     return False
Пример #18
0
def update_fps(ctx, *largs):
    ctx.label.text = 'FPS: %f' % Clock.get_fps()
    ctx.rectangle.texture = ctx.label.texture
    ctx.rectangle.size = ctx.label.texture_size
Пример #19
0
 def update(self, dt):
     self.fps = str(int(Clock.get_fps()))
     Clock.schedule_once(self.update)
Пример #20
0
 def update(self, *args):
     self.rect.size = self.size
     self.rect.pos = self.pos
     self.label.text = 'FPS: ' + str(int(Clock.get_fps()))