home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / Gems.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-10-27  |  7.7 KB  |  217 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Bladex
  5. import AuxFuncs
  6. import whrandom
  7. import Reference
  8. import math
  9. MaximunAlpha = 0.15
  10.  
  11. def ConcentraTimer(e_name, time):
  12.     o = Bladex.GetEntity(e_name)
  13.     o.Data.Counter = o.Data.Counter + 1
  14.     o.Scale = o.Data.Scale * (o.Data.Frames - o.Data.Counter) / o.Data.Frames + 1.0
  15.     if o.Data.Counter > o.Data.Decon:
  16.         o.Alpha = MaximunAlpha - MaximunAlpha * (o.Data.Counter - o.Data.Decon) / (o.Data.Frames - o.Data.Decon)
  17.     else:
  18.         o.Alpha = MaximunAlpha * o.Data.Counter / o.Data.Frames
  19.     o.Rotate(o.Data.x, o.Data.y, o.Data.z, o.Data.delta)
  20.     if o.Data.Counter + 1 > o.Data.Frames:
  21.         o.RemoveFromList('Timer30')
  22.         o.SubscribeToList('Pin')
  23.     
  24.  
  25.  
  26. def EfectoConcentracion(pos, name, frames = 150, Scale = 30.0, RotSpeed = 32.0, Decon = 100):
  27.     
  28.     class vacio:
  29.         pass
  30.  
  31.     if ActualColor == GREEN_GEM:
  32.         o = Bladex.CreateEntity(name, 'EsferaGemaVerde', 0, 0, 0)
  33.     
  34.     if ActualColor == RED_GEM:
  35.         o = Bladex.CreateEntity(name, 'EsferaGemaRoja', 0, 0, 0)
  36.     
  37.     if ActualColor == BLUE_GEM:
  38.         o = Bladex.CreateEntity(name, 'EsferaGemaAzul', 0, 0, 0)
  39.     
  40.     o.Static = 1
  41.     o.Orientation = (0.707107, 0.707107, 0.0, 0.0)
  42.     o.Position = pos
  43.     o.SelfIlum = 1
  44.     o.CastShadows = 0
  45.     o.RasterMode = 'AdditiveAlpha'
  46.     o.RasterMode = 'Read'
  47.     o.Alpha = 0.0
  48.     o.Scale = 6.0
  49.     o.TimerFunc = ConcentraTimer
  50.     o.SubscribeToList('Timer30')
  51.     o.Data = vacio()
  52.     x = whrandom.random()
  53.     y = whrandom.random()
  54.     z = whrandom.random()
  55.     tot = x * x + y * y + z * z
  56.     x = math.sqrt(x * x / tot)
  57.     y = math.sqrt(y * y / tot)
  58.     z = math.sqrt(z * z / tot)
  59.     if whrandom.random() > 0.5:
  60.         o.Data.x = +x
  61.     else:
  62.         o.Data.x = -x
  63.     if whrandom.random() > 0.5:
  64.         o.Data.y = +y
  65.     else:
  66.         o.Data.y = -y
  67.     if whrandom.random() > 0.5:
  68.         o.Data.z = +z
  69.     else:
  70.         o.Data.z = -z
  71.     o.Data.delta = (whrandom.random() + 0.5) / RotSpeed
  72.     o.Data.Counter = 0
  73.     o.Data.Frames = frames
  74.     o.Data.Scale = Scale
  75.     o.Data.Decon = Decon
  76.     return o
  77.  
  78. Bladex.AddParticleGType('GemaConc', 'SmokeParticle', Reference.B_PARTICLE_GTYPE_ADD, 64)
  79. for i in range(64):
  80.     aux = 1.0 - i / 64.0
  81.     r = 10
  82.     g = 205
  83.     b = 150
  84.     a = aux * 128.0
  85.     size = aux * 128 + 64
  86.     Bladex.SetParticleGVal('GemaConc', i, r, g, b, a, size)
  87.  
  88. Bladex.AddParticleGType('Particulate', 'Estrellita', 1, 32)
  89. for i in range(32):
  90.     a = i * 4
  91.     r = 128.0
  92.     g = 255.0
  93.     b = 128.0
  94.     size = (i % 8) * 6
  95.     Bladex.SetParticleGVal('Particulate', i, r, g, b, a, size)
  96.  
  97.  
  98. def PiecesOfGema(pos):
  99.     RayoHit = Bladex.CreateEntity('RayoBastonHit', 'Entity Particle System D1', pos[0], pos[1], pos[2])
  100.     RayoHit.Time2Live = 32
  101.     RayoHit.YGravity = 20000
  102.     RayoHit.ParticleType = 'Particulate'
  103.     RayoHit.Friction = 0.95
  104.     RayoHit.Velocity = (0, 0, 0)
  105.     RayoHit.RandomVelocity = -5
  106.     RayoHit.DeathTime = Bladex.GetTime() + 1.0
  107.  
  108. GREEN_GEM = 0
  109. RED_GEM = 1
  110. BLUE_GEM = 2
  111. ActualColor = GREEN_GEM
  112.  
  113. def SetGemColor(color):
  114.     global ActualColor
  115.     ActualColor = color
  116.     if ActualColor == GREEN_GEM:
  117.         r = 10
  118.         g = 205
  119.         b = 150
  120.     
  121.     if ActualColor == RED_GEM:
  122.         r = 205
  123.         g = 150
  124.         b = 10
  125.     
  126.     if ActualColor == BLUE_GEM:
  127.         r = 10
  128.         g = 100
  129.         b = 205
  130.     
  131.     for i in range(64):
  132.         aux = 1.0 - i / 64.0
  133.         a = aux * 128.0
  134.         size = aux * 128 + 64
  135.         Bladex.SetParticleGVal('GemaConc', i, r, g, b, a, size)
  136.     
  137.     if ActualColor == RED_GEM:
  138.         r = 255.0
  139.         g = 128.0
  140.         b = 128.0
  141.     
  142.     if ActualColor == BLUE_GEM:
  143.         r = 128.0
  144.         g = 128.0
  145.         b = 255.0
  146.     
  147.     for i in range(32):
  148.         a = i * 4
  149.         size = (i % 8) * 6
  150.         Bladex.SetParticleGVal('Particulate', i, r, g, b, a, size)
  151.     
  152.  
  153.  
  154. def ConcentratorParticulate(pos, delta = (0, 0, 0)):
  155.     RayoHit = Bladex.CreateEntity('RayoBastonHit', 'Entity Particle System D1', pos[0], pos[1], pos[2])
  156.     RayoHit.ParticleType = 'GemaConc'
  157.     RayoHit.Time2Live = 64
  158.     RayoHit.YGravity = 0.0
  159.     RayoHit.Friction = 0
  160.     RayoHit.PPS = 255
  161.     RayoHit.Velocity = delta
  162.     RayoHit.RandomVelocity = -10
  163.     RayoHit.DeathTime = Bladex.GetTime() + 4.0
  164.  
  165. GemCallBack = None
  166. GemParams = ()
  167.  
  168. def FlashGem():
  169.     if ActualColor == GREEN_GEM:
  170.         AuxFuncs.FadeFrom(0.15, 0.0, 128, 255, 128)
  171.     
  172.     if ActualColor == RED_GEM:
  173.         AuxFuncs.FadeFrom(0.15, 0.0, 255, 128, 128)
  174.     
  175.     if ActualColor == BLUE_GEM:
  176.         AuxFuncs.FadeFrom(0.15, 0.0, 128, 128, 255)
  177.     
  178.     if GemCallBack != None:
  179.         apply(GemCallBack, GemParams)
  180.     
  181.  
  182.  
  183. def FaderUp():
  184.     _SndConcentGem.Volume = _SndConcentGem.Volume + 1.0 / 60.0
  185.     if _SndConcentGem.Volume >= 0.95:
  186.         _SndConcentGem.Stop()
  187.         _SndConcentGemHit.Play(ABC_POS[0], ABC_POS[1], ABC_POS[2], 0)
  188.     else:
  189.         Bladex.AddScheduledFunc(Bladex.GetTime() + 0.1, FaderUp, ())
  190.  
  191.  
  192. def Concentrator(pos, delta = (0, 0, 0)):
  193.     global ABC_POS
  194.     _SndConcentGem.Play(pos[0], pos[1], pos[2], -1)
  195.     _SndConcentGem.Volume = 0
  196.     ABC_POS = pos
  197.     FaderUp()
  198.     Bladex.AddScheduledFunc(Bladex.GetTime() + 0.5, EfectoConcentracion, (pos, 'C1gema1a'))
  199.     Bladex.AddScheduledFunc(Bladex.GetTime() + 1.0, EfectoConcentracion, (pos, 'C2gema1a'))
  200.     Bladex.AddScheduledFunc(Bladex.GetTime() + 1.5, EfectoConcentracion, (pos, 'C3gema1a'))
  201.     Bladex.AddScheduledFunc(Bladex.GetTime() + 5.95, PiecesOfGema, (pos,))
  202.     Bladex.AddScheduledFunc(Bladex.GetTime() + 6.0, FlashGem, ())
  203.     ConcentratorParticulate(pos, delta)
  204.  
  205. _SndConcentGem = Bladex.CreateSound('..\\..\\Sounds\\energy-ball.wav', 'SndConcentGem')
  206. _SndConcentGem.MinDistance = 10000.0
  207. _SndConcentGem.MaxDistance = 100000.0
  208. _SndConcentGemHit = Bladex.CreateSound('..\\..\\Sounds\\energy-ball-impact.wav', 'SndConcentGemHit')
  209. _SndConcentGemHit.MinDistance = 10000.0
  210. _SndConcentGemHit.MaxDistance = 100000.0
  211. o = Bladex.CreateEntity('e1', 'EsferaGemaVerde', 0, 0, 0)
  212. o.SubscribeToList('Pin')
  213. o = Bladex.CreateEntity('e2', 'EsferaGemaRoja', 0, 0, 0)
  214. o.SubscribeToList('Pin')
  215. o = Bladex.CreateEntity('e3', 'EsferaGemaAzul', 0, 0, 0)
  216. o.SubscribeToList('Pin')
  217.