ソースを参照

Broke the game/gbe/core.py into the time.py and display.py file. Updated the __init__.py files to reflect change.

master
Bryan Miller 6年前
コミット
5c4f574a5b
4個のファイルの変更56行の追加53行の削除
  1. +7
    -7
      game/__init__.py
  2. +2
    -2
      game/gbe/__init__.py
  3. +1
    -44
      game/gbe/display.py
  4. +46
    -0
      game/gbe/time.py

+ 7
- 7
game/__init__.py ファイルの表示

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

+ 2
- 2
game/gbe/__init__.py ファイルの表示

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

+ 1
- 44
game/gbe/display.py ファイルの表示

''' '''
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

+ 46
- 0
game/gbe/time.py ファイルの表示

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



読み込み中…
キャンセル
保存