forked from ayte/PinmikPanik
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.selected = False # If beeing redirected
|
||||
self.cachedrel = [] # Storing relative movement of mouse
|
||||
self.cachedrelsize = 10
|
||||
self.mincachedsize = 3
|
||||
|
||||
# Used for movement
|
||||
self.restx = 0
|
||||
@ -63,10 +60,6 @@ class Lemming(BaseObject):
|
||||
# Mouse selection
|
||||
mouse=self.game.inputs["mouse"]
|
||||
if self.selected:
|
||||
# Caching mouse relative movement
|
||||
self.cachedrel.append(mouse["rel"])
|
||||
if len(self.cachedrel)>self.cachedrelsize:
|
||||
self.cachedrel.pop(0)
|
||||
# Releasing it
|
||||
if mouse["click"]==0 or not self.holdrect.collidepoint(mouse["campos"]):
|
||||
self.launch()
|
||||
@ -108,12 +101,11 @@ class Lemming(BaseObject):
|
||||
|
||||
def launch(self):
|
||||
# Launch itself in the mouse direction
|
||||
if len(self.cachedrel)>self.mincachedsize:
|
||||
averagerel = [sum([x[i] for x in self.cachedrel])/len(self.cachedrel) for i in range(2)]
|
||||
self.direction = math.degrees(math.atan2(averagerel[1],averagerel[0]))
|
||||
xdir, ydir = self.game.inputs["mouse"]["rel"]
|
||||
self.direction = math.degrees(math.atan2(ydir,xdir))
|
||||
|
||||
self.speed = self.basespeed*4
|
||||
self.cachedrel = []
|
||||
self.speed = self.basespeed*4
|
||||
self.cachedrel = []
|
||||
self.selected = False
|
||||
self.holdtimer.reset()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user