Example #1
0
def test_sys_time(console):
    libtcodpy.sys_set_fps(0)
    libtcodpy.sys_get_fps()
    libtcodpy.sys_get_last_frame_length()
    libtcodpy.sys_sleep_milli(0)
    libtcodpy.sys_elapsed_milli()
    libtcodpy.sys_elapsed_seconds()
Example #2
0
 def update_objects(self):
   self.update_timer1 = libtcod.sys_elapsed_milli()
   for object in self.objects:
     self.player.check_collision(object)
     if isinstance(object, Monster):
       if object.Alive is False:
         object.clear(self.con)
         self.objects.remove(object)
   self.update_timer2 = libtcod.sys_elapsed_milli()
Example #3
0
def main_game_loop(facility, consoles):
    now = libtcod.sys_elapsed_milli()
    while not messages.quit:
        # Time computing
        delta = libtcod.sys_elapsed_milli() - now
        now = libtcod.sys_elapsed_milli()
        # Model update
        messages.poll(game_mode, facility)
        facility.update(delta)
        # Display !
        consoles.display(delta)
Example #4
0
def main_game_loop(facility, consoles):
    now = libtcod.sys_elapsed_milli()
    while not messages.quit:
        # Time computing
        delta = libtcod.sys_elapsed_milli() - now
        now = libtcod.sys_elapsed_milli()
        # Model update
        messages.poll(game_mode, facility)
        facility.update(delta)
        # Display !
        consoles.display(delta)
Example #5
0
	def draw(self):
		total_milli = 0
		for frame in self.frames:
			pre_action_milli = libtcod.sys_elapsed_milli()
			frame.draw()
			post_action_milli = libtcod.sys_elapsed_milli()
			if self.should_measure:
				print 'Frame ' + frame['frame'].__class__.__name__ + ' took ' + str(post_action_milli - pre_action_milli) + ' MS to draw'
				total_milli += post_action_milli - pre_action_milli
		if self.should_measure:
			print 'Total draw call duration: ' + str(total_milli) + ' MS'
			self.should_measure = False
		libtcod.console_flush()
Example #6
0
 def draw(self):
     total_milli = 0
     for frame in self.frames:
         pre_action_milli = libtcod.sys_elapsed_milli()
         frame.draw()
         post_action_milli = libtcod.sys_elapsed_milli()
         if self.should_measure:
             print 'Frame ' + frame[
                 'frame'].__class__.__name__ + ' took ' + str(
                     post_action_milli - pre_action_milli) + ' MS to draw'
             total_milli += post_action_milli - pre_action_milli
     if self.should_measure:
         print 'Total draw call duration: ' + str(total_milli) + ' MS'
         self.should_measure = False
     libtcod.console_flush()
Example #7
0
    def update(self, delta):

        if self.is_executing and len(self.queued_actions) > 0:
            self.update_timer += delta
            if self.update_timer >= self.update_delay:
                pre_action_milli = libtcod.sys_elapsed_milli()

                self.update_timer = 0
                current_action = self.queued_actions.pop()
                self.process_single_queued_action(current_action)
                # this is the only line of code that depends on the outside world to any degree. I *REALLY* don't like doing this, and may consider a callback model in the future
                # for now it is the simple way to tell the UI that we processed an action without doing nasty voodoo in MenuGame
                self.parent_menu.frame_manager.handle_ui_event(
                    UIEvent(UIEventType.ActionQueueRemove, {"action": current_action})
                )
                if len(self.queued_actions) == 0:
                    self.is_executing = False

                post_action_milli = libtcod.sys_elapsed_milli()
                print "single action took " + str(post_action_milli - pre_action_milli) + " MS"
Example #8
0
  def render_all(self):
    self.render_timer1 = libtcod.sys_elapsed_milli()

    for object in self.objects:
      object.draw(self.con, self.map)

    if self.fov_recompute:
      #recompute FOV if needed (the player moved or something)
      self.fov_recompute = False
      self.map.recompute_fov(self.player.x, self.player.y)

    self.map.draw(self.con)

    messagePanel = self.Messages.render()

    libtcod.console_blit(messagePanel,
                         0, 0, 0, 0,
                         self.con, 0, 46)
    libtcod.console_blit(self.con, 0, 0, 0, 0, 0, 0, 0)
    self.render_timer2 = libtcod.sys_elapsed_milli()
Example #9
0
	def update (self):
		cur_time = tcod.sys_elapsed_milli()
		dt = cur_time - self.last_time
		self.last_time = cur_time
		self.time_buf += dt

		while self.time_buf >= self.interval:
			self.time_buf -= self.interval

			result = self.cb(*self.args)
			if result:
				return result
Example #10
0
    def update(self, delta):

        if self.is_executing and len(self.queued_actions) > 0:
            self.update_timer += delta
            if self.update_timer >= self.update_delay:
                pre_action_milli = libtcod.sys_elapsed_milli()

                self.update_timer = 0
                current_action = self.queued_actions.pop()
                self.process_single_queued_action(current_action)
                #this is the only line of code that depends on the outside world to any degree. I *REALLY* don't like doing this, and may consider a callback model in the future
                #for now it is the simple way to tell the UI that we processed an action without doing nasty voodoo in MenuGame
                self.parent_menu.frame_manager.handle_ui_event(
                    UIEvent(UIEventType.ActionQueueRemove,
                            {'action': current_action}))
                if len(self.queued_actions) == 0:
                    self.is_executing = False

                post_action_milli = libtcod.sys_elapsed_milli()
                print 'single action took ' + str(post_action_milli -
                                                  pre_action_milli) + ' MS'
Example #11
0
def stats():
	libtcod.console_set_default_foreground(None, libtcod.grey)
	
	libtcod.console_print_ex (
		None, 79, 46, libtcod.BKGND_NONE, libtcod.RIGHT,
		'last frame : %3d ms (%3d fps)' %
		(
			int(libtcod.sys_get_last_frame_length() * 1000.0),
			libtcod.sys_get_fps()
		)
	)
	
	libtcod.console_print_ex (
		None, 79, 47, libtcod.BKGND_NONE, libtcod.RIGHT,
		'elapsed : %8d ms %4.2fs' %
		(
			libtcod.sys_elapsed_milli(),
			libtcod.sys_elapsed_seconds()
		)
	)
Example #12
0
	def reset (self):
		self.last_time = tcod.sys_elapsed_milli()
		self.time_buf = 0
Example #13
0
	def resume (self):
		self.last_time = tcod.sys_elapsed_milli()
Example #14
0
	def pause (self):
		cur_time = tcod.sys_elapsed_milli() #TODO paste
		dt = cur_time - self.last_time
		self.last_time = cur_time
		self.time_buf += dt
Example #15
0
	def start (self):
		self.last_time = tcod.sys_elapsed_milli()
		return self
Example #16
0
def get_elapsed_milli():
    return libtcod.sys_elapsed_milli()