Exemplo n.º 1
0
    def __init__(self, x, y):
        super().__init__(True, 3)
        """ Load all images of Wolf"""
        self.stand_r = sprites.load_sprite('image/Monster/Wolf/stand/', 4)
        self.stand_l = sprites.hori_flip_sprite('image/Monster/Wolf/stand/', 4)
        self.attack_r = sprites.load_sprite('image/Monster/Wolf/attack/', 7)
        self.attack_l = sprites.hori_flip_sprite('image/Monster/Wolf/attack/',
                                                 7)
        self.death_r = sprites.load_sprite('image/Monster/Wolf/death/', 9)
        self.death_l = sprites.hori_flip_sprite('image/Monster/Wolf/death/', 9)
        self.run_r = sprites.load_sprite('image/Monster/Wolf/run/', 6)
        self.run_l = sprites.hori_flip_sprite('image/Monster/Wolf/run/', 6)
        self.beaten_r = sprites.load_sprite('image/Monster/Wolf/beaten/1/', 3)
        self.beaten_l = sprites.hori_flip_sprite(
            'image/Monster/Wolf/beaten/1/', 3)
        self.true_attack = [self.attack_r[4], self.attack_l[4]]

        # Get image
        self.image = self.stand_r[0]
        # Get rect
        self.rect = self.image.get_rect()
        self.size = self.image.get_size()
        self.rect.x = x
        self.rect.y = y
        self.max_HP = 120
        self.current_HP = 100
        self.damage = 15
Exemplo n.º 2
0
 def __init__(self, x, y):
     super().__init__(True, 1)
     """ Load all image of male zombie"""
     self.stand_r = sprites.load_sprite('image/Monster/Male_Zombie/stand/',
                                        10)
     self.stand_l = sprites.hori_flip_sprite(
         'image/Monster/Male_Zombie/stand/', 10)
     self.attack_r = sprites.load_sprite(
         'image/Monster/Male_Zombie/attack/', 9)
     self.attack_l = sprites.hori_flip_sprite(
         'image/Monster/Male_Zombie/attack/', 9)
     self.death_r = sprites.load_sprite('image/Monster/Male_Zombie/death/',
                                        7)
     self.death_l = sprites.hori_flip_sprite(
         'image/Monster/Male_Zombie/death/', 7)
     self.run_r = sprites.load_sprite('image/Monster/Male_Zombie/move/', 20)
     self.run_l = sprites.hori_flip_sprite(
         'image/Monster/Male_Zombie/move/', 20)
     self.beaten_r = sprites.load_sprite(
         'image/Monster/Male_Zombie/beaten/', 3)
     self.beaten_l = sprites.hori_flip_sprite(
         'image/Monster/Male_Zombie/beaten/', 3)
     self.true_attack = [self.attack_r[4], self.attack_l[4]]
     # Get image
     self.image = self.stand_r[0]
     # Get rect
     self.rect = self.image.get_rect()
     self.size = self.image.get_size()
     self.rect.x = x
     self.rect.y = y
     self.max_HP = 150
     self.current_HP = 100
     self.damage = 10
Exemplo n.º 3
0
 def __init__(self):
     """ Constructor function"""
     # Call the parent's constructor
     pygame.sprite.Sprite.__init__(self)
     """ Load all image of the player"""
     # Load all the standing images
     self.stand_r = sprites.load_sprite('image/Player/stand/', 6)
     self.stand_l = sprites.hori_flip_sprite('image/Player/stand/', 6)
     # Load all the running images
     self.run_r = sprites.load_sprite('image/Player/run/', 8)
     self.run_l = sprites.hori_flip_sprite('image/Player/run/', 8)
     # Load all the jumping images
     self.jump_r = [
         sprites.load_sprite('image/Player/jump1/', 1),
         sprites.load_sprite('image/Player/jump2/', 5)
     ]
     self.jump_l = [
         sprites.hori_flip_sprite('image/Player/jump1/', 1),
         sprites.hori_flip_sprite('image/Player/jump2/', 5)
     ]
     # Load all the falling images
     self.fall_r = [
         sprites.load_sprite('image/Player/fall1/', 3),
         sprites.load_sprite('image/Player/fall2/', 3)
     ]
     self.fall_l = [
         sprites.hori_flip_sprite('image/Player/fall1/', 3),
         sprites.hori_flip_sprite('image/Player/fall2/', 3)
     ]
     # Load all the attack images
     self.normal_attack_r = [
         sprites.load_sprite('image/Player/attack/normal_attack_1/', 4),
         sprites.load_sprite('image/Player/attack/normal_attack_2/', 4),
         sprites.load_sprite('image/Player/attack/normal_attack_3/', 7)
     ]
     self.normal_attack_l = [
         sprites.hori_flip_sprite('image/Player/attack/normal_attack_1/',
                                  4),
         sprites.hori_flip_sprite('image/Player/attack/normal_attack_2/',
                                  4),
         sprites.hori_flip_sprite('image/Player/attack/normal_attack_3/', 7)
     ]
     self.beaten_r = sprites.load_sprite('image/Player/beaten/', 5)
     self.beaten_l = sprites.hori_flip_sprite('image/Player/beaten/', 5)
     self.true_attack = [
         self.normal_attack_l[0][1], self.normal_attack_r[0][1],
         self.normal_attack_l[1][1], self.normal_attack_r[1][1],
         self.normal_attack_l[2][2], self.normal_attack_r[2][2]
     ]
     self.image = self.stand_r[0]
     # Get rectangle surrounding image, we will calculate its coordinates
     self.rect = self.image.get_rect()
     # Get size of image
     self.size = self.image.get_size()
Exemplo n.º 4
0
 def __init__(self, x, y):
     """ Constructor function"""
     Item.__init__(self)
     self.images = sprites.load_sprite('image/Coins/Style 2/', 6)
     self.image = self.images[0]
     self.rect = self.image.get_rect()
     self.rect.x = x
     self.rect.y = y
Exemplo n.º 5
0
 def load_platforms():
     platform_images = [
         load_sprite("plat1.png"),
         load_sprite("plat2.png"),
         load_sprite("plat3.png"),
         load_sprite("plat4.png"),
         load_sprite("plat5.png"),
         load_sprite("plat6.png"),
         load_sprite("plat7.png"),
         load_sprite("plat8.png")
     ]
     return platform_images
Exemplo n.º 6
0
    def __init__(self,
                 width=900,
                 height=650,
                 config=None,
                 display_screen=True):
        pygame.display.init()
        pygame.mixer.pre_init(44100, -16, 2, 512)
        pygame.init()

        self.display_screen = display_screen

        if config is None:
            config = {
                "enemy_count": 2,
                "max_speed": 10,
                "initial_lives": 1,
            }
        self.config = config

        self.p1_actions = {
            "p1_up": K_w,
            "p1_left": K_a,
            "p1_right": K_d,
            "p1_noop": K_F5
        }

        self.p2_actions = {
            "p2_up": K_i,
            "p2_left": K_j,
            "p2_right": K_l,
            "p2_noop": K_F15
        }

        actions = {}
        actions.update(self.p1_actions)
        actions.update(self.p2_actions)

        base.PyGameWrapper.__init__(self, width, height, actions=actions)

        self.rng = np.random.RandomState(24)
        self.screen = pygame.display.set_mode(self.getScreenDims(), 0, 32)
        self.clear_surface = self.screen.copy()

        self.player1 = Player(1,
                              self,
                              initial_lives=self.config['initial_lives'])
        self.player2 = Player(2,
                              self,
                              initial_lives=self.config['initial_lives'])

        self.rewards = {
            "positive": 10.0,
            "tick": 0.0,
            "defect": 5,
            "cooperative": 20,
            "negative": -5,
            "win": 0,
            "loss": 0,
        }

        # init sprites
        self._sprites = {
            'digits': load_sliced_sprites(21, 21, "digits.png"),
            'red_digits': load_sliced_sprites(21, 21, 'red_digits.png'),
            'life': load_sprite("life.png", convert_alpha=True),
        }
Exemplo n.º 7
0
import sprites


def DEPRECATED_create_grid():
    new_grid = []
    new_grid = [[0] * constants.GAME_HEIGHT_TILES
                for n in range(constants.GAME_WIDTH_TILES)]
    for x in range(5, 15):
        for y in range(5, 15):
            new_grid[x][y] = 1

    return new_grid


wall_tiles = {
    "H": sprites.load_sprite(0, 23, constants.WHITE),
    "V": sprites.load_sprite(1, 23, constants.WHITE),
    "X": sprites.load_sprite(2, 23, constants.WHITE),
    "RD": sprites.load_sprite(3, 23, constants.WHITE),
    "LD": sprites.load_sprite(4, 23, constants.WHITE),
    "RU": sprites.load_sprite(5, 23, constants.WHITE),
    "LU": sprites.load_sprite(6, 23, constants.WHITE),
    "TR": sprites.load_sprite(7, 23, constants.WHITE),
    "TL": sprites.load_sprite(8, 23, constants.WHITE),
    "TD": sprites.load_sprite(9, 23, constants.WHITE),
    "TU": sprites.load_sprite(10, 23, constants.WHITE),
    "C": sprites.load_sprite(11, 23, constants.WHITE)
}

tiles = {
    constants.FLOOR: sprites.load_sprite(15, 1, constants.WHITE),
Exemplo n.º 8
0
import sprites
import text

# how much xp does it take to go to the next level?
xp_table = [10, 30, 60, 100, 300, 500]  # 1000, 2000, 4000, 8000, etc


def calc_xp(num):
    if num > len(xp_table):
        return (2**(num - len(xp_table) + 1)) * 1000
    else:
        return xp_table[num - 1]


player_sprites = {
    "": sprites.load_sprite(0, 1, constants.WHITE),
    "Sage": sprites.load_sprite(6, 1, constants.WHITE),
    "Monk": sprites.load_sprite(0, 1, constants.WHITE),
    "Barbarian": sprites.load_sprite(2, 1, constants.WHITE),
    "Spellblade": sprites.load_sprite(2, 1, constants.WHITE),
    "Fighter": sprites.load_sprite(2, 1, constants.WHITE),
    "Ninja": sprites.load_sprite(4, 1, constants.WHITE),
    "Thief": sprites.load_sprite(4, 1, constants.WHITE),
    "Rogue": sprites.load_sprite(4, 1, constants.WHITE),
    "Sorcerer": sprites.load_sprite(5, 1, constants.WHITE),
    "Wizard": sprites.load_sprite(5, 1, constants.WHITE),
    "Warlock": sprites.load_sprite(5, 1, constants.WHITE),
    "Enigma": sprites.load_sprite(12, 1, constants.WHITE)
}

Exemplo n.º 9
0
def make_item(name, count=1):
    item = 0
    # Weapons
    if name == "dagger":
        item = Item(name, sprites.load_sprite(0, 40, constants.WHITE))
    elif name == "shortsword":
        item = Item(name, sprites.load_sprite(1, 42, constants.WHITE))
    elif name == "longsword":
        item = Item(name, sprites.load_sprite(0, 42, constants.WHITE))
    elif name == "broadsword":
        item = Item(name, sprites.load_sprite(1, 40, constants.WHITE))
    elif name == "rapier":
        item = Item(name, sprites.load_sprite(2, 42, constants.WHITE))
    elif name == "greatsword":
        item = Item(name, sprites.load_sprite(3, 42, constants.WHITE))
    elif name == "greataxe":
        item = Item(name, sprites.load_sprite(4, 42, constants.WHITE))

    # Armor
    elif name == "helmet":
        item = Item(name, sprites.load_sprite(11, 40, constants.WHITE))
    elif name == "full helm":
        item = Item(name, sprites.load_sprite(12, 40, constants.WHITE))
    elif name == "wizard hat":
        item = Item(name, sprites.load_sprite(13, 40, constants.BLUE))
    elif name == "boots":
        item = Item(name, sprites.load_sprite(0, 41, constants.WHITE))
    elif name == "hide armor":
        item = Item(name, sprites.load_sprite(3, 41, constants.YELLOW))
    elif name == "half plate":
        item = Item(name, sprites.load_sprite(4, 41, constants.WHITE))
    elif name == "full plate":
        item = Item(name, sprites.load_sprite(5, 41, constants.WHITE))

    # Rings
    elif name == "ruby ring":
        item = Item(name, sprites.load_sprite(7, 41, constants.RED))

    # Potions
    elif name == "lesser cure":
        item = Item(name, sprites.load_sprite(3, 37, constants.RED), 99, count)
    elif name == "greater cure":
        item = Item(name, sprites.load_sprite(4, 37, constants.RED), 99, count)
    elif name == "superior cure":
        item = Item(name, sprites.load_sprite(5, 37, constants.RED), 99, count)
    elif name == "lesser potion":
        item = Item(name, sprites.load_sprite(3, 37, constants.BLUE), 99, count)
    elif name == "greater potion":
        item = Item(name, sprites.load_sprite(4, 37, constants.BLUE), 99, count)
    elif name == "superior potion":
        item = Item(name, sprites.load_sprite(5, 37, constants.BLUE), 99, count)
    elif name == "lesser elixir":
        item = Item(name, sprites.load_sprite(3, 37, constants.GREEN), 99, count)
    elif name == "greater elixir":
        item = Item(name, sprites.load_sprite(4, 37, constants.GREEN), 99, count)
    elif name == "superior elixir":
        item = Item(name, sprites.load_sprite(5, 37, constants.GREEN), 99, count)

    # Food
    elif name == "mutton":
        item = Item(name, sprites.load_sprite(0, 36, constants.YELLOW), 99, count)

    # Misc
    elif name == "gold piece":
        item = Item(name, sprites.load_sprite(13, 32, constants.YELLOW), 10000, count)

    return item
Exemplo n.º 10
0
            if player.equip["off_hand"] != None and player.equip[
                    "off_hand"].name in weapons:
                off_weapon_stats = weapons[player.equip["off_hand"].name]
                total += dice.roll(off_weapon_stats[0], off_weapon_stats[1],
                                   drop)

    return total


equip_slots = [["head", (200, 20), "Head"], ["armor", (200, 60), "Armor"],
               ["r_ring", (160, 40), "Ring"], ["l_ring", (240, 40), "Ring"],
               ["main_hand", (160, 80), "Main hand"],
               ["off_hand", (240, 80), "Off hand"],
               ["boots", (200, 100), "Boots"]]

blank_sprite = sprites.load_sprite(0, 4, constants.WHITE)

first_time = True


def draw_equip(surface):
    global first_time
    text.write("Equipment", surface, 10, 10)

    for row in equip_slots:
        # Draw a white square
        equip_rect = pygame.Rect(row[1][0] - 2, row[1][1] - 2, 29, 29)
        pygame.draw.rect(surface, (255, 255, 255), equip_rect)

        if settings.player.equip[row[0]] == None:
            # Draw the blank sprite
Exemplo n.º 11
0
import button
import constants
import pygame
import settings
import sprites

text_sprites_white = {
    'A' : sprites.load_sprite(0, 55, constants.WHITE, half_width=True),
    'B' : sprites.load_sprite(1, 55, constants.WHITE, half_width=True),
    'C' : sprites.load_sprite(2, 55, constants.WHITE, half_width=True),
    'D' : sprites.load_sprite(3, 55, constants.WHITE, half_width=True),
    'E' : sprites.load_sprite(4, 55, constants.WHITE, half_width=True),
    'F' : sprites.load_sprite(5, 55, constants.WHITE, half_width=True),
    'G' : sprites.load_sprite(6, 55, constants.WHITE, half_width=True),
    'H' : sprites.load_sprite(7, 55, constants.WHITE, half_width=True),
    'I' : sprites.load_sprite(8, 55, constants.WHITE, half_width=True),
    'J' : sprites.load_sprite(9, 55, constants.WHITE, half_width=True),
    'K' : sprites.load_sprite(10, 55, constants.WHITE, half_width=True),
    'L' : sprites.load_sprite(11, 55, constants.WHITE, half_width=True),
    'M' : sprites.load_sprite(12, 55, constants.WHITE, half_width=True),
    'N' : sprites.load_sprite(13, 55, constants.WHITE, half_width=True),
    'O' : sprites.load_sprite(14, 55, constants.WHITE, half_width=True),
    'P' : sprites.load_sprite(15, 55, constants.WHITE, half_width=True),
    'Q' : sprites.load_sprite(16, 55, constants.WHITE, half_width=True),
    'R' : sprites.load_sprite(17, 55, constants.WHITE, half_width=True),
    'S' : sprites.load_sprite(18, 55, constants.WHITE, half_width=True),
    'T' : sprites.load_sprite(19, 55, constants.WHITE, half_width=True),
    'U' : sprites.load_sprite(20, 55, constants.WHITE, half_width=True),
    'V' : sprites.load_sprite(21, 55, constants.WHITE, half_width=True),
    'W' : sprites.load_sprite(22, 55, constants.WHITE, half_width=True),
    'X' : sprites.load_sprite(23, 55, constants.WHITE, half_width=True),
Exemplo n.º 12
0
def make_monster(name, x, y):
    mon = 0
    if name == "bat":
        mon = Monster(name,
                      x,
                      y,
                      sprites.load_sprite(1, 9, constants.WHITE),
                      hp=1,
                      ac=5,
                      lvl=1,
                      speed=18)
    if name == "rat":
        mon = Monster(name,
                      x,
                      y,
                      sprites.load_sprite(0, 9, constants.YELLOW),
                      hp=1,
                      ac=0,
                      lvl=1,
                      speed=18)

    if name == "garter snake":
        mon = Monster(name,
                      x,
                      y,
                      sprites.load_sprite(6, 9, constants.CYAN),
                      hp=5,
                      ac=5,
                      lvl=2)
    if name == "jackal":
        mon = Monster(name,
                      x,
                      y,
                      sprites.load_sprite(7, 9, constants.YELLOW),
                      hp=10,
                      ac=8,
                      lvl=2)

    if name == "goblin":
        mon = Monster(name,
                      x,
                      y,
                      sprites.load_sprite(0, 12, constants.GREEN),
                      hp=10,
                      ac=10,
                      lvl=3)

    if name == "ogre":
        mon = Monster(name,
                      x,
                      y,
                      sprites.load_sprite(1, 12, constants.GREEN),
                      hp=30,
                      ac=10,
                      lvl=4)
    if name == "orc":
        mon = Monster(name,
                      x,
                      y,
                      sprites.load_sprite(1, 12, constants.BLUE),
                      hp=20,
                      ac=12,
                      lvl=4)

    if name == "troll":
        mon = Monster(name,
                      x,
                      y,
                      sprites.load_sprite(3, 12, constants.CYAN),
                      hp=30,
                      ac=12,
                      lvl=5)

    if name == "golem":
        mon = Monster(name,
                      x,
                      y,
                      sprites.load_sprite(7, 18, constants.GRAY),
                      hp=50,
                      ac=0,
                      lvl=6,
                      speed=3)

    if name == "shade":
        mon = Monster(name,
                      x,
                      y,
                      sprites.load_sprite(7, 15, constants.WHITE),
                      hp=20,
                      ac=20,
                      lvl=7)

    settings.monsters.append(mon)
    return mon