improve performance

This commit is contained in:
chrys 2016-09-25 22:28:14 +02:00
parent 8c2b4523f4
commit 7a12cc0889

View File

@ -41,6 +41,7 @@ class fenrir():
self.prepareCommand() self.prepareCommand()
if not (self.wasCommand or self.environment['runtime']['inputManager'].isFenrirKeyPressed() or self.environment['generalInformation']['tutorialMode']): if not (self.wasCommand or self.environment['runtime']['inputManager'].isFenrirKeyPressed() or self.environment['generalInformation']['tutorialMode']):
self.environment['runtime']['inputManager'].writeEventBuffer() self.environment['runtime']['inputManager'].writeEventBuffer()
if self.environment['runtime']['inputManager'].noKeyPressed(): if self.environment['runtime']['inputManager'].noKeyPressed():
if self.wasCommand: if self.wasCommand:
self.wasCommand = False self.wasCommand = False
@ -51,7 +52,6 @@ class fenrir():
self.environment['input']['keyForeward'] -=1 self.environment['input']['keyForeward'] -=1
self.environment['input']['prevDeepestInput'] = [] self.environment['input']['prevDeepestInput'] = []
else: else:
self.environment['runtime']['screenManager'].update() self.environment['runtime']['screenManager'].update()
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
@ -73,6 +73,8 @@ class fenrir():
#print(time.time()-startTime) #print(time.time()-startTime)
def prepareCommand(self): def prepareCommand(self):
if time.time() - self.environment['commandInfo']['lastCommandExecutionTime'] < 0.2:
return
if self.environment['runtime']['inputManager'].noKeyPressed(): if self.environment['runtime']['inputManager'].noKeyPressed():
return return
if self.environment['input']['keyForeward'] > 0: if self.environment['input']['keyForeward'] > 0:
@ -85,8 +87,6 @@ class fenrir():
self.wasCommand = command != '' self.wasCommand = command != ''
def handleCommands(self): def handleCommands(self):
if time.time() - self.environment['commandInfo']['lastCommandExecutionTime'] < 0.2:
return
if not self.environment['runtime']['commandManager'].isCommandQueued(): if not self.environment['runtime']['commandManager'].isCommandQueued():
return return
self.environment['runtime']['commandManager'].executeCommand( self.environment['commandInfo']['currCommand'], 'commands') self.environment['runtime']['commandManager'].executeCommand( self.environment['commandInfo']['currCommand'], 'commands')