Example #1
0
def regenerate_world(build_test=False):
    gfx.title('Generating...')

    reload(mapgen)

    if build_test:
        mapgen.create_buildings()

    pre_setup_world()

    try:
        mapgen.generate_map(towns=1,
                            factories=0,
                            outposts=2,
                            forests=1,
                            skip_zoning=True,
                            skip_chunking=True,
                            hotload=True,
                            build_test=build_test)
    except:
        import traceback
        traceback.print_exc()
        SETTINGS['running'] = 1

        return False

    post_setup_world()
    gfx.refresh_view('map')

    return True
Example #2
0
def regenerate_world(build_test=False):
	gfx.title('Generating...')
	
	reload(mapgen)
	
	if build_test:
		mapgen.create_buildings()
	
	pre_setup_world()
	
	try:
		mapgen.generate_map(towns=1,
			                factories=0,
			                outposts=2,
			                forests=1,
			                skip_zoning=True,
			                skip_chunking=True,
			                hotload=True,
		                     build_test=build_test)
	except:
		import traceback
		traceback.print_exc()
		SETTINGS['running'] = 1
		
		return False
	
	post_setup_world()
	gfx.refresh_view('map')
	
	return True
Example #3
0
def regenerate_world():
	gfx.title('Generating...')
	reload(mapgen)
	
	pre_setup_world()
	
	try:
		mapgen.generate_map(size=(450, 450, 10),
			                towns=1,
			                factories=0,
			                outposts=2,
			                forests=1,
			                skip_zoning=True,
			                skip_chunking=True,
			                hotload=True)
	except:
		import traceback
		traceback.print_exc()
		
		SETTINGS['running'] = 1
		return False
	
	post_setup_world()
	gfx.refresh_view('map')
	
	return True
Example #4
0
def init_game():
    turn_state = TurnState()
    game_map = Map(MAX_MAP_WIDTH, MAX_MAP_HEIGHT)
    generate_map(game_map)
    map_knowledge = MapKnowledge(game_map)
    game_map.init_los()

    place_player(game_map)

    return turn_state, game_map, map_knowledge
Example #5
0
 def new_game(self):
     gen = mazegen.MazeGenerator(*self.vars["mapsize"])
     gen.create2()
     gen.pprint(prettier=True)
     self.vars["maze"] = gen.data
     self.vars["player_mazepos"] = gen.start_pos
     self.vars["map"] = [[None for _ in range(gen.width)]
                         for _ in range(gen.height)]
     mapgen.generate_map(self.vars["map"], gen)
     start_level = self.vars["map"][gen.start_pos[1]][gen.start_pos[0]]
     return start_level
Example #6
0
def new_game():
    global player, alive, state, current_turn
    starting_items = ui.item_choice_menu()
    if starting_items is None:
        # player closed window during starting item dialog
        return
    terrain.map = mapgen.generate_map()

    pos = terrain.map.player_start_pos
    player = mob.Player(pos)
    for i in starting_items:
        player.get(i((0, 0)))

    # terrain.map.init_fov_and_pathfinding()

    for i in range(50):
        update_objects()

    terrain.map.objects.append(player)
    ui.clear_messages()

    render.init()
    compute_fov()
    render.draw_all_tiles()

    alive = True
    state = 'playing'

    current_turn = 1

    ui.message(
        'Good job! You managed to sneak into the fortress of the dwarves and nabbed a priceless artifact while the dwarves were busy repelling a seige. Unfortunately, your escape route is now encased in battle! Can you navigate 200 tiles of mayhem?')
Example #7
0
def generate_world(combat_test=False):
    _menu = MENUS[menus.get_menu_by_name('World Generation')]
    _settings = {}

    for entry in _menu['menu']:
        _settings[entry['key']] = entry['values'][entry['value']]

    if _settings['Map'] == 'Generate Map':
        _settings['Map'] = mapgen.generate_map(towns=1,
                                               factories=0,
                                               outposts=2,
                                               forests=1)['name']

    if _settings['World Age'] == 'Day 0':
        _ticks = 10
    elif _settings['World Age'] == '1 Week':
        _ticks = 1000  #30000
    elif _settings['World Age'] == '2 Weeks':
        _ticks = 2000
    elif _settings['World Age'] == '3 Weeks':
        _ticks = 3000
    elif _settings['World Age'] == '4 Weeks':
        _ticks = 4000
    elif _settings['World Age'] == '5 Weeks':
        _ticks = 5000

    maps.load_map(_settings['Map'], cache_map=True)

    worldgen.generate_world(WORLD_INFO['map'],
                            dynamic_spawns=_settings['Dynamic Spawns'],
                            wildlife_spawns=_settings['Wildlife Density'],
                            simulate_ticks=_ticks,
                            save=True,
                            thread=True)
Example #8
0
def generate_world(combat_test=False):
	_menu = MENUS[menus.get_menu_by_name('World Generation')]
	_settings = {}
	
	for entry in _menu['menu']:
		_settings[entry['key']] = entry['values'][entry['value']]
	
	if _settings['Map'] == 'Generate Map':
		_settings['Map'] = mapgen.generate_map(towns=1,
		                                       factories=0,
		                                       outposts=2,
		                                       forests=1)['name']
	
	if _settings['World Age'] == 'Day 0':
		_ticks = 10
	elif _settings['World Age'] == '1 Week':
		_ticks = 1000#30000
	elif _settings['World Age'] == '2 Weeks':
		_ticks = 2000
	elif _settings['World Age'] == '3 Weeks':
		_ticks = 3000
	elif _settings['World Age'] == '4 Weeks':
		_ticks = 4000
	elif _settings['World Age'] == '5 Weeks':
		_ticks = 5000
	
	maps.load_map(_settings['Map'], cache_map=True)
	
	worldgen.generate_world(WORLD_INFO['map'],
		dynamic_spawns=_settings['Dynamic Spawns'],
		wildlife_spawns=_settings['Wildlife Density'],
		simulate_ticks=_ticks,
		save=True,
		thread=True)
Example #9
0
def new_game():
    global player, alive, state, current_turn
    starting_items = ui.item_choice_menu()
    if starting_items is None:
        #player closed window during starting item dialog
        return
    terrain.map = mapgen.generate_map()

    (x, y) = terrain.map.player_start_pos
    terrain.map[x][y] = terrain.Floor()
    player = mob.Player((x, y))
    for i in starting_items:
        player.get(i((0, 0)))

    terrain.map.init_fov_and_pathfinding()

    for i in range(50):
        randomly_spawn_enemies()
        update_objects()

    terrain.map.mobs.append(player)
    ui.clear_messages()

    render.init()
    compute_fov()
    render.draw_all_tiles()

    alive = True
    state = 'playing'

    current_turn = 1

    ui.message('For this mission something something you need to get to the other side of this battlefield! Go 100 tiles to the right!')
Example #10
0
def test_generate_map():

    # list may look inflated, but the output map is scaled.

    expected_list = [[(0, 0, 0)]]

    actual_list = mapgen.generate_map(os.path.join(TEST_FOLDER,
                                                   "test_img.png"))

    assert repr(actual_list) == repr(expected_list)
    def load_data(self):
        self.player_img = pg.image.load(
            os.path.join(SPRITE_FOLDER, "paddle.png")).convert_alpha()
        self.player_img = pg.transform.scale(self.player_img,
                                             (PADDLE_WIDTH, PADDLE_HEIGHT))
        self.ball_img = pg.image.load(os.path.join(SPRITE_FOLDER, "ball.png"))
        self.ball_img = pg.transform.scale(self.ball_img,
                                           (BALL_SIZE, BALL_SIZE))
        self.block_img = pg.image.load(os.path.join(SPRITE_FOLDER,
                                                    "block.png"))
        self.block_img = pg.transform.scale(self.block_img,
                                            (TILESIZE, TILESIZE))

        self.map_data = generate_map(LEVEL)
        self.bigfont = pg.font.SysFont('symeteoiv50', 40)
        self.smallfont = pg.font.SysFont('symeteoiv50', 30)
Example #12
0
    def __init__(self, level):
        self.tiles = generate_map(level)
        self.level = level

        self.player = None
        self.mobs = []

        self.fov_map = T.map_new(MAP_W, MAP_H)
        for x in range(MAP_W):
            for y in range(MAP_H):
                tile = self.tiles[x][y]
                T.map_set_properties(self.fov_map,
                                           x, y,
                                           tile.transparent,
                                           tile.walkable)

        self.populate()
        if self.level == MAX_DLEVEL:
            self.place_monsters(Boss)
Example #13
0
    elif config.cornerpoint[0] > config.mapsize[0] - int(config.screensize[0]/64+1):
        config.cornerpoint[0] = config.mapsize[0] - int(config.screensize[0]/64+1)
        scrollx = 0
    if config.cornerpoint[1] < 0:
        config.cornerpoint[1] = 0
        scrolly = 0
    elif config.cornerpoint[1] > config.mapsize[1] - int(config.screensize[1]/64+2):
        config.cornerpoint[1] = config.mapsize[1] - int(config.screensize[1]/64+2)
        scrolly = 0    

# Initialise screen
pygame.init()
screen = pygame.display.set_mode((config.screensize[0], config.screensize[1]), FULLSCREEN)

#-----------------Get maparray, load gfx and prepare surfaces ---------------------
themap,minimap = mapgen.generate_map(random.randint(1,1000000),(config.mapsize[0],config.mapsize[1]))
minimapcopy=minimap.copy()

water = spritesheet("graphics/water.png")
grass = spritesheet("graphics/grass.png")
rock  = spritesheet("graphics/rock.png")  
tiletextures = [water.load_strip((0,0,64,64),16,(255,255,255)),grass.load_strip((0,0,64,64),16,(255,255,255)),rock.load_strip((0,0,64,64),18,(255,255,255))] 
terrain = pygame.Surface((config.screensize[0]+128,config.screensize[1]+128))

clock = pygame.time.Clock()
startpos = (10,10)

config.cornerpoint = [0,0]

allgroup = pygame.sprite.Group()