-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-cycle.py
68 lines (52 loc) · 1.91 KB
/
test-cycle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import sys
from sdl2 import *
import sdl2.ext
import cStringIO
from PIL import Image, ImageDraw
from palettes import EGAPalette
from picture import AGIPicture
from view import AGIView
class SoftwareRenderer(sdl2.ext.SoftwareSpriteRenderSystem):
def __init__(self, window):
super(SoftwareRenderer, self).__init__(window)
def render(self, components):
sdl2.ext.fill(self.surface, EGAPalette.BLACK)
super(SoftwareRenderer, self).render(components)
TARGET_DIMENSIONS = (320, 336)
RENDER_DIMENSIONS = (1280, 672)
TARGET_DIMENSIONS = (160, 200)
RENDER_DIMENSIONS = (640, 400)
def run():
sdl2.ext.init()
window = sdl2.ext.Window("Game Test", size=RENDER_DIMENSIONS)
world = sdl2.ext.World()
spriterenderer = SoftwareRenderer(window)
world.add_system(spriterenderer)
factory = sdl2.ext.SpriteFactory(sdl2.ext.SOFTWARE)
imgdata = cStringIO.StringIO()
imgdat2 = cStringIO.StringIO()
import_pic = AGIPicture("picture.003")
import_pic.get_upscaled('visual').save("checker.png")
import_pic.get_upscaled('visual').save(imgdata, format="PNG")
import_view = AGIView("view.000")
import_view.get_all_frames(True)[1][1].save(imgdat2, format="PNG")
surfy = sdl2.ext.load_image(imgdata, enforce="PIL")
background = factory.from_surface(surfy)
background.position = 0, 16
spriterenderer.render(background)
surface2 = sdl2.ext.load_image(imgdat2, enforce="PIL")
player = factory.from_surface(surface2)
player.position = 80, 30
spriterenderer.render(player)
window.show()
window.refresh()
running = True
while running:
events = sdl2.ext.get_events()
for event in events:
if event.type == sdl2.SDL_QUIT:
running = False
break
return 0
if __name__ == "__main__":
sys.exit(run())