@@ -1 +1,3 @@ | |||
__pycache__/ | |||
*.pyc | |||
*.swp |
@@ -4,6 +4,10 @@ from .nodes import * | |||
_RUNNING = False | |||
def _OnQuit(event, data): | |||
global _RUNNING | |||
_RUNNING = False | |||
def _OnVideoResize(event, data): | |||
flags = gbe.display.Display.flags | |||
gbe.display.Display.set_mode(data["size"], flags) | |||
@@ -23,15 +27,16 @@ def _OnKeyEvent(event, data): | |||
def start(): | |||
global _RUNNING, _OnKeyEvent, _OnVideoResize | |||
global _RUNNING, _OnKeyEvent, _OnQuit, _OnVideoResize | |||
t = gbe.time.Time() | |||
t.reset() | |||
gbe.events.Events.listen("QUIT", _OnQuit) | |||
gbe.events.Events.listen("KEYDOWN", _OnKeyEvent) | |||
gbe.events.Events.listen("KEYUP", _OnKeyEvent) | |||
gbe.events.Events.listen("KEYPRESSED", _OnKeyEvent) | |||
d = gbe.display.Display | |||
d.init() | |||
d.init(640, 480) | |||
d.caption = "Goldbox 64" | |||
d.watch_for_resize(True) | |||
#gbe.events.Events.listen("VIDEORESIZE", _OnVideoResize) |
@@ -27,7 +27,7 @@ class _Display: | |||
self._init = False | |||
self._resolution = (width, height) | |||
self._display_surface = None | |||
self._display_flags = Flag.RESIZABLE | Flag.HWSURFACE | Flag.DOUBLEBUF | |||
self._display_flags = Flag.HWSURFACE | Flag.DOUBLEBUF | |||
@property | |||
def surface(self): | |||
@@ -110,11 +110,11 @@ class _Display: | |||
if self._init: | |||
pygame.display.flip() | |||
def init(self): | |||
def init(self, width=0, height=0): | |||
if self._init == False: | |||
self._init = True | |||
pygame.init() | |||
self.set_mode(self._resolution, self._display_flags) | |||
self.set_mode((width, height), self._display_flags) | |||
return self | |||
def close(self): |
@@ -134,6 +134,7 @@ def pollEmitter(): | |||
_WatchButton(-1, event.button) | |||
Events.emit("MOUSEBUTTONDOWN", {"pos":event.pos, "button":event.button}) | |||
elif event.type == pygame.VIDEORESIZE: | |||
# NOTE: There is a resize bug in Linux. This will stop working after a short time. Grrr | |||
Events.emit("VIDEORESIZE", {"size":event.size, "w":event.w, "h":event.h}) | |||
elif event.type == pygame.VIDEOEXPOSE: | |||
Events.emit("VIDEOEXPOSE", {}) |