@@ -1,4 +1,4 @@ | |||
import game.gbe | |||
from . import gbe | |||
_RUNNING = False | |||
@@ -18,15 +18,15 @@ def onKeyEvent(event, data): | |||
def start(): | |||
global _RUNNING, onKeyEvent | |||
t = game.gbe.Time() | |||
t = gbe.time.Time() | |||
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() | |||
_RUNNING = True | |||
while _RUNNING: | |||
game.gbe.events.pollEmitter() | |||
gbe.events.pollEmitter() | |||
d.close() |
@@ -1,4 +1,4 @@ | |||
from .core import Time | |||
from .core import Display | |||
from . import time | |||
from . import display | |||
from . import events | |||
from . import nodes |
@@ -1,54 +1,11 @@ | |||
''' | |||
Filename core.py | |||
Filename display.py | |||
Author: Bryan "ObsidianBlk" Miller | |||
Date Created: 8/1/2018 | |||
Python Version: 3.7 | |||
''' | |||
import time | |||
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: | |||
def __init__(self, width=640, height=480): | |||
self._init = False |
@@ -0,0 +1,46 @@ | |||
''' | |||
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)) | |||