Exemple #1
0
    def create_enemy(self):
        self.skeleton1 = self.my_view.draw_entity(self.my_view.skeleton,
                                                  self.random_spawn())
        self.chars_on_screen.append(self.skeleton1)
        self.skeleton2 = self.my_view.draw_entity(self.my_view.skeleton,
                                                  self.random_spawn())
        self.chars_on_screen.append(self.skeleton2)
        self.skeleton3 = self.my_view.draw_entity(self.my_view.skeleton,
                                                  self.random_spawn())
        self.chars_on_screen.append(self.skeleton3)
        self.boss = self.my_view.draw_entity(self.my_view.boss,
                                             self.random_spawn())
        self.chars_on_screen.append(self.boss)

        obj = Boss()
        obj.id = self.boss
        self.enemies_on_screen.append(obj)
        self.bossEntity = obj

        obj = Skeleton()
        obj.id = self.skeleton1
        self.enemies_on_screen.append(obj)

        obj = Skeleton()
        obj.id = self.skeleton2
        self.enemies_on_screen.append(obj)

        obj = Skeleton()
        obj.id = self.skeleton3
        self.enemies_on_screen.append(obj)

        print(self.chars_on_screen)
        print(self.skeleton1)
Exemple #2
0
    def __init__(self):
        root = Tk()
        canvas_height = 720
        canvas_width = 780
        canvas = Canvas(root, width=canvas_width, height=canvas_height)
        self.map = Map()
        self.map.draw_map(canvas)
        self.hero = Hero(canvas)
        self.hero.create_hero()
        self.skeleton = Skeleton(canvas)
        self.skeleton_number = 3
        self.spawn_spots = self.map.create_spawn_spots(self.skeleton_number)
        self.skeleton.spawn_skeleton(self.spawn_spots[:-1])

        root.bind("<KeyPress>", self.on_key_press)
        canvas.pack(padx=1, pady=0.6)
        root.mainloop()
Exemple #3
0
class Game(object):
    def __init__(self):
        root = Tk()
        canvas_height = 700
        canvas_width = 720
        canvas = Canvas(root, width=canvas_width, height=canvas_height)
        self.map = Map()
        self.map.draw_map(canvas)
        self.hero = Hero(canvas)
        self.hero.draw_hero(0, 0)
        self.hero.update_entity(self.hero.hero_down)
        self.skeleton = Skeleton(canvas)
        self.boss = Boss(canvas)
        self.skel_num = 3
        self.coordinates = self.map.create_random_coordinates(self.skel_num +
                                                              1)
        self.skeleton.draw_skeleton(self.coordinates[:-1])
        self.boss.draw_boss(self.coordinates[-1])
        self.hud = Hud()
        self.hud.draw_hud(canvas, 0, 650)
        root.bind("<KeyPress>", self.on_key_press)
        canvas.pack()
        root.mainloop()

    def on_key_press(self, e):
        if (e.keysym == 'Up'):
            self.hero.update_entity(self.hero.hero_up)
            if self.map.is_wall(self.hero.x,
                                self.hero.y - self.map.tile_size) == False:
                self.hero.move(0, -self.map.tile_size)
        elif (e.keysym == 'Down'):
            self.hero.update_entity(self.hero.hero_down)
            if self.map.is_wall(self.hero.x,
                                self.hero.y + self.map.tile_size) == False:
                self.hero.move(0, +self.map.tile_size)
        elif (e.keysym == 'Right'):
            self.hero.update_entity(self.hero.hero_right)
            if self.map.is_wall(self.hero.x + self.map.tile_size,
                                self.hero.y) == False:
                self.hero.move(+self.map.tile_size, 0)
        elif (e.keysym == 'Left'):
            self.hero.update_entity(self.hero.hero_left)
            if self.map.is_wall(self.hero.x - self.map.tile_size,
                                self.hero.y) == False:
                self.hero.move(-self.map.tile_size, 0)
Exemple #4
0
    def populate_world(self):
        # Skeleton Sprites
        for i in range(50):
            self._entities.add(
                Skeleton([
                    random.randint(50, self._width - 50),
                    random.randint(80, self._height - 80)
                ], random.randint(0, 360), 0, random.randint(50, 80)))

        # Player
        self._player = Player([settings.WIDTH, settings.HEIGHT])
        self._entities.add(self._player)
Exemple #5
0
class Game(object):
    def __init__(self):
        root = Tk()
        canvas_height = 720
        canvas_width = 780
        canvas = Canvas(root, width=canvas_width, height=canvas_height)
        self.map = Map()
        self.map.draw_map(canvas)
        self.hero = Hero(canvas)
        self.hero.create_hero()
        self.skeleton = Skeleton(canvas)
        self.skeleton_number = 3
        self.spawn_spots = self.map.create_spawn_spots(self.skeleton_number)
        self.skeleton.spawn_skeleton(self.spawn_spots[:-1])

        root.bind("<KeyPress>", self.on_key_press)
        canvas.pack(padx=1, pady=0.6)
        root.mainloop()

    def on_key_press(self, e):
        if (e.keysym == 'Up'):
            self.hero.change_image(self.hero.hero_up)
            if self.map.is_in_border_floor(self.hero.x,
                                           self.hero.y - 1) == True:
                self.hero.move(0, -1)
        elif (e.keysym == 'Down'):
            self.hero.change_image(self.hero.hero_down)
            if self.map.is_in_border_floor(self.hero.x,
                                           self.hero.y + 1) == True:
                self.hero.move(0, 1)
        elif (e.keysym == 'Left'):
            self.hero.change_image(self.hero.hero_left)
            if self.map.is_in_border_floor(self.hero.x - 1,
                                           self.hero.y) == True:
                self.hero.move(-1, 0)
        elif (e.keysym == 'Right'):
            self.hero.change_image(self.hero.hero_right)
            if self.map.is_in_border_floor(self.hero.x + 1,
                                           self.hero.y) == True:
                self.hero.move(1, 0)
Exemple #6
0
 def __init__(self):
     root = Tk()
     canvas_height = 700
     canvas_width = 720
     canvas = Canvas(root, width=canvas_width, height=canvas_height)
     self.map = Map()
     self.map.draw_map(canvas)
     self.hero = Hero(canvas)
     self.hero.draw_hero(0, 0)
     self.hero.update_entity(self.hero.hero_down)
     self.skeleton = Skeleton(canvas)
     self.boss = Boss(canvas)
     self.skel_num = 3
     self.coordinates = self.map.create_random_coordinates(self.skel_num +
                                                           1)
     self.skeleton.draw_skeleton(self.coordinates[:-1])
     self.boss.draw_boss(self.coordinates[-1])
     self.hud = Hud()
     self.hud.draw_hud(canvas, 0, 650)
     root.bind("<KeyPress>", self.on_key_press)
     canvas.pack()
     root.mainloop()
Exemple #7
0
 def get_random_skeletons(self):
     skeletons = randint(20, 25)
     while skeletons > 0:
         x = randint(1, 9)
         y = randint(1, 9)
         valid = self.my_map.cell_validation(x, y)
         if valid:
             can_insert_skeleton = True
             for creature in self.creatures:
                 if x == creature.position_x and y == creature.position_y:
                     can_insert_skeleton = False
             if can_insert_skeleton:
                 self.creatures.append(Skeleton(x, y, "skeleton"))
                 skeletons -= 1
Exemple #8
0
 def __init__(self):
     self.size = 720
     self.root = Tk()
     self.root.configure(background ='black')
     self.hud = 200
     self.canvas = Canvas(self.root, width=self.size+self.hud, height=self.size,bg="green",bd=0)
     self.floor = PhotoImage(file="floor.png")
     self.wall = PhotoImage(file="wall.png")
     self.char_down = PhotoImage(file="hero-down.png")
     self.char_up = PhotoImage(file="hero-up.png")
     self.char_right = PhotoImage(file="hero-right.png")
     self.char_left = PhotoImage(file="hero-left.png")
     self.skeleton = PhotoImage(file="skeleton.png")
     self.boss = PhotoImage(file="boss.png")
     self.hero = Hero()
     self.warlock = Boss()
     self.bones = Skeleton()
     self.canvas.pack()
     self.canvas.focus_set()
 def create_skeletons(self):
     for i in range(self.skeleton_number):
         self.skeletons.append(Skeleton(self.canvas))