home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Scripts / Demo_Stuff.py < prev    next >
Encoding:
Text File  |  2000-10-27  |  8.1 KB  |  331 lines

  1. ####################################################################################
  2. #
  3. #
  4. #
  5. #                dd ee mm oo !! !! !! !!
  6. #
  7. #
  8. #
  9. ####################################################################################
  10.  
  11. import Bladex
  12. import Reference
  13. import Menu
  14.  
  15. import Raster
  16.  
  17. import BUIx
  18. import BBLib
  19. import BInput
  20.  
  21. import darfuncs
  22. import GameText
  23. import TutorialScorer
  24.  
  25. fading_start_time=0
  26. logo_rebel = 0
  27. logo_friendware=0
  28. logo_blade=0
  29.  
  30.  
  31. last_demo_msg_time=0
  32.  
  33. demo_is_active=0
  34. prev_was_menu=0
  35.  
  36.  
  37.  
  38. LOGOS_FULL=1
  39.  
  40. TutorialScorer.ActivateTutorialScorer("../../Data/Letras menu med.bmp")
  41. TutorialScorer.wMultiText.SetColor(255,0,0)
  42.  
  43. LastMessage = 0
  44.  
  45.  
  46. OnEnterDemo=0
  47. OnExitDemo=0
  48.  
  49. def StaticLogoRebel(time):
  50.     global last_demo_msg_time
  51.     global logo_rebel
  52.     global logo_friendware
  53.     global logo_blade
  54.     global fading_start_time
  55.     global LastMessage
  56.  
  57.     alpha= (time-fading_start_time)*0.25
  58.     if alpha>0.8:
  59.         alpha=0.8
  60.     if alpha<0:
  61.         alpha=0
  62.  
  63.     if time-last_demo_msg_time>3.0:
  64.         GameText.WriteTextAux("Modo DEMO - pulsa una tecla",2.0,255,255,255,[])
  65.         last_demo_msg_time=time
  66.  
  67.     w, h = Raster.GetSize()
  68.  
  69.     Raster.SetPosition(w-136,h-90-5)
  70.     Raster.SetAlpha(alpha)
  71.     Raster.DrawBitmap(logo_rebel,128,90)
  72.  
  73.     Raster.SetPosition(10,h-110)
  74.     Raster.SetAlpha(alpha)
  75.     Raster.DrawBitmap(logo_friendware,128-20,128)
  76.     
  77.     Raster.SetPosition(w/2.0-128,-90)
  78.     Raster.SetAlpha(alpha)
  79.     Raster.DrawBitmap(logo_blade,256,256)
  80.  
  81.  
  82.  
  83. def FadeLogoFriendware(time):
  84.     global logo_friendware
  85.     global fading_start_time
  86.     if (time-fading_start_time<2):
  87.         alpha= (time-fading_start_time)*0.5
  88.     else:
  89.         alpha= 1.0-(time-fading_start_time-2)*0.5
  90.  
  91.  
  92.     if alpha>1:
  93.         alpha=1
  94.     elif alpha<=0:
  95.         alpha=0
  96.         if (time-fading_start_time>1):
  97.             Bladex.RemoveAfterFrameFunc("FadeLogoFriendware")
  98.             fading_start_time=Bladex.GetTime()+0.5
  99.             Bladex.SetAfterFrameFunc("StaticLogoRebel", StaticLogoRebel)
  100.  
  101.     Raster.SetPenColor(255,255,255)
  102.     Raster.SetAlpha(alpha)
  103.     if LOGOS_FULL==1:
  104.         Raster.SetPosition(110,0)
  105.         Raster.DrawBitmap(logo_friendware,Raster.GetSize()[0]-220,Raster.GetSize()[1])
  106.     else:
  107.         Raster.SetPosition(Raster.GetSize()[0]-256,Raster.GetSize()[1]-225)
  108.         Raster.DrawBitmap(logo_friendware,255,255)
  109.  
  110.  
  111.  
  112. def FadeLogoRebel(time):
  113.     global logo_rebel
  114.     global fading_start_time
  115.  
  116.     if (time-fading_start_time<2):
  117.         alpha= (time-fading_start_time)*0.5
  118.     else:
  119.         alpha= 1.0-(time-fading_start_time-2)*0.5
  120.  
  121.  
  122.     if alpha>1:
  123.         alpha=1
  124.     elif alpha<=0:
  125.         alpha=0
  126.         if (time-fading_start_time>1):
  127.             Bladex.RemoveAfterFrameFunc("FadeLogoRebel")
  128.             fading_start_time=Bladex.GetTime()+0.5
  129.             Bladex.SetAfterFrameFunc("FadeLogoFriendware", FadeLogoFriendware)
  130.  
  131.     Raster.SetPenColor(255,255,255)
  132.     Raster.SetAlpha(alpha)
  133.  
  134.     if LOGOS_FULL==1:
  135.         Raster.SetPosition(60,40)
  136.         Raster.DrawBitmap(logo_rebel,Raster.GetSize()[0]-120,Raster.GetSize()[1]-80)
  137.     else:
  138.         Raster.SetPosition(Raster.GetSize()[0]-256,Raster.GetSize()[1]-256)
  139.         Raster.DrawBitmap(logo_rebel,255,255)
  140.  
  141.  
  142.  
  143. def LaunchDemoCamera2(a,b):
  144.     global fading_start_time
  145.     global LastMessage
  146.  
  147.     fading_start_time=Bladex.GetTime()+1
  148.     Bladex.RemoveAfterFrameFunc("StaticLogoRebel")
  149.     Bladex.SetAfterFrameFunc("FadeLogoRebel", FadeLogoRebel)
  150.     darfuncs.LaunchMaxCamera("demo_travelling.cam",0,-1,LaunchDemoCamera)
  151.  
  152.  
  153. def LaunchDemoCamera(a,b):
  154.     darfuncs.LaunchMaxCamera("demo_travelling.cam",0,-1,LaunchDemoCamera2)
  155.  
  156.  
  157. import pdb
  158.  
  159. oldInputActionsSet = None
  160.  
  161. def FinishDemoFunc(x,y,z):
  162.     global Listener
  163.     global oldInputActionsSet
  164.  
  165.     print "Demo_Stuff.FinishDemoFunc called"
  166.  
  167.     InputManager=BInput.GetInputManager()
  168.     InputManager.SetInputActionsSet(oldInputActionsSet)
  169.     InputManager.GetAttachedDevice("Keyboard").RemoveListener("EndDemo")
  170.  
  171.     Listener = None
  172.     DemoLoop()
  173.  
  174.  
  175. def DemoLoop():
  176.     global fading_start_time
  177.     global demo_is_active
  178.     global prev_was_menu
  179.     global Listener
  180.     global LastMessage
  181.  
  182.     global CurrentPerson
  183.     global FinishPerson
  184.     global oldInputActionsSet
  185.  
  186.     AppMode=Bladex.GetAppMode()
  187.     import Scorer
  188.  
  189.     if AppMode=="Menu":
  190.         demo_is_active=1
  191.         prev_was_menu=1
  192.         print "DemoLoop-Menu2Demo"
  193.         Menu.ActivateMenu()
  194.         print "DemoLoop , activatemenu en menu2demo"
  195.         Bladex.SetAppMode("Demo")
  196.  
  197.         if OnEnterDemo:
  198.             OnEnterDemo()
  199.  
  200.         print "demo mode set up"
  201.         #Bladex.KillMusic()
  202.         Bladex.ExeMusicEvent( Bladex.GetMusicEvent("musica_loop_demo") )
  203.         fading_start_time=Bladex.GetTime()+1
  204.         Bladex.SetAfterFrameFunc("FadeLogoRebel", FadeLogoRebel)
  205.  
  206.         Listener=BInput.B_InputListener("EndDemo")
  207.         Listener.SetPythonFunc(FinishDemoFunc)
  208.         
  209.         InputManager=BInput.GetInputManager()    
  210.         oldInputActionsSet=InputManager.GetInputActionsSet()
  211.         InputManager.SetInputActionsSet("Demo")
  212.         InputManager.GetAttachedDevice("Keyboard").AddListener(Listener)
  213.  
  214.         Bladex.AddScheduledFunc(Bladex.GetTime()+0.1, LaunchDemoCamera,(0,0))
  215.         Scorer.SetVisible(0)
  216.  
  217.     elif AppMode=="Demo":
  218.         demo_is_active=0
  219.         Bladex.ActivateInput() #la funcion launchMaxcamera la habia desactivado!        
  220.         if prev_was_menu==1:
  221.             Menu.ActivateMenu()
  222.             print "DemoLoop-Demo2Menu"
  223.             print "set menu mode"
  224.             Bladex.SetAppMode("Menu")
  225.         else:
  226.             print "DemoLoop-Demo2Game"
  227.             print "NO set 2 menu mode"
  228.             Bladex.SetAppMode("Game")
  229.  
  230.         if OnExitDemo:
  231.             OnExitDemo()
  232.  
  233.         #Bladex.KillMusic()
  234.         Bladex.ExeMusicEvent(-1)
  235.         Bladex.RemoveAfterFrameFunc("FadeLogoRebel")
  236.         Bladex.RemoveAfterFrameFunc("FadeLogoFriendware")
  237.         Bladex.RemoveAfterFrameFunc("StaticLogoRebel")
  238.  
  239.         prev_was_menu=0
  240.  
  241.         cam=Bladex.GetEntity("Camera")
  242.  
  243.         if Bladex.GetCurrentMap()!="Casa":
  244.             cam.SetPersonView("Player1")
  245.             cam.Cut()
  246.             Bladex.SetListenerPosition(1)
  247.             Scorer.SetVisible(1)
  248.  
  249.     elif AppMode=="Game":
  250.         prev_was_menu=0
  251.         demo_is_active=1
  252.         print "DemoLoop-Game2Demo"        
  253.         Bladex.SetAppMode("Demo")        
  254.         print "demo mode set up"
  255.         #Bladex.KillMusic()
  256.         Bladex.ExeMusicEvent( Bladex.GetMusicEvent("musica_loop_demo") )
  257.         fading_start_time=Bladex.GetTime()+1
  258.         Bladex.SetAfterFrameFunc("FadeLogoRebel", FadeLogoRebel)
  259.  
  260.         if OnEnterDemo:
  261.             OnEnterDemo()
  262.  
  263.         Listener=BInput.B_InputListener("EndDemo")
  264.         Listener.SetPythonFunc(FinishDemoFunc)
  265.  
  266.         InputManager=BInput.GetInputManager()    
  267.         oldInputActionsSet=InputManager.GetInputActionsSet()
  268.         InputManager.SetInputActionsSet("Demo")
  269.         InputManager.GetAttachedDevice("Keyboard").AddListener(Listener)
  270.  
  271.         LaunchDemoCamera(0,0)
  272.         Scorer.SetVisible(0)
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283. #
  284. # Init 
  285. #
  286. def Init():
  287.     global logo_rebel
  288.     global logo_friendware
  289.     global logo_blade
  290.  
  291.     
  292.     #
  293.     # FUNC itself
  294.     #
  295.     if Reference.DEMO_MODE==1:
  296.         Bladex.SetMenuTgapFunc(DemoLoop)
  297.     else:
  298.         return
  299.  
  300.  
  301.  
  302.     #
  303.     # LOGO REBELACT
  304.     #
  305.     BBLib.ReadMMP("../../Data/logorebel.mmp")
  306.     logo_rebel=Raster.BmpHandle("LOGOREBELALFA")
  307.  
  308.  
  309.  
  310.     #
  311.     # LOGO CODEMASTERS
  312.     #
  313.     BBLib.ReadMMP("../../Data/logofriendware256.mmp")
  314.     logo_friendware=Raster.BmpHandle("LOGOFRIENDWARE")
  315.  
  316.  
  317.  
  318.     #
  319.     # LOGO SEVERANCE
  320.     #
  321.     BBLib.ReadMMP("../../Data/logoblade256.mmp")
  322.     logo_blade=Raster.BmpHandle("LOGOBLADE")
  323.  
  324.  
  325.  
  326.     #
  327.     # MUSICAS
  328.     #
  329.     Bladex.AddMusicEventMP3  ( "musica_loop_demo",     "..\\..\\Sounds\\tema.mp3",          0.1, 1.0, 1.0, 11000,     0, -1 )
  330.     Bladex.AddMusicEventMP3  ( "emptyloquesea_demo",   "",                                  0.1, 0.1, 1.0, 11000,     0, 0 )
  331.