minigame: fix more minigames

This commit is contained in:
John Cote 2019-12-30 23:04:48 -05:00
parent 187eb4b50c
commit c5c733560f
4 changed files with 22 additions and 3 deletions

View file

@ -1,7 +1,8 @@
import builtins
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'):
def enumerate(L):
@ -130,6 +131,21 @@ def pdir(obj, str = None, width = None,
_pdir(obj, str, width, fTruncate, lineWidth, wantPrivate)
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):
# equivalent of C++ (condition ? ifTrue : ifFalse)
if condition:
@ -158,5 +174,7 @@ def cmp(a, b):
builtins.pdir = pdir
builtins.isClient = isClient
builtins.lerp = lerp
builtins.triglerp = triglerp
builtins.choice = choice
builtins.cmp = cmp

View file

@ -272,7 +272,7 @@ class DistributedCannonGame(DistributedMinigame):
def getTowerPosition(self):
yRange = TOWER_Y_RANGE
yMin = yRange * 0.3
yMin = int(yRange * 0.3)
yMax = yRange
if self.DEBUG_TOWER_RANGE:
if self.DEBUG_TOWER_NEAR:

View file

@ -45,7 +45,7 @@ def convertValueToGagTrackAndLevel(value):
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)
return (track, level)

View file

@ -1,3 +1,4 @@
from libotp import *
from .PurchaseBase import *
from direct.task.Task import Task
from toontown.toon import ToonHead