Browse Source

Had to make a little adjustment due to a video resize bug in Linux

master
Bryan Miller 6 years ago
parent
commit
f034d9afa9
4 changed files with 13 additions and 5 deletions
  1. +2
    -0
      .gitignore
  2. +7
    -2
      game/__init__.py
  3. +3
    -3
      game/gbe/display.py
  4. +1
    -0
      game/gbe/events.py

+ 2
- 0
.gitignore View File

__pycache__/ __pycache__/
*.pyc
*.swp

+ 7
- 2
game/__init__.py View File

_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)

+ 3
- 3
game/gbe/display.py View File

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):

+ 1
- 0
game/gbe/events.py View File

_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", {})

Loading…
Cancel
Save