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

@@ -1 +1,3 @@
__pycache__/
*.pyc
*.swp

+ 7
- 2
game/__init__.py View File

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

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

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

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

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

Loading…
Cancel
Save