self.is_dead(reason)
def attack(self, enemy, weapon, direction):
- if not self.attacked:
+ if not self.attacked and self.invincibility_frames == 0:
self.push(direction, 2, -1)
self.modify_health(weapon.damage, "enemy")
self.attacked = True
# pg.draw.rect(surf, (0,0,0), self.get_collision_rect(), border_radius=8, width=2)
# Uncomment for debugging area hitboxes
- # for area in self.areas.values():
- # area.draw(surf)
+ for area in self.areas.values():
+ area.draw(surf)
+import math
from argparse import Action
from Setup import *
from Player import Player
run_frames = []
for i in range(run_gif.n_frames):
run_frames.append(pg.transform.scale(pil_to_game(get_gif_frame(run_gif, i)), (180, 180)))
+
+ attack_gif = Image.open("Assets/skeleton/skeleton_attack.gif")
+ attack_frames = []
+ for i in range(attack_gif.n_frames):
+ attack_frames.append(pg.transform.scale(pil_to_game(get_gif_frame(attack_gif, i)), (180, 180)))
+
def __init__(self, pos, collision_layer, collision_mask):
super().__init__(pos, collision_layer, collision_mask)
self.follow_target(target, stop_dist=target.width/2+self.weapon.width)
if not target.attacked and get_display_rect(self.weapon.get_collision_rect()).colliderect(
get_display_rect(target.get_collision_rect())):
- target.attack(self, self.weapon, self.direction)
+ if self.state != "ATTACK":
+ self.state = "ATTACK"
+ self.current_frame = 0
+ elif 4 < self.current_frame:
+ target.attack(self, self.weapon, math.copysign(1, -self.velocity.x))
# Deals with collision and applying velocity
self.position, self.velocity = self.move_and_collide(self.position.copy(), self.velocity.copy(), delta)
self.display_offsets["enemy"] = pg.Vector2(-60, -35)
if frame % 4 == 0 and self.on_ground:
Dust(pg.Vector2(self.get_collision_rect().midbottom) + pg.Vector2(math.copysign(1, self.velocity.x) * -self.width/2,-15), 16, self.direction)
- self.current_frame = (self.current_frame + 0.5) % self.run_gif.n_frames
-
+ self.current_frame = (self.current_frame + 0.25) % self.run_gif.n_frames
+ elif self.state == "ATTACK":
+ frame = math.floor(self.current_frame)
+ if self.velocity.x > 0:
+ self.display = self.attack_frames[math.floor(frame)]
+ self.display_offsets["enemy"] = pg.Vector2(-50, -50)
+ else:
+ self.display = pg.transform.flip(self.attack_frames[math.floor(frame)], True, False)
+ self.display_offsets["enemy"] = pg.Vector2(-100, -50)
+ self.current_frame += 0.4
+ if math.floor(self.current_frame) >= self.attack_gif.n_frames-1:
+ self.state = "RUN"
# print(self.velocity)
# self.crouch(1000)
def draw(self, surf):
- self.weapon.draw(surf)
- super(Enemy, self).draw(surf)
+ # self.weapon.draw(surf)
+ # super(Enemy, self).draw(surf)
surf.blit(self.display, get_display_rect(self.get_collision_rect()).topleft + self.display_offsets["enemy"])
# for b in self.buffer:
from UI.HealthBar import HealthBar
from UI.PotionUI import PotionUI
from World import World
+from Item import PotionItem
class Game:
def __init__(self, level):
- self.collision_layer = {"none": set(), "world": set(), "player": set(), "enemy": set(), "pet": set(), "body":set()}
+ self.collision_layer = {"none": set(), "world": set(), "player": set(), "enemy": set(), "pet": set(), "body":set(), "potion":set()}
# self.load_world(level)
self.world = World(self.collision_layer)
- enemy_positions, player_position, self.portal_position = self.world.load_world(level)
+ enemy_positions, player_position, self.portal_position, heal_positions = self.world.load_world(level)
+
+ for i in heal_positions:
+ PotionItem(i, self.collision_layer["potion"])
self.player = Player(player_position, self.collision_layer["player"],
[self.collision_layer["enemy"], self.collision_layer["world"]],
- [self.collision_layer["enemy"], self.collision_layer["body"]])
+ [self.collision_layer["enemy"], self.collision_layer["body"]],
+ self.collision_layer["potion"])
# self.pet = Pet(center, self.collision_layer["pet"], [self.collision_layer["world"]])
self.enemies = [Enemy(pos, self.collision_layer["enemy"],
[self.collision_layer["player"], self.collision_layer["world"]]) for pos in
self.world.draw(surf)
+ for potion in self.collision_layer["potion"]:
+ potion.draw(surf)
+
for particle in particles:
particle.draw(surf)
--- /dev/null
+from Setup import *
+
+
+class PotionItem:
+ width, height = 50, 50
+ img = pg.transform.scale(pg.image.load("Assets/world/decor/HEALTHPOTION.png"), (50, 50))
+
+ def __init__(self, pos, collision_layer):
+ self.position = pg.Vector2(pos)
+ collision_layer.add(self)
+
+ def update(self, delta):
+ pass
+
+ def get_collision_rect(self):
+ return pg.Rect(self.position, (self.width, self.height))
+
+ def draw(self, surf):
+ surf.blit(self.img, get_display_rect(self.get_collision_rect()))
+ # pg.draw.rect(surf,(255,0,0),get_display_rect(self.get_collision_rect()))
-none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world
-1250.0,750.0|1200.0,750.0|1350.0,750.0|1350.0,700.0|1450.0,750.0|1450.0,700.0|1450.0,650.0|1450.0,600.0|1450.0,550.0|1250.0,700.0|1900.0,550.0|1900.0,600.0|1900.0,650.0|1900.0,700.0|1900.0,750.0|50.0,800.0|100.0,800.0|150.0,800.0|200.0,800.0|250.0,800.0|300.0,800.0|350.0,800.0|400.0,800.0|450.0,800.0|500.0,800.0|550.0,800.0|600.0,800.0|650.0,800.0|700.0,800.0|750.0,800.0|800.0,800.0|850.0,800.0|900.0,800.0|950.0,800.0|1000.0,800.0|1050.0,800.0|1100.0,800.0|1150.0,800.0|1200.0,800.0|1250.0,800.0|1300.0,800.0|1350.0,800.0|1400.0,800.0|1450.0,800.0|1500.0,800.0|1550.0,800.0|1600.0,800.0|1650.0,800.0|1700.0,800.0|1750.0,800.0|1800.0,800.0|1850.0,800.0|1900.0,800.0|1950.0,800.0|2000.0,800.0|2050.0,800.0|2100.0,800.0|2150.0,850.0|2100.0,850.0|2050.0,850.0|2000.0,850.0|1950.0,850.0|1900.0,850.0|1850.0,850.0|1800.0,850.0|1750.0,850.0|1700.0,850.0|1650.0,850.0|1600.0,850.0|1550.0,850.0|1500.0,850.0|1450.0,850.0|1400.0,850.0|1350.0,850.0|1300.0,850.0|1250.0,850.0|1200.0,850.0|1150.0,850.0|1100.0,850.0|1050.0,850.0|1000.0,850.0|950.0,850.0|900.0,850.0|850.0,850.0|800.0,850.0|750.0,850.0|700.0,850.0|650.0,850.0|600.0,850.0|550.0,850.0|500.0,850.0|450.0,850.0|400.0,850.0|350.0,850.0|300.0,850.0|250.0,850.0|200.0,850.0|150.0,850.0|100.0,850.0|50.0,850.0|0.0,850.0|0.0,800.0|0.0,750.0|0.0,700.0|0.0,650.0|0.0,600.0|0.0,550.0|0.0,400.0|0.0,350.0|0.0,300.0|0.0,250.0|0.0,200.0|0.0,150.0|0.0,100.0|0.0,50.0|0.0,0.0|2200.0,850.0|2200.0,800.0|2200.0,750.0|2200.0,700.0|2200.0,650.0|2200.0,600.0|2150.0,400.0|2200.0,200.0|2200.0,150.0|2200.0,100.0|2200.0,50.0|2200.0,0.0|2150.0,0.0|2150.0,50.0|2150.0,100.0|2150.0,150.0|2150.0,200.0|2150.0,250.0|2150.0,350.0|2150.0,300.0|2200.0,250.0|2200.0,300.0|2200.0,350.0|2200.0,400.0|2200.0,550.0|2150.0,550.0|2150.0,600.0|2150.0,650.0|2150.0,700.0|2150.0,750.0|2150.0,800.0|300.0,600.0|0.0,450.0|2200.0,450.0|2150.0,450.0|2150.0,500.0|2200.0,500.0|0.0,500.0|2050.0,700.0
-GOLDCOIN|BRONZECOIN|PEDESTAL|INTERDIMENSIONALPOWDER|PILLAR_|PILLAR_|PILLAR_|PILLAR_|PILLAR_|SILVERCOIN|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLAYER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|ENEMY
+none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world
+1250.0,750.0|1200.0,750.0|1350.0,750.0|1350.0,700.0|1450.0,750.0|1450.0,700.0|1450.0,650.0|1450.0,600.0|1450.0,550.0|1250.0,700.0|1900.0,550.0|1900.0,600.0|1900.0,650.0|1900.0,700.0|1900.0,750.0|50.0,800.0|100.0,800.0|150.0,800.0|200.0,800.0|250.0,800.0|300.0,800.0|350.0,800.0|400.0,800.0|450.0,800.0|500.0,800.0|550.0,800.0|600.0,800.0|650.0,800.0|700.0,800.0|750.0,800.0|800.0,800.0|850.0,800.0|900.0,800.0|950.0,800.0|1000.0,800.0|1050.0,800.0|1100.0,800.0|1150.0,800.0|1200.0,800.0|1250.0,800.0|1300.0,800.0|1350.0,800.0|1400.0,800.0|1450.0,800.0|1500.0,800.0|1550.0,800.0|1600.0,800.0|1650.0,800.0|1700.0,800.0|1750.0,800.0|1800.0,800.0|1850.0,800.0|1900.0,800.0|1950.0,800.0|2000.0,800.0|2050.0,800.0|2100.0,800.0|2150.0,850.0|2100.0,850.0|2050.0,850.0|2000.0,850.0|1950.0,850.0|1900.0,850.0|1850.0,850.0|1800.0,850.0|1750.0,850.0|1700.0,850.0|1650.0,850.0|1600.0,850.0|1550.0,850.0|1500.0,850.0|1450.0,850.0|1400.0,850.0|1350.0,850.0|1300.0,850.0|1250.0,850.0|1200.0,850.0|1150.0,850.0|1100.0,850.0|1050.0,850.0|1000.0,850.0|950.0,850.0|900.0,850.0|850.0,850.0|800.0,850.0|750.0,850.0|700.0,850.0|650.0,850.0|600.0,850.0|550.0,850.0|500.0,850.0|450.0,850.0|400.0,850.0|350.0,850.0|300.0,850.0|250.0,850.0|200.0,850.0|150.0,850.0|100.0,850.0|50.0,850.0|0.0,850.0|0.0,800.0|0.0,750.0|0.0,700.0|0.0,650.0|0.0,600.0|0.0,550.0|0.0,400.0|0.0,350.0|0.0,300.0|0.0,250.0|0.0,200.0|0.0,150.0|0.0,100.0|0.0,50.0|0.0,0.0|2200.0,850.0|2200.0,800.0|2200.0,750.0|2200.0,700.0|2200.0,650.0|2200.0,600.0|2150.0,400.0|2200.0,200.0|2200.0,150.0|2200.0,100.0|2200.0,50.0|2200.0,0.0|2150.0,0.0|2150.0,50.0|2150.0,100.0|2150.0,150.0|2150.0,200.0|2150.0,250.0|2150.0,350.0|2150.0,300.0|2200.0,250.0|2200.0,300.0|2200.0,350.0|2200.0,400.0|2200.0,550.0|2150.0,550.0|2150.0,600.0|2150.0,650.0|2150.0,700.0|2150.0,750.0|2150.0,800.0|300.0,600.0|0.0,450.0|2200.0,450.0|2150.0,450.0|2150.0,500.0|2200.0,500.0|0.0,500.0|2050.0,700.0|1050.0,750.0|1100.0,750.0|1050.0,700.0|1000.0,750.0|700.0,750.0
+GOLDCOIN|BRONZECOIN|PEDESTAL|INTERDIMENSIONALPOWDER|PILLAR_|PILLAR_|PILLAR_|PILLAR_|PILLAR_|SILVERCOIN|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLAYER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|ENEMY|HEALTHPOTION|HEALTHPOTION|HEALTHPOTION|HEALTHPOTION|HEALTHPOTION
from Actors import Actor
from datetime import datetime, timedelta
from Potion import Potion
+from Item import PotionItem
from Weapon import Sword
from Particle import Dust
colour = (52, 94, 235)
- def __init__(self, pos, collision_layer, collision_mask, can_hurt):
+ def __init__(self, pos, collision_layer, collision_mask, can_hurt, heals):
super().__init__(pos, collision_layer, collision_mask)
# self.initial_position = pg.Vector2(pos)
- self.dashCooldown = timedelta(seconds=2, microseconds=500000)
- self.timeBetweenDoublePress = timedelta(seconds=0, microseconds=500000)
- self.dashSpeed = 5
+ # self.dashCooldown = timedelta(seconds=2, microseconds=500000)
+ # self.timeBetweenDoublePress = timedelta(seconds=0, microseconds=500000)
+ # self.dashSpeed = 5
# self.dashPossible = False
# self.lastDash = datetime.utcnow()
# self.lastValueL = False
# self.lastPressedRight = datetime.utcnow()
# self.lastValueR = False
- self.areas = {"body": Area(self.position, pg.Vector2(0, self.height / 2), self.width, self.height / 2, Actor),
- "head": Area(self.position, pg.Vector2(self.width * 1 / 3 * 1 / 2, -2), self.width * 2 / 3, 25,
- Actor)}
+ self.areas = {"head": Area(self.position, pg.Vector2(0, self.height / 2), self.width, self.height / 2, Actor),
+ "body": Area(self.position,(0,0),self.width,self.height,PotionItem, self.add_potion)}
+ self.heal_layer = heals
self.potion_cooldown = 0
- self.starting_potions = 999
+ self.starting_potions = 3
self.potion_bag = [Potion(self)]
- for i in range(self.starting_potions):
+ for i in range(self.starting_potions - 1):
self.potion_bag.append(Potion(self)) # use one liner
self.weapon = Sword(self.position, (0, 0), self.width, -1)
self.buffer = []
+ def add_potion(self):
+ if len(self.potion_bag) < 3:
+ self.potion_bag.append(Potion(self))
+
# def attack(self, enemy, weapon):
# super(Player, self).attack(enemy, weapon)
# self.current_frame = 0
# self.state = "ATTACK"
# print('a')
+ def attack(self, enemy, weapon, direction):
+ self.friction = 0.9
+
+ super().attack(enemy,weapon,direction)
+
def update(self, delta):
if self.attacked:
# Get and handle input
self.handle_input()
+ for i,heal in enumerate(self.heal_layer):
+ if len(self.potion_bag) < 3 and self.areas["body"].is_colliding(heal):
+ self.add_potion()
+ self.heal_layer.remove(heal)
+ break
+
if len(self.potion_bag) > 0:
self.potion_bag[0].get_input(self)
enemy.attack(self, self.weapon, self.direction)
def draw(self, surf):
+ # super().draw(surf)
if self.state == "IDLE":
# self.weapon.draw(surf, self.display_offsets["weapon"])
if self.direction == 1:
if player.health > 100:
player.health = 100
- del player.potion_bag[0]
- player.potion_cooldown = 30
- threading.Thread(target = player.potion_cooldown_timer).start()
-
-
-
-
-
+ del self.player.potion_bag[0]
+ self.player.potion_cooldown = 4
+ threading.Thread(target = self.player.potion_cooldown_timer).start()
from Setup import *
from Block import Block
+from Item import PotionItem
from os import path, listdir
with open(path.join("Levels", f'Level{level}.txt'), 'r') as f:
file_contents = f.read().split("\n")
- out = [[], center, "a"]
+ out = [[], center, "a", []]
for i in range(0, len(file_contents) - 1, 3):
layer = file_contents[i].split("|")
pos = file_contents[i + 1].split("|")
out[0].append((x, y))
elif t == "PORTAL":
out[2] = (x, y)
+ elif t == "HEALTHPOTION":
+ out[3].append((x,y))
elif f"{t}.png" in listdir("Assets/world/decor"):
self.blocks.append(Decor((x,y),self.collision_layer["none"],t))
else:
class Decor:
textures = dict()
+ # for file in listdir("Assets/world/decor"):
+ # textures[file[:file.index(".")]] = pg.transform.scale(
+ # pg.image.load(path.join("Assets/world/decor", file)), (50, 50))
for file in listdir("Assets/world/decor"):
- textures[file[:file.index(".")]] = pg.transform.scale(
- pg.image.load(path.join("Assets/world/decor", file)), (50, 50))
+ img = pg.image.load(path.join("Assets/world/decor", file))
+
+ textures[file[:file.index(".")]] = pg.transform.scale(pg.image.load(path.join("Assets/world/decor", file)),(img.get_width() * 50/16, img.get_height() * 50/16))
def __init__(self, pos, collision_layer, img):
self.position = pg.Vector2(pos)
self.img = img