19 changed files with 90 additions and 260 deletions
|
Before Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 929 KiB |
@ -1,21 +0,0 @@ |
|||||||
-----BEGIN CERTIFICATE----- |
|
||||||
MIIDdjCCAl6gAwIBAgIUO+7fPRqW/ZlLcjJc7abg7zY0dMswDQYJKoZIhvcNAQEL |
|
||||||
BQAwNTEOMAwGA1UECwwFV2F6dWgxDjAMBgNVBAoMBVdhenVoMRMwEQYDVQQHDApD |
|
||||||
YWxpZm9ybmlhMB4XDTI1MDQxOTE0NTQwM1oXDTM1MDQxNzE0NTQwM1owXDELMAkG |
|
||||||
A1UEBhMCVVMxEzARBgNVBAcMCkNhbGlmb3JuaWExDjAMBgNVBAoMBVdhenVoMQ4w |
|
||||||
DAYDVQQLDAVXYXp1aDEYMBYGA1UEAwwPd2F6dWguZGFzaGJvYXJkMIIBIjANBgkq |
|
||||||
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvmIj4rPiA56NxFJDDjwMyE41wUzojw5X |
|
||||||
zfHOvvn22/G7I5pT7TKebFJcjMhLdj3oP2l3owYC/9SkwXD9S3nIkApLUMeg44LK |
|
||||||
LxuDdluneKa8hCm74zzZxP4D8lrSN4GBgCWB4D2UgOBEEBQXqD2bHp8Q/3JZHq44 |
|
||||||
yRVEBYHRHNKNV8V+X/jwsRQX/AXxrZB5+88+E/qyWA20SFxHu+Ts4qBLbH5WN7sP |
|
||||||
i4ZeSYsWOjD4tarF2rCs+2BW08hinYh4gE+AzTlkhpz3AbwHpjx3W/LU1i3zr82T |
|
||||||
WvnDzfA89jmT3e+wYHk13b2JvAOFVW1TrEjo5B567Bq4WL3Ff7zoXwIDAQABo1cw |
|
||||||
VTAfBgNVHSMEGDAWgBTuFh2D9FW9b4yWpdSgKEgQi6ReHjAJBgNVHRMEAjAAMAsG |
|
||||||
A1UdDwQEAwIE8DAaBgNVHREEEzARgg93YXp1aC5kYXNoYm9hcmQwDQYJKoZIhvcN |
|
||||||
AQELBQADggEBAJyUnuD7Ss6hHtLlgugYLLKAGCiaTdlkSxzpzjRxka3hMqMVwSaQ |
|
||||||
XA+iUuxPZAFA3mMQX/jtgzD60CFJNK9lkHbh9n7uFCKqQwmQrFRwISdmoHI0M46B |
|
||||||
nJ6zUsarB7rovg1Mbdt1/1oFtRFq+AblnXlNh0IWrNL8U/kEzCeiR1f6DZZUqzTq |
|
||||||
UYmLLp3PVpL4U4TiUhExmpjSwrXrNt6Lus/tfP8ad0jVPBb728LhP0cbZlehRHH6 |
|
||||||
8KjaSSwwgQ4p3yNC5puTbuSSFFgzbA7SawDkaH0KI4ZTSQHDPsmq2ZQpOXAeAJTC |
|
||||||
UXdyb7GGWuxsKjzzCcL2D90mZCsHlK3kjgM= |
|
||||||
-----END CERTIFICATE----- |
|
||||||
@ -1,21 +0,0 @@ |
|||||||
-----BEGIN CERTIFICATE----- |
|
||||||
MIIDdjCCAl6gAwIBAgIUO+7fPRqW/ZlLcjJc7abg7zY0dMswDQYJKoZIhvcNAQEL |
|
||||||
BQAwNTEOMAwGA1UECwwFV2F6dWgxDjAMBgNVBAoMBVdhenVoMRMwEQYDVQQHDApD |
|
||||||
YWxpZm9ybmlhMB4XDTI1MDQxOTE0NTQwM1oXDTM1MDQxNzE0NTQwM1owXDELMAkG |
|
||||||
A1UEBhMCVVMxEzARBgNVBAcMCkNhbGlmb3JuaWExDjAMBgNVBAoMBVdhenVoMQ4w |
|
||||||
DAYDVQQLDAVXYXp1aDEYMBYGA1UEAwwPd2F6dWguZGFzaGJvYXJkMIIBIjANBgkq |
|
||||||
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvmIj4rPiA56NxFJDDjwMyE41wUzojw5X |
|
||||||
zfHOvvn22/G7I5pT7TKebFJcjMhLdj3oP2l3owYC/9SkwXD9S3nIkApLUMeg44LK |
|
||||||
LxuDdluneKa8hCm74zzZxP4D8lrSN4GBgCWB4D2UgOBEEBQXqD2bHp8Q/3JZHq44 |
|
||||||
yRVEBYHRHNKNV8V+X/jwsRQX/AXxrZB5+88+E/qyWA20SFxHu+Ts4qBLbH5WN7sP |
|
||||||
i4ZeSYsWOjD4tarF2rCs+2BW08hinYh4gE+AzTlkhpz3AbwHpjx3W/LU1i3zr82T |
|
||||||
WvnDzfA89jmT3e+wYHk13b2JvAOFVW1TrEjo5B567Bq4WL3Ff7zoXwIDAQABo1cw |
|
||||||
VTAfBgNVHSMEGDAWgBTuFh2D9FW9b4yWpdSgKEgQi6ReHjAJBgNVHRMEAjAAMAsG |
|
||||||
A1UdDwQEAwIE8DAaBgNVHREEEzARgg93YXp1aC5kYXNoYm9hcmQwDQYJKoZIhvcN |
|
||||||
AQELBQADggEBAJyUnuD7Ss6hHtLlgugYLLKAGCiaTdlkSxzpzjRxka3hMqMVwSaQ |
|
||||||
XA+iUuxPZAFA3mMQX/jtgzD60CFJNK9lkHbh9n7uFCKqQwmQrFRwISdmoHI0M46B |
|
||||||
nJ6zUsarB7rovg1Mbdt1/1oFtRFq+AblnXlNh0IWrNL8U/kEzCeiR1f6DZZUqzTq |
|
||||||
UYmLLp3PVpL4U4TiUhExmpjSwrXrNt6Lus/tfP8ad0jVPBb728LhP0cbZlehRHH6 |
|
||||||
8KjaSSwwgQ4p3yNC5puTbuSSFFgzbA7SawDkaH0KI4ZTSQHDPsmq2ZQpOXAeAJTC |
|
||||||
UXdyb7GGWuxsKjzzCcL2D90mZCsHlK3kjgM= |
|
||||||
-----END CERTIFICATE----- |
|
||||||
@ -0,0 +1,15 @@ |
|||||||
|
from enne2engine.render import SDL2Renderer |
||||||
|
from enne2engine.controls import UserControls |
||||||
|
import sys |
||||||
|
import os |
||||||
|
import json |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GameEngine(UserControls): |
||||||
|
def __init__(self, map, game): |
||||||
|
super().__init__() |
||||||
|
self.map = map |
||||||
|
self.game = game |
||||||
|
self.graphics = SDL2Renderer(self) |
||||||
|
|
||||||
@ -1,46 +0,0 @@ |
|||||||
import pyglet |
|
||||||
from .tilemanager import TileManager |
|
||||||
|
|
||||||
class PygletWrapper: |
|
||||||
def __init__(self): |
|
||||||
self.window = pyglet.window.Window(800, 600, "My Game") |
|
||||||
self.window.push_handlers(self) |
|
||||||
self.running = True |
|
||||||
|
|
||||||
def on_draw(self): |
|
||||||
self.window.clear() |
|
||||||
# Render your game here |
|
||||||
|
|
||||||
def on_close(self): |
|
||||||
self.running = False |
|
||||||
|
|
||||||
def handle_events(self): |
|
||||||
pyglet.clock.tick() |
|
||||||
self.window.dispatch_events() |
|
||||||
return not self.running |
|
||||||
|
|
||||||
def clear_screen(self, color=(0, 0, 0, 255)): |
|
||||||
pyglet.gl.glClearColor(color[0] / 255.0, color[1] / 255.0, color[2] / 255.0, color[3] / 255.0) |
|
||||||
self.window.clear() |
|
||||||
|
|
||||||
def present_renderer(self): |
|
||||||
self.window.flip() |
|
||||||
|
|
||||||
def quit(self): |
|
||||||
pyglet.app.exit() |
|
||||||
|
|
||||||
def load_spritesheet(self, name, path): |
|
||||||
image = pyglet.image.load(path) |
|
||||||
self.spritesheets[name] = image |
|
||||||
self.tile_managers[name] = TileManager(path.replace('.png', '.xml')) |
|
||||||
|
|
||||||
def render_sprite(self, name, x, y): |
|
||||||
sprite = pyglet.sprite.Sprite(self.spritesheets[name], x, y) |
|
||||||
sprite.draw() |
|
||||||
|
|
||||||
def render_tile(self, spritesheet_name, tile_name, x, y): |
|
||||||
tile_rect = self.tile_managers[spritesheet_name].get_tile_rect(tile_name) |
|
||||||
if tile_rect is not None: |
|
||||||
image = self.spritesheets[spritesheet_name].get_region(*tile_rect) |
|
||||||
sprite = pyglet.sprite.Sprite(image, x, y) |
|
||||||
sprite.draw() |
|
||||||
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 1.2 MiB |
@ -1,62 +0,0 @@ |
|||||||
from PIL import ImageOps, Image, ImageFilter |
|
||||||
|
|
||||||
FG_IMG_PATH = "fg.png" |
|
||||||
|
|
||||||
BG_IMG_PATH = "bg.jpeg" |
|
||||||
|
|
||||||
def load_image(path): |
|
||||||
|
|
||||||
"""Load an image using PIL.""" |
|
||||||
|
|
||||||
return Image.open(path) |
|
||||||
|
|
||||||
def extract_alpha(image): |
|
||||||
|
|
||||||
"""Extract the alpha channel from an image.""" |
|
||||||
|
|
||||||
return image.split()[-1] |
|
||||||
|
|
||||||
def create_shadow_from_alpha(alpha, blur_radius): |
|
||||||
|
|
||||||
"""Create a shadow based on a blurred version of the alpha channel.""" |
|
||||||
|
|
||||||
alpha_blur = alpha.filter(ImageFilter.BoxBlur(blur_radius)) |
|
||||||
|
|
||||||
shadow = Image.new(mode="RGB", size=alpha_blur.size) |
|
||||||
|
|
||||||
shadow.putalpha(alpha_blur) |
|
||||||
|
|
||||||
return shadow |
|
||||||
|
|
||||||
def composite_images(fg, shadow): |
|
||||||
|
|
||||||
"""Composite the shadow and foreground onto the background.""" |
|
||||||
|
|
||||||
shadow.paste(fg, (-5, 4), fg) |
|
||||||
|
|
||||||
return shadow |
|
||||||
|
|
||||||
if __name__ == "__main__": |
|
||||||
|
|
||||||
|
|
||||||
# Load the images |
|
||||||
|
|
||||||
fg = load_image(FG_IMG_PATH) |
|
||||||
|
|
||||||
# Create the shadow based on the alpha channel of the foreground |
|
||||||
|
|
||||||
alpha = extract_alpha(fg) |
|
||||||
|
|
||||||
shadow = create_shadow_from_alpha(alpha, blur_radius=1) |
|
||||||
|
|
||||||
# Composite the shadow and foreground onto the background |
|
||||||
|
|
||||||
final_image = composite_images(fg, shadow) |
|
||||||
|
|
||||||
# Display the final image (optional) |
|
||||||
|
|
||||||
final_image.show() |
|
||||||
|
|
||||||
# Save the final image |
|
||||||
|
|
||||||
final_image.save(f"final_image.png") |
|
||||||
@ -1,35 +0,0 @@ |
|||||||
import sdl2 |
|
||||||
import sdl2.ext |
|
||||||
|
|
||||||
def run(): |
|
||||||
sdl2.ext.init() |
|
||||||
window = sdl2.ext.Window("SDL2 Texture Example", size=(640, 480)) |
|
||||||
renderer = sdl2.ext.Renderer(window) |
|
||||||
target_surface = sdl2.SDL_CreateRGBSurface(0, 640, 480, 32, 0, 0, 0, 0) |
|
||||||
# Crea texture target usando il metodo del renderer |
|
||||||
target_tex = sdl2.ext.Texture(renderer, surface=target_surface) |
|
||||||
|
|
||||||
# Disegna sulla texture |
|
||||||
sdl2.SDL_SetRenderTarget(renderer.renderer, target_tex.tx) |
|
||||||
renderer.clear() |
|
||||||
square_rect = sdl2.SDL_Rect(270, 190, 100, 100) |
|
||||||
renderer.draw_rect([square_rect], sdl2.ext.Color(255, 0, 0)) |
|
||||||
renderer.present() |
|
||||||
sdl2.SDL_SetRenderTarget(renderer.renderer, None) |
|
||||||
# Main loop |
|
||||||
running = True |
|
||||||
while running: |
|
||||||
for event in sdl2.ext.get_events(): |
|
||||||
if event.type == sdl2.SDL_QUIT: |
|
||||||
running = False |
|
||||||
break |
|
||||||
|
|
||||||
renderer.clear() |
|
||||||
renderer.copy(target_tex) # Ora usa l'oggetto Texture corretto |
|
||||||
renderer.present() |
|
||||||
sdl2.SDL_Delay(10) |
|
||||||
|
|
||||||
sdl2.ext.quit() |
|
||||||
|
|
||||||
if __name__ == "__main__": |
|
||||||
run() |
|
||||||
Loading…
Reference in new issue