Esempio n. 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()
def get_raw_input():
    libtcod.sys_sleep_milli(
        1)  # prevent from checking a billion times/second to reduce CPU usage

    # we use the check_for_event instead of the wait_for_event function
    # because wait_for_event causes lots of problems
    libtcod.sys_check_for_event(
        libtcod.EVENT_KEY
        | libtcod.EVENT_MOUSE_PRESS  # we only want to know mouse press
        | libtcod.EVENT_MOUSE_RELEASE,  # or release, NOT mouse move event.
        key,
        mouse)
    return (
        key,
        mouse,
    )
    def run(self):
        super(TextInputManager, self).run()

        libtcod.sys_sleep_milli(5)  #reduce CPU usage

        self.update()

        libtcod.sys_check_for_event(  # check don't wait.
            libtcod.EVENT_KEY
            | libtcod.EVENT_MOUSE_PRESS  # we only want to know mouse press
            | libtcod.EVENT_MOUSE_RELEASE,  # or release, NOT mouse move event.
            self.key,
            self.mouse)

        self.get_char()
        self.mouse_events()
        self.keyboard_events()
Esempio n. 4
0
    def draw(self):  #sleep is in miliseconds

        if self.char == '':
            self.char = determine_projchar(
                self.origin, self.end
            )  #can't put functions in the definition line apparently, so its here instead

        libtcod.console_set_default_foreground(self.console, self.color)
        for point in self.line:
            libtcod.console_put_char(self.console, int(point.x), int(point.y),
                                     self.char, libtcod.BKGND_NONE)

        lastpoint = self.line[-1]
        libtcod.console_put_char(self.console, int(lastpoint.x),
                                 int(lastpoint.y), 9, libtcod.BKGND_NONE)
        libtcod.console_blit(self.console, 0, 0, 0, 0, 0,
                             min(self.origin.camx, self.end.camx),
                             min(self.origin.camy, self.end.camy), 1, 0)
        libtcod.console_flush()

        libtcod.sys_sleep_milli(self.sleep)
        self.duration -= 1
 def run(self):
     super(Manager_Menu, self).run()
     
     libtcod.sys_sleep_milli(5)
     key,mouse=IO.get_raw_input()
     
 #   mouse
     if mouse.lbutton_pressed:
         self.refresh()
         index=mouse.cy - self.y - self.border_h
         if (index >= 0 and index < self.h - self.border_h*2):
             result=tuple(self.keysItems.values())[index]
             self.set_result(result)
     
 #   key
     if libtcod.console_is_key_pressed(key.vk):
         if key.vk == libtcod.KEY_ESCAPE:
             self.set_result(-1)
     if key.vk == libtcod.KEY_TEXT: # select
         self.refresh()
         n=self.keysItems.get(key.text,None) #.decode()
         if n: self.set_result(n)
Esempio n. 6
0
	def on_apply(self):
		actor = self.actor
		
		messages.Basic('Your mind expands to fill the world around you.', actor, self.symbol)
		
		#for (x, y) in self.actor.map.floodfill(self.actor.x, self.actor.y, 1000, True):
		#	self.actor.memory.update(x, y, scry_color_filter)
		
		for i, points in enumerate(actor.map.iter_floodfill(actor.x, actor.y, 20, True)):
			for (x, y) in points:
				actor.memory.update(x, y, scry_color_filter)
			
			draw_map(actor)
			
			for (x, y) in points:
				libtcod.console_set_back(0, x, y, libtcod.violet)
				libtcod.console_set_fore(0, x, y, libtcod.light_violet)
			
			libtcod.console_flush()
			libtcod.sys_sleep_milli(50)
		
		return True