__pycache__/ | __pycache__/ | ||||
*.pyc | |||||
*.swp |
_RUNNING = False | _RUNNING = False | ||||
def _OnQuit(event, data): | |||||
global _RUNNING | |||||
_RUNNING = False | |||||
def _OnVideoResize(event, data): | def _OnVideoResize(event, data): | ||||
flags = gbe.display.Display.flags | flags = gbe.display.Display.flags | ||||
gbe.display.Display.set_mode(data["size"], flags) | gbe.display.Display.set_mode(data["size"], flags) | ||||
def start(): | def start(): | ||||
global _RUNNING, _OnKeyEvent, _OnVideoResize | |||||
global _RUNNING, _OnKeyEvent, _OnQuit, _OnVideoResize | |||||
t = gbe.time.Time() | t = gbe.time.Time() | ||||
t.reset() | t.reset() | ||||
gbe.events.Events.listen("QUIT", _OnQuit) | |||||
gbe.events.Events.listen("KEYDOWN", _OnKeyEvent) | gbe.events.Events.listen("KEYDOWN", _OnKeyEvent) | ||||
gbe.events.Events.listen("KEYUP", _OnKeyEvent) | gbe.events.Events.listen("KEYUP", _OnKeyEvent) | ||||
gbe.events.Events.listen("KEYPRESSED", _OnKeyEvent) | gbe.events.Events.listen("KEYPRESSED", _OnKeyEvent) | ||||
d = gbe.display.Display | d = gbe.display.Display | ||||
d.init() | |||||
d.init(640, 480) | |||||
d.caption = "Goldbox 64" | d.caption = "Goldbox 64" | ||||
d.watch_for_resize(True) | d.watch_for_resize(True) | ||||
#gbe.events.Events.listen("VIDEORESIZE", _OnVideoResize) | #gbe.events.Events.listen("VIDEORESIZE", _OnVideoResize) |
self._init = False | self._init = False | ||||
self._resolution = (width, height) | self._resolution = (width, height) | ||||
self._display_surface = None | self._display_surface = None | ||||
self._display_flags = Flag.RESIZABLE | Flag.HWSURFACE | Flag.DOUBLEBUF | |||||
self._display_flags = Flag.HWSURFACE | Flag.DOUBLEBUF | |||||
@property | @property | ||||
def surface(self): | def surface(self): | ||||
if self._init: | if self._init: | ||||
pygame.display.flip() | pygame.display.flip() | ||||
def init(self): | |||||
def init(self, width=0, height=0): | |||||
if self._init == False: | if self._init == False: | ||||
self._init = True | self._init = True | ||||
pygame.init() | pygame.init() | ||||
self.set_mode(self._resolution, self._display_flags) | |||||
self.set_mode((width, height), self._display_flags) | |||||
return self | return self | ||||
def close(self): | def close(self): |
_WatchButton(-1, event.button) | _WatchButton(-1, event.button) | ||||
Events.emit("MOUSEBUTTONDOWN", {"pos":event.pos, "button":event.button}) | Events.emit("MOUSEBUTTONDOWN", {"pos":event.pos, "button":event.button}) | ||||
elif event.type == pygame.VIDEORESIZE: | 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}) | Events.emit("VIDEORESIZE", {"size":event.size, "w":event.w, "h":event.h}) | ||||
elif event.type == pygame.VIDEOEXPOSE: | elif event.type == pygame.VIDEOEXPOSE: | ||||
Events.emit("VIDEOEXPOSE", {}) | Events.emit("VIDEOEXPOSE", {}) |