Files
Elvenbane/slop.txt
2026-02-14 05:24:52 +03:00

73 lines
2.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#o = eb_terrain.Ground(1, 1, 1)
#c = eb_creatures.Unit(1, 1, 1)
#print(isinstance(o, eb_objects.Object))
#print(isinstance(o, eb_objects.Terrain))
#print(isinstance(c, eb_objects.Terrain))
import pygame
pygame.init()
screen = pygame.display.set_mode((800, 600))
original = pygame.image.load('sprite.png').convert_alpha()
orig_rect = original.get_rect(center=(200, 300))
def scale_image(image, n):
orig_size = image.get_size()
new_size = (int(orig_size[0] * n), int(orig_size[1] * n))
return pygame.transform.scale(image, new_size)
n = 1.5 # Example: 1.5x larger
scaled = scale_image(original, n)
scaled_rect = scaled.get_rect(center=(600, 300))
screen.blit(original, orig_rect) # Original size
screen.blit(scaled, scaled_rect) # Scaled by n
def load_sprites_from_folder(self, folder_path = sprites_dir):
"""
Загружает все PNG изображения из указанной папки в словарь.
Ключи - имена файлов без расширения, значения - pygame.Surface
"""
# Полный путь к папке со спрайтами относительно скрипта
script_dir = os.path.dirname(os.path.abspath(__file__))
full_path = os.path.join(script_dir, folder_path)
sprites = {}
if not os.path.exists(full_path):
print(f"❌ Папка не найдена: {full_path}")
return sprites
print(f"🔍 Сканируем папку: {full_path}")
# Проходим по всем файлам в папке
for filename in os.listdir(full_path):
if filename.lower().endswith('.png'):
# Убираем расширение .png для ключа
name = os.path.splitext(filename)[0]
filepath = os.path.join(full_path, filename)
try:
# Загружаем изображение
surface = pygame.image.load(filepath).convert_alpha()
self.sprites[name] = surface
print(f"✅ Загружен: {name} ({surface.get_size()})")
except pygame.error as e:
print(f"❌ Ошибка загрузки {filename}: {e}")
print(f"🎉 Загружено {len(sprites)} спрайтов")