removed useless cache
This commit is contained in:
parent
43ff99dc1f
commit
8b69c76b2e
@ -14,9 +14,6 @@ class Lemming(BaseObject):
|
|||||||
self.speed = 0 # Current speed, leaning towards objective speed
|
self.speed = 0 # Current speed, leaning towards objective speed
|
||||||
|
|
||||||
self.selected = False # If beeing redirected
|
self.selected = False # If beeing redirected
|
||||||
self.cachedrel = [] # Storing relative movement of mouse
|
|
||||||
self.cachedrelsize = 10
|
|
||||||
self.mincachedsize = 3
|
|
||||||
|
|
||||||
# Used for movement
|
# Used for movement
|
||||||
self.restx = 0
|
self.restx = 0
|
||||||
@ -63,10 +60,6 @@ class Lemming(BaseObject):
|
|||||||
# Mouse selection
|
# Mouse selection
|
||||||
mouse=self.game.inputs["mouse"]
|
mouse=self.game.inputs["mouse"]
|
||||||
if self.selected:
|
if self.selected:
|
||||||
# Caching mouse relative movement
|
|
||||||
self.cachedrel.append(mouse["rel"])
|
|
||||||
if len(self.cachedrel)>self.cachedrelsize:
|
|
||||||
self.cachedrel.pop(0)
|
|
||||||
# Releasing it
|
# Releasing it
|
||||||
if mouse["click"]==0 or not self.holdrect.collidepoint(mouse["campos"]):
|
if mouse["click"]==0 or not self.holdrect.collidepoint(mouse["campos"]):
|
||||||
self.launch()
|
self.launch()
|
||||||
@ -108,12 +101,11 @@ class Lemming(BaseObject):
|
|||||||
|
|
||||||
def launch(self):
|
def launch(self):
|
||||||
# Launch itself in the mouse direction
|
# Launch itself in the mouse direction
|
||||||
if len(self.cachedrel)>self.mincachedsize:
|
xdir, ydir = self.game.inputs["mouse"]["rel"]
|
||||||
averagerel = [sum([x[i] for x in self.cachedrel])/len(self.cachedrel) for i in range(2)]
|
self.direction = math.degrees(math.atan2(ydir,xdir))
|
||||||
self.direction = math.degrees(math.atan2(averagerel[1],averagerel[0]))
|
|
||||||
|
|
||||||
self.speed = self.basespeed*4
|
self.speed = self.basespeed*4
|
||||||
self.cachedrel = []
|
self.cachedrel = []
|
||||||
self.selected = False
|
self.selected = False
|
||||||
self.holdtimer.reset()
|
self.holdtimer.reset()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user