import game.gbe | |||||
from . import gbe | |||||
_RUNNING = False | _RUNNING = False | ||||
def start(): | def start(): | ||||
global _RUNNING, onKeyEvent | global _RUNNING, onKeyEvent | ||||
t = game.gbe.Time() | |||||
t = gbe.time.Time() | |||||
t.reset() | t.reset() | ||||
game.gbe.events.Events.listen("KEYDOWN", onKeyEvent) | |||||
game.gbe.events.Events.listen("KEYUP", onKeyEvent) | |||||
game.gbe.events.Events.listen("KEYPRESSED", onKeyEvent) | |||||
d = game.gbe.Display() | |||||
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() | ||||
_RUNNING = True | _RUNNING = True | ||||
while _RUNNING: | while _RUNNING: | ||||
game.gbe.events.pollEmitter() | |||||
gbe.events.pollEmitter() | |||||
d.close() | d.close() |
from .core import Time | |||||
from .core import Display | |||||
from . import time | |||||
from . import display | |||||
from . import events | from . import events | ||||
from . import nodes | from . import nodes |
''' | ''' | ||||
Filename core.py | |||||
Filename display.py | |||||
Author: Bryan "ObsidianBlk" Miller | Author: Bryan "ObsidianBlk" Miller | ||||
Date Created: 8/1/2018 | Date Created: 8/1/2018 | ||||
Python Version: 3.7 | Python Version: 3.7 | ||||
''' | ''' | ||||
import time | |||||
import pygame | import pygame | ||||
class Time: | |||||
def __init__(self): | |||||
self._dticks = 0 | |||||
self._ldelta = 0 | |||||
self._lastTick = 0 | |||||
@property | |||||
def delta(self): | |||||
tick = int(round(time.time() * 1000)) | |||||
dt = 0 | |||||
if self._lastTick > 0: | |||||
dt = tick - self._lastTick | |||||
self._lastTick = tick | |||||
self._ldelta = dt | |||||
self._dticks += dt | |||||
return dt | |||||
@property | |||||
def last_delta(self): | |||||
return self._ldelta | |||||
@property | |||||
def aliveTicks(self): | |||||
tick = int(round(time.time() * 1000)) | |||||
dt = 0 | |||||
if self._lastTick > 0: | |||||
dt = tick - self._lastTick | |||||
return self._dticks + dt | |||||
@property | |||||
def aliveSeconds(self): | |||||
return self.aliveTicks / 1000.0 | |||||
def reset(self): | |||||
self.dticks = 0 | |||||
self._lastTick = int(round(time.time() * 1000)) | |||||
class Display: | class Display: | ||||
def __init__(self, width=640, height=480): | def __init__(self, width=640, height=480): | ||||
self._init = False | self._init = False |
''' | |||||
Filename time.py | |||||
Author: Bryan "ObsidianBlk" Miller | |||||
Date Created: 8/1/2018 | |||||
Python Version: 3.7 | |||||
''' | |||||
import time | |||||
class Time: | |||||
def __init__(self): | |||||
self._dticks = 0 | |||||
self._ldelta = 0 | |||||
self._lastTick = 0 | |||||
@property | |||||
def delta(self): | |||||
tick = int(round(time.time() * 1000)) | |||||
dt = 0 | |||||
if self._lastTick > 0: | |||||
dt = tick - self._lastTick | |||||
self._lastTick = tick | |||||
self._ldelta = dt | |||||
self._dticks += dt | |||||
return dt | |||||
@property | |||||
def last_delta(self): | |||||
return self._ldelta | |||||
@property | |||||
def aliveTicks(self): | |||||
tick = int(round(time.time() * 1000)) | |||||
dt = 0 | |||||
if self._lastTick > 0: | |||||
dt = tick - self._lastTick | |||||
return self._dticks + dt | |||||
@property | |||||
def aliveSeconds(self): | |||||
return self.aliveTicks / 1000.0 | |||||
def reset(self): | |||||
self.dticks = 0 | |||||
self._lastTick = int(round(time.time() * 1000)) | |||||