Beispiel #1
0
def session_console():
    libtcodpy.console_set_custom_font(FONT_FILE)
    console = libtcodpy.console_init_root(WIDTH, HEIGHT, TITLE, FULLSCREEN, RENDERER)

    assert libtcodpy.console_get_width(console) == WIDTH
    assert libtcodpy.console_get_height(console) == HEIGHT
    assert libtcodpy.console_is_fullscreen() == FULLSCREEN
    libtcodpy.console_set_window_title(TITLE)
    assert not libtcodpy.console_is_window_closed()

    libtcodpy.sys_get_current_resolution()
    libtcodpy.sys_get_char_size()
    libtcodpy.sys_set_renderer(RENDERER)
    libtcodpy.sys_get_renderer()

    yield console
    libtcodpy.console_delete(console)
Beispiel #2
0
	if mouse.lbutton_pressed:
		x = mouse.x/FONT_WIDTH
		y = mouse.y/FONT_HEIGHT
	
	if mouse.rbutton_pressed:
		x = mouse.x/FONT_WIDTH
		y = mouse.y/FONT_HEIGHT
	
	# key handler
	player.control(key.vk)

	if key.vk == libtcod.KEY_ENTER and key.lalt:
		libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
	elif key.vk == libtcod.KEY_PRINTSCREEN or key.c == 'p':
		print ("screenshot")
		if key.lalt :
			libtcod.console_save_apf(None,"samples.apf")
			print ("apf")
		else :
			libtcod.sys_save_screenshot()
			print ("png")
	elif key.vk == libtcod.KEY_ESCAPE:
		break
	elif key.vk == libtcod.KEY_F1:
		libtcod.sys_set_renderer(libtcod.RENDERER_GLSL)
	elif key.vk == libtcod.KEY_F2:
		libtcod.sys_set_renderer(libtcod.RENDERER_OPENGL)
	elif key.vk == libtcod.KEY_F3:
		libtcod.sys_set_renderer(libtcod.RENDERER_SDL)
	libtcod.console_flush()
Beispiel #3
0
    def __init__(self, content, logger, key_set):
##============================================================================
        self.version = '0.0.1a'
        self.objects = []
        self.logger = logger
        self.logger.log.info('Init Game and Game Screen.')
        self.debug_level = 'debug'  # prints errors verbosely to the game screen
                                    # On release, just a confirmation menu
                                    # Also affects the use of the python interpreter
                                    # in the console, disabled on release

        '''try:
            self.logger.log.debug('Init gEngine...')
            import cEngine as gEngine  # Try importing the pyd
            self.logger.log.debug('gEngine pyd/so imported')
        except ImportError, err:  # if that fails, import the python prototype
            sys.path.append(os.path.join(sys.path[0], 'gEngine'))
            self.logger.log.debug('gEngine pyd/so import failed, using python prototype')
            self.logger.log.exception(err)
            import gEngine.gEngine as gEngine'''
        import gEngine.gEngine as gEngine
            
        try:
            self.logger.log.debug("Importing Psyco.")
            import psyco
            psyco.full()
            psyco.log()
            psyco.profile()
            self.logger.log.debug('Psyco full used.')
        except ImportError:
            self.logger.log.debug("Importing Psyco failed.")
            pass

        #libtcod.console_set_keyboard_repeat(250,250)
        self.gEngine = gEngine.gEngine(SCREEN_WIDTH, SCREEN_HEIGHT, 'Ascension 0.0.1a', False, LIMIT_FPS)
        try:
            font = os.path.join(sys.path[0], 'terminal10x10_gs_tc.png')
            self.gEngine.console_set_custom_font(font, libtcod.FONT_LAYOUT_TCOD | libtcod.FONT_TYPE_GREYSCALE)
        except:
            pass
        self.gEngine.init_root()
        self.con = self.gEngine.console_new(MAP_WIDTH, MAP_HEIGHT)
        self.panel = self.gEngine.console_new(SCREEN_WIDTH, PANEL_HEIGHT)

        self.toolbar = self.gEngine.console_new(SCREEN_WIDTH, 5)

        x = 32/2
        x = SCREEN_WIDTH/2 - x
        self.hotbar = HotBar(x, 0, self.gEngine, self.toolbar)
        z=1
        index = ord('1')
        for i in range(10):
            if index == ord(':'):
                index = ord('0')
            s = HotBarSlot(None, z+x, PANEL_Y-4, z, chr(index), self.gEngine)
            self.hotbar.add_slot(s)
            z += 3
            index += 1
        self.message = Message(self.panel, MSG_HEIGHT, MSG_WIDTH, MSG_X, self.logger, self.debug_level)
        self.build_objects = GameObjects(content)        
        self.ticker = Ticker()
        
        self.Map = map.Map(MAP_HEIGHT, MAP_WIDTH, ROOM_MIN_SIZE, ROOM_MAX_SIZE,
            MAX_ROOMS, MAX_ROOM_MONSTERS, MAX_ROOM_ITEMS, self.logger)

        self.keys = key_set
        self.setup_keys()
        self.current_dungeon = []  # an array that holds all off the dungeon levels
        #self.console = console.Console(self, SCREEN_WIDTH-2, SCREEN_HEIGHT/2, self.debug_level)
        self.depth = None
        self.game_state = None
        self.dev_mode = dev_mode.DevMode(self.gEngine, self.Map)

        #libtcod.console_set_keyboard_repeat(50, 50)
        libtcod.sys_set_renderer(libtcod.RENDERER_GLSL)
            if self.player_ship.laser_firing:
                self.player_ship.fire_laser()

            if self.player_ship.reversing:
                self.player_ship.reverse_direction()
            elif self.player_ship.turning_left:
                self.player_ship.turn_left()
            elif self.player_ship.turning_right:
                self.player_ship.turn_right()

if __name__ == '__main__':
    # libtcod setup

    libtcod.sys_set_fps(60)
    libtcod.sys_set_renderer(libtcod.RENDERER_GLSL)
    # libtcod.sys_set_renderer(libtcod.RENDERER_OPENGL)
    # libtcod.sys_set_renderer(libtcod.RENDERER_SDL)
    libtcod.console_set_keyboard_repeat(1, 10)

    # libtcod.console_set_custom_font('fonts/8x8_limited.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW, nb_char_horiz=16, nb_char_vertic=16)
    # game = Game(160, 90)

    # libtcod.console_set_custom_font('fonts/10x10_limited.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW, nb_char_horiz=16, nb_char_vertic=16)
    # game = Game(128, 72)

    libtcod.console_set_custom_font('fonts/12x12_limited.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW, nb_char_horiz=16, nb_char_vertic=16)
    game = Game(106, 60)

    game.main_loop()
Beispiel #5
0
MSG_WIDTH = GAME_WIDTH
MSG_HEIGHT = SCREEN_HEIGHT - GAME_HEIGHT - 1

LIMIT_FPS = 40

noise1d = libtcod.noise_new(1)

font = os.path.join('data', 'fonts', 'dejavu12x12_gs_tc.png')
libtcod.console_set_custom_font(font, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)

torchconst = 0.0

libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Rogue Operative', False)
libtcod.sys_set_fps(LIMIT_FPS)
libtcod.sys_set_renderer(libtcod.RENDERER_SDL) # stick with SDL for now until other renderers are more stable

viewport = console(GAME_WIDTH,GAME_HEIGHT,0,0)
libtcod.console_set_default_foreground(viewport.con, libtcod.white)

message = console(MSG_WIDTH, MSG_HEIGHT,0,GAME_HEIGHT+1)
libtcod.console_set_default_foreground(message.con, libtcod.white)


# organizing the root console
libtcod.console_set_default_foreground(0, libtcod.white)
for y in range(GAME_HEIGHT):
    libtcod.console_print_ex(0, GAME_WIDTH, y, libtcod.BKGND_NONE, libtcod.LEFT, '|')
for x in range(GAME_WIDTH):
    libtcod.console_print_ex(0, x, GAME_HEIGHT, libtcod.BKGND_NONE, libtcod.LEFT, '_')
libtcod.console_print_ex(0,GAME_WIDTH,GAME_HEIGHT,libtcod.BKGND_NONE, libtcod.LEFT, '/')