minigame: fix more minigames
This commit is contained in:
parent
187eb4b50c
commit
c5c733560f
4 changed files with 22 additions and 3 deletions
|
@ -1,7 +1,8 @@
|
||||||
import builtins
|
import builtins
|
||||||
import sys
|
import sys
|
||||||
|
import math
|
||||||
|
|
||||||
__all__ = ['enumerate', 'nonRepeatingRandomList', 'describeException', 'pdir', 'choice', 'cmp']
|
__all__ = ['enumerate', 'nonRepeatingRandomList', 'describeException', 'pdir', 'choice', 'cmp', 'lerp', 'triglerp']
|
||||||
|
|
||||||
if not hasattr(builtins, 'enumerate'):
|
if not hasattr(builtins, 'enumerate'):
|
||||||
def enumerate(L):
|
def enumerate(L):
|
||||||
|
@ -130,6 +131,21 @@ def pdir(obj, str = None, width = None,
|
||||||
_pdir(obj, str, width, fTruncate, lineWidth, wantPrivate)
|
_pdir(obj, str, width, fTruncate, lineWidth, wantPrivate)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
def lerp(v0, v1, t):
|
||||||
|
"""
|
||||||
|
returns a value lerped between v0 and v1, according to t
|
||||||
|
t == 0 maps to v0, t == 1 maps to v1
|
||||||
|
"""
|
||||||
|
return v0 + ((v1 - v0) * t)
|
||||||
|
|
||||||
|
def triglerp(v0, v1, t):
|
||||||
|
"""
|
||||||
|
lerp using the curve of sin(-pi/2) -> sin(pi/2)
|
||||||
|
"""
|
||||||
|
x = lerp(-math.pi/2, math.pi/2, t)
|
||||||
|
v = math.sin(x)
|
||||||
|
return lerp(v0, v1, (v + 1.) / 2.)
|
||||||
|
|
||||||
def choice(condition, ifTrue, ifFalse):
|
def choice(condition, ifTrue, ifFalse):
|
||||||
# equivalent of C++ (condition ? ifTrue : ifFalse)
|
# equivalent of C++ (condition ? ifTrue : ifFalse)
|
||||||
if condition:
|
if condition:
|
||||||
|
@ -158,5 +174,7 @@ def cmp(a, b):
|
||||||
|
|
||||||
builtins.pdir = pdir
|
builtins.pdir = pdir
|
||||||
builtins.isClient = isClient
|
builtins.isClient = isClient
|
||||||
|
builtins.lerp = lerp
|
||||||
|
builtins.triglerp = triglerp
|
||||||
builtins.choice = choice
|
builtins.choice = choice
|
||||||
builtins.cmp = cmp
|
builtins.cmp = cmp
|
||||||
|
|
|
@ -272,7 +272,7 @@ class DistributedCannonGame(DistributedMinigame):
|
||||||
|
|
||||||
def getTowerPosition(self):
|
def getTowerPosition(self):
|
||||||
yRange = TOWER_Y_RANGE
|
yRange = TOWER_Y_RANGE
|
||||||
yMin = yRange * 0.3
|
yMin = int(yRange * 0.3)
|
||||||
yMax = yRange
|
yMax = yRange
|
||||||
if self.DEBUG_TOWER_RANGE:
|
if self.DEBUG_TOWER_RANGE:
|
||||||
if self.DEBUG_TOWER_NEAR:
|
if self.DEBUG_TOWER_NEAR:
|
||||||
|
|
|
@ -45,7 +45,7 @@ def convertValueToGagTrackAndLevel(value):
|
||||||
|
|
||||||
|
|
||||||
def convertRankToGagTrackAndLevel(rank):
|
def convertRankToGagTrackAndLevel(rank):
|
||||||
track = rank % (ToontownBattleGlobals.MAX_TRACK_INDEX + 1)
|
track = int(rank % (ToontownBattleGlobals.MAX_TRACK_INDEX + 1))
|
||||||
level = rank / (ToontownBattleGlobals.MAX_TRACK_INDEX + 1)
|
level = rank / (ToontownBattleGlobals.MAX_TRACK_INDEX + 1)
|
||||||
return (track, level)
|
return (track, level)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from libotp import *
|
||||||
from .PurchaseBase import *
|
from .PurchaseBase import *
|
||||||
from direct.task.Task import Task
|
from direct.task.Task import Task
|
||||||
from toontown.toon import ToonHead
|
from toontown.toon import ToonHead
|
||||||
|
|
Loading…
Reference in a new issue