Exemplo n.º 1
0
	
	if _old_size[2]>size[2]:
		for x1 in range(_old_size[0]):
			for y1 in range(_old_size[1]):
				for z in range(abs(_old_size[2]-size[2])):
					_new_map[x1][y1].pop()
	elif _old_size[2]<size[2]:
		for x1 in range(_old_size[0]):
			_y1 = []
			for y1 in range(abs(_old_size[1])):
				_z1 = []
				for z1 in range(abs(_old_size[2]-size[2])):
					_z1.append(None)
			
				_new_map[x1][y1].extend(_z1)
	
	return _new_map

if __name__ == '__main__':
	if '--create' in sys.argv:
		create_all_tiles()
		WORLD_INFO['map'] = maps.create_map()
		maps.create_position_maps()
		maps.update_chunk_map()
		
		zones.create_zone_map()
		zones.connect_ramps()
		
		maps.save_map('temp_map')
		
		print 'Created map: temp_map.dat'
Exemplo n.º 2
0
def handle_input():
	global PLACING_TILE,RUNNING,SETTINGS,KEYBOARD_STRING

	if gfx.window_is_closed():
		SETTINGS['running'] = False
		
		return True
	
	elif INPUT['\x1b'] or INPUT['q']:
		if not ACTIVE_MENU['menu'] == -1 and not SETTINGS['running'] == 1:
			ACTIVE_MENU['menu'] = -1
			
			return True
			
		SETTINGS['running'] = False
		
		return True
	
	elif INPUT['-']:
		if SETTINGS['draw console']:
			SETTINGS['draw console'] = False
		else:
			SETTINGS['draw console'] = True
	
	elif SETTINGS['draw console']:
		return

	elif INPUT['up']:
		if not ACTIVE_MENU['menu'] == -1:
			menus.move_up(MENUS[ACTIVE_MENU['menu']], MENUS[ACTIVE_MENU['menu']]['index'])
		else:
			CURSOR_POS[1] -= SETTINGS['cursor speed']

	elif INPUT['down']:
		if not ACTIVE_MENU['menu'] == -1:
			menus.move_down(MENUS[ACTIVE_MENU['menu']], MENUS[ACTIVE_MENU['menu']]['index'])
		else:
			CURSOR_POS[1] += SETTINGS['cursor speed']

	elif INPUT['right']:
		if not ACTIVE_MENU['menu'] == -1:
			menus.next_item(MENUS[ACTIVE_MENU['menu']],MENUS[ACTIVE_MENU['menu']]['index'])
			menus.item_changed(ACTIVE_MENU['menu'],MENUS[ACTIVE_MENU['menu']]['index'])
		else:
			CURSOR_POS[0] += SETTINGS['cursor speed']

	elif INPUT['left']:
		if not ACTIVE_MENU['menu'] == -1:
			menus.previous_item(MENUS[ACTIVE_MENU['menu']],MENUS[ACTIVE_MENU['menu']]['index'])
			menus.item_changed(ACTIVE_MENU['menu'],MENUS[ACTIVE_MENU['menu']]['index'])
		else:
			CURSOR_POS[0] -= SETTINGS['cursor speed']

	elif INPUT[' ']:
		menus.activate_menu_by_name('Buildings')
	
	elif INPUT['n']:
		for alife in LIFE:
			life.memory(alife, 'focus_on_chunk', chunk_key=life.get_current_chunk_id(LIFE[SETTINGS['controlling']]))
	
	elif INPUT['\r']:
		if ACTIVE_MENU['menu'] == -1:
			return False
		
		menus.item_selected(ACTIVE_MENU['menu'],MENUS[ACTIVE_MENU['menu']]['index'])
		ACTIVE_MENU['menu'] = -1
	
	elif INPUT['\t']:
		pass

	elif INPUT['c']:
		CURSOR_POS[0] = MAP_SIZE[0]/2
		CURSOR_POS[1] = MAP_SIZE[1]/2

	elif INPUT['m']:
		if SETTINGS['running'] == 2:
			gfx.add_view_to_scene_by_name('chunk_map')
			gfx.set_active_view('chunk_map')
			
			SETTINGS['running'] = 3
		elif SETTINGS['running'] == 3:
			gfx.remove_view_from_scene_by_name('chunk_map')
			gfx.set_active_view('map')
			SETTINGS['running'] = 2

	elif INPUT['r']:
		if regenerate_world():
			SETTINGS['running'] = 2

	elif INPUT['s']:
		items.save_all_items()
		
		gfx.title('Generating Chunk Map')
		maps.update_chunk_map()
		
		gfx.title('Zoning...')
		zones.create_zone_map()
		
		gfx.title('Saving...')
		maps.save_map(str(time.time()), only_cached=False)
		items.reload_all_items()

	elif INPUT['l']:
		SUN_BRIGHTNESS[0] += 4
	
	elif INPUT['k']:
		SUN_BRIGHTNESS[0] -= 4

	elif INPUT['1']:
		CAMERA_POS[2] = 1
		gfx.refresh_view('map')

	elif INPUT['2']:
		CAMERA_POS[2] = 2
		gfx.refresh_view('map')

	elif INPUT['3']:
		CAMERA_POS[2] = 3
		gfx.refresh_view('map')

	elif INPUT['4']:
		CAMERA_POS[2] = 4
		gfx.refresh_view('map')

	elif INPUT['5']:
		CAMERA_POS[2] = 5
		gfx.refresh_view('map')
	
	elif INPUT['6']:
		CAMERA_POS[2] = 6
		gfx.refresh_view('map')
	
	elif INPUT['7']:
		CAMERA_POS[2] = 7
		gfx.refresh_view('map')
	
	elif INPUT['8']:
		CAMERA_POS[2] = 8
		gfx.refresh_view('map')
	
	elif INPUT['9']:
		CAMERA_POS[2] = 9
		gfx.refresh_view('map')
	
	elif INPUT['0']:
		CAMERA_POS[2] = 0
		gfx.refresh_view('map')
Exemplo n.º 3
0
    if _old_size[2] > size[2]:
        for x1 in range(_old_size[0]):
            for y1 in range(_old_size[1]):
                for z in range(abs(_old_size[2] - size[2])):
                    _new_map[x1][y1].pop()
    elif _old_size[2] < size[2]:
        for x1 in range(_old_size[0]):
            _y1 = []
            for y1 in range(abs(_old_size[1])):
                _z1 = []
                for z1 in range(abs(_old_size[2] - size[2])):
                    _z1.append(None)

                _new_map[x1][y1].extend(_z1)

    return _new_map


if __name__ == '__main__':
    if '--create' in sys.argv:
        create_all_tiles()
        WORLD_INFO['map'] = maps.create_map()
        maps.create_position_maps()
        maps.update_chunk_map()

        zones.create_zone_map()
        zones.connect_ramps()

        maps.save_map('temp_map')

        print 'Created map: temp_map.dat'
Exemplo n.º 4
0
def handle_input():
    global PLACING_TILE, RUNNING, SETTINGS, KEYBOARD_STRING

    if gfx.window_is_closed():
        SETTINGS['running'] = False

        return True

    elif INPUT['\x1b'] or INPUT['q']:
        if not ACTIVE_MENU['menu'] == -1 and not SETTINGS['running'] == 1:
            ACTIVE_MENU['menu'] = -1

            return True

        SETTINGS['running'] = False

        return True

    elif INPUT['-']:
        if SETTINGS['draw console']:
            SETTINGS['draw console'] = False
        else:
            SETTINGS['draw console'] = True

    elif SETTINGS['draw console']:
        return

    elif INPUT['up']:
        if not ACTIVE_MENU['menu'] == -1:
            menus.move_up(MENUS[ACTIVE_MENU['menu']],
                          MENUS[ACTIVE_MENU['menu']]['index'])
        else:
            CURSOR_POS[1] -= SETTINGS['cursor speed']

    elif INPUT['down']:
        if not ACTIVE_MENU['menu'] == -1:
            menus.move_down(MENUS[ACTIVE_MENU['menu']],
                            MENUS[ACTIVE_MENU['menu']]['index'])
        else:
            CURSOR_POS[1] += SETTINGS['cursor speed']

    elif INPUT['right']:
        if not ACTIVE_MENU['menu'] == -1:
            menus.next_item(MENUS[ACTIVE_MENU['menu']],
                            MENUS[ACTIVE_MENU['menu']]['index'])
            menus.item_changed(ACTIVE_MENU['menu'],
                               MENUS[ACTIVE_MENU['menu']]['index'])
        else:
            CURSOR_POS[0] += SETTINGS['cursor speed']

    elif INPUT['left']:
        if not ACTIVE_MENU['menu'] == -1:
            menus.previous_item(MENUS[ACTIVE_MENU['menu']],
                                MENUS[ACTIVE_MENU['menu']]['index'])
            menus.item_changed(ACTIVE_MENU['menu'],
                               MENUS[ACTIVE_MENU['menu']]['index'])
        else:
            CURSOR_POS[0] -= SETTINGS['cursor speed']

    elif INPUT[' ']:
        menus.activate_menu_by_name('Buildings')

    elif INPUT['n']:
        for alife in LIFE:
            life.memory(alife,
                        'focus_on_chunk',
                        chunk_key=life.get_current_chunk_id(
                            LIFE[SETTINGS['controlling']]))

    elif INPUT['\r']:
        if ACTIVE_MENU['menu'] == -1:
            return False

        menus.item_selected(ACTIVE_MENU['menu'],
                            MENUS[ACTIVE_MENU['menu']]['index'])
        ACTIVE_MENU['menu'] = -1

    elif INPUT['\t']:
        pass

    elif INPUT['c']:
        CURSOR_POS[0] = MAP_SIZE[0] / 2
        CURSOR_POS[1] = MAP_SIZE[1] / 2

    elif INPUT['m']:
        if SETTINGS['running'] == 2:
            gfx.add_view_to_scene_by_name('chunk_map')
            gfx.set_active_view('chunk_map')

            SETTINGS['running'] = 3
        elif SETTINGS['running'] == 3:
            gfx.remove_view_from_scene_by_name('chunk_map')
            gfx.set_active_view('map')
            SETTINGS['running'] = 2

    elif INPUT['r']:
        if regenerate_world():
            SETTINGS['running'] = 2

    elif INPUT['s']:
        items.save_all_items()

        gfx.title('Generating Chunk Map')
        maps.update_chunk_map()

        gfx.title('Zoning...')
        zones.create_zone_map()

        gfx.title('Saving...')
        maps.save_map(str(time.time()), only_cached=False)
        items.reload_all_items()

    elif INPUT['l']:
        SUN_BRIGHTNESS[0] += 4

    elif INPUT['k']:
        SUN_BRIGHTNESS[0] -= 4

    elif INPUT['1']:
        CAMERA_POS[2] = 1
        gfx.refresh_view('map')

    elif INPUT['2']:
        CAMERA_POS[2] = 2
        gfx.refresh_view('map')

    elif INPUT['3']:
        CAMERA_POS[2] = 3
        gfx.refresh_view('map')

    elif INPUT['4']:
        CAMERA_POS[2] = 4
        gfx.refresh_view('map')

    elif INPUT['5']:
        CAMERA_POS[2] = 5
        gfx.refresh_view('map')

    elif INPUT['6']:
        CAMERA_POS[2] = 6
        gfx.refresh_view('map')

    elif INPUT['7']:
        CAMERA_POS[2] = 7
        gfx.refresh_view('map')

    elif INPUT['8']:
        CAMERA_POS[2] = 8
        gfx.refresh_view('map')

    elif INPUT['9']:
        CAMERA_POS[2] = 9
        gfx.refresh_view('map')

    elif INPUT['0']:
        CAMERA_POS[2] = 0
        gfx.refresh_view('map')