예제 #1
0
 def __init__(self,
              name,
              displayAutomatically=False):
     inventory = InventoryManager(on=False,
                                  under=False,
                                  inside=True)
     Human.__init__(self,
                    name=name,
                    displayAutomatically=displayAutomatically,
                    inventory=inventory,
                    recurseAutomatically=False,
                    displayName='handsome looking gentleman')
예제 #2
0
    def generate(self):
        world_size = 50
        sea_level = 0.35
        ocean_end = 0.7 * sea_level
        beach_end = 0.4
        grass_end = 0.75
        mountain_end = 0.9

        tree_chance = 0.35
        print("generate() - generating terrain noise")
        terrain_noise_matrix = World.new_noise_matrix(world_size, octaves=4)
        print("generate() - generating decorations noise")
        decorations_noise_matrix = World.new_noise_matrix(world_size,
                                                          octaves=8)
        print(f"generate() - placing tiles")

        for x in range(world_size):
            for y in range(world_size):
                terrain_noise = terrain_noise_matrix[x][y]
                if terrain_noise < ocean_end:
                    t = tile.Ocean(self, (x, y))
                elif terrain_noise < sea_level:
                    t = tile.Coast(self, (x, y))
                elif terrain_noise < beach_end:
                    t = tile.Sand(self, (x, y))
                elif terrain_noise < grass_end:
                    if decorations_noise_matrix[x][y] < tree_chance:
                        t = tile.Tree(self, (x, y))
                    else:
                        t = tile.Grass(self, (x, y))
                elif terrain_noise < mountain_end:
                    t = tile.Mountain(self, (x, y))
                else:
                    t = tile.Snow(self, (x, y))

                t.name = f"{t.name} {terrain_noise}"

        print("generate() - spawning player")
        Human(self, (25, 25))
        Human(self, (26, 25))
        Human(self, (25, 26))
        self.camera_pos = 444, 444
        print("generate() - done")
예제 #3
0
    def __init__(self):
        self.done = False
        self.world = World()

        self.ambient = pygame.mixer.Sound("audio/generic_ambient1.wav")        
        self.ambient.play(-1)
        
        self.fire_images = []
        self.hare_images_rf = []
        self.water_images = []

        self.player = MusicPlayer()       
        self.wait_for_song = 1200
        self.music_playing = False

        self.hare_timer = 1.0
        self.hare_timer_add = 1.0
        
        self.fire_timer = 1.0
        self.fire_timer_add = 1.0

        for i in xrange(3):
            filename = "images/fire%i.png" % (i+1)
            image = pygame.image.load(filename).convert_alpha()
            self.fire_images.append(image)

        for i in xrange(2):
            filename = "images/hare%i.png" % (i+1)
            image = pygame.image.load(filename).convert_alpha()
            self.hare_images_rf.append(image)

        for i in xrange(2):
            filename = "images/water%i.png" % (i+1)
            image = pygame.image.load(filename).convert_alpha()
            self.water_images.append(image)

        self.hare_images_lf = map(lambda i: pygame.transform.flip(i, 1, 0), self.hare_images_rf)

        self.humans = []
        self.viewports = []
        
        loader = ImageStripLoader("images/hunger_strip.png")
        self.world.hunger_images = []
        self.world.hunger_images = loader.images_from_coordinates((
            (0,0,64,64),(64,0,64,64),(128,0,64,64),(192,0,64,64),(256,0,64,64),(320,0,64,64),
        ))
        loader = ImageStripLoader("images/thirst_strip.png")
        self.world.thirst_images = []
        self.world.thirst_images = loader.images_from_coordinates((
            (0,0,64,64),(64,0,64,64),(128,0,64,64),(192,0,64,64),(256,0,64,64),(320,0,64,64),
        ))
        loader = ImageStripLoader("images/warmth_strip.png")
        self.world.warmth_images = []
        self.world.warmth_images = loader.images_from_coordinates((
            (0,0,64,64),(64,0,64,64),(128,0,64,64),(192,0,64,64),(256,0,64,64),(320,0,64,64),
        ))

        for human_count in xrange(2):
            human_red = Human(self.world, human_count+1)
            human_red.location = self.get_safe_spot()
            self.world.add_entity(human_red)
            self.humans.append(human_red)
            offset = human_count*SCREEN_SIZE[0]/2+1
            r = pygame.Rect(offset, 0, SCREEN_SIZE[0]/2-1, SCREEN_SIZE[1])
            viewport = Viewport(r, human_red)
            self.viewports.append(viewport)

        for fire_count in xrange(randint(10,50)):
            fire = Fire(self.world, self.fire_images)
            fire.location = self.get_safe_spot()
            self.world.add_entity(fire)
            self.world.fire_count += 1

        for water_count in xrange(randint(5, 10)):
            water = Water(self.world, self.water_images)
            water.location = self.get_safe_spot()
            self.world.add_entity(water)
            self.world.hare_count += 1