home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / global / democharge.scr < prev    next >
Encoding:
Text File  |  2002-10-21  |  5.5 KB  |  252 lines

  1. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. //
  4. // global/democharge.scr
  5. //
  6. // used to give visual feedback of inventory status
  7. //   in the HUD when a democharge/stickbomb is been used
  8. //
  9. // author: Michael Goodwin
  10. //
  11. // setup:
  12. //
  13. // TODO:
  14. //
  15. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  16. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  17. main:
  18. end
  19.  
  20.  
  21. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. // charge_switch
  24. // - local.from            - index of image to switch from (corresponds to charge count)
  25. // - local.to            - index of image to switch to
  26. // - local.predelay        - amount of time to hold first image before switching
  27. // - local.holddelay    - amount of time to hold second image before fading out
  28. //
  29. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  30. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. charge_switch local.from local.to local.predelay local.holddelay:
  32.  
  33. charge_switch_loop:
  34.  
  35.     if ( (level.demochargeswitchsemaphore == NIL) || (level.demochargeswitchsemaphore == 0) )
  36.     {
  37.         local.icon = waitthread get_charge_icon local.from
  38.         local.icon2 = waitthread get_charge_icon local.to
  39.  
  40.         level.demochargeswitchsemaphore = 1
  41.         waitthread do_switch local.icon local.icon2 local.predelay local.holddelay
  42.         level.demochargeswitchsemaphore = 0
  43.     }
  44.     else
  45.     {
  46.         wait 0.1
  47.         goto charge_switch_loop
  48.     }
  49.  
  50. end
  51.  
  52.  
  53. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  54. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  55. //
  56. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  57. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  58. get_charge_icon local.which:
  59.  
  60.     switch ( local.which )
  61.     {
  62.         case 0:
  63.             local.icon = "textures/hud/democharge0"
  64.             break
  65.  
  66.         case 1:
  67.             local.icon = "textures/hud/democharge1"
  68.             break
  69.  
  70.         case 2:
  71.             local.icon = "textures/hud/democharge2"
  72.             break
  73.  
  74.         case 3:
  75.             local.icon = "textures/hud/democharge3"
  76.             break
  77.  
  78.         case 4:
  79.             local.icon = "textures/hud/democharge4"
  80.             break
  81.  
  82.         case 5:
  83.             local.icon = "textures/hud/democharge5"
  84.             break
  85.  
  86.         case 6:
  87.             local.icon = "textures/hud/democharge6"
  88.             break
  89.  
  90.         case 7:
  91.             local.icon = "textures/hud/democharge7"
  92.             break
  93.  
  94.         case 8:
  95.             local.icon = "textures/hud/democharge8"
  96.             break
  97.  
  98.         case 9:
  99.             local.icon = "textures/hud/democharge9"
  100.             break
  101.  
  102.         default:
  103.             println "~~~~~~~~~~~~~~~~~~~~~~~ invalid charge icon"
  104.             break
  105.     }
  106.  
  107. end local.icon
  108.  
  109.  
  110. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  111. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  112. // sticky_switch
  113. // - local.from            - index of image to switch from (corresponds to charge count)
  114. // - local.to            - index of image to switch to
  115. // - local.predelay        - amount of time to hold first image before switching
  116. // - local.holddelay    - amount of time to hold second image before fading out
  117. //
  118. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  119. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  120. sticky_switch local.from local.to local.predelay local.holddelay:
  121.  
  122. sticky_switch_loop:
  123.  
  124.     if ( (level.demochargeswitchsemaphore == NIL) || (level.demochargeswitchsemaphore == 0) )
  125.     {
  126.         local.icon = waitthread get_sticky_icon local.from
  127.         local.icon2 = waitthread get_sticky_icon local.to
  128.  
  129.         level.demochargeswitchsemaphore = 1
  130.         waitthread do_switch local.icon local.icon2 local.predelay local.holddelay
  131.         level.demochargeswitchsemaphore = 0
  132.     }
  133.     else
  134.     {
  135.         wait 0.1
  136.         goto sticky_switch_loop
  137.     }
  138.  
  139. end
  140.  
  141.  
  142. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  143. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  144. //
  145. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  146. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  147. get_sticky_icon local.which:
  148.  
  149.     switch ( local.which )
  150.     {
  151.         case 0:
  152.             local.icon = "textures/hud/stickybomb0"
  153.             break
  154.  
  155.         case 1:
  156.             local.icon = "textures/hud/stickybomb1"
  157.             break
  158.  
  159.         case 2:
  160.             local.icon = "textures/hud/stickybomb2"
  161.             break
  162.  
  163.         case 3:
  164.             local.icon = "textures/hud/stickybomb3"
  165.             break
  166.  
  167.         case 4:
  168.             local.icon = "textures/hud/stickybomb4"
  169.             break
  170.  
  171.         case 5:
  172.             local.icon = "textures/hud/stickybomb5"
  173.             break
  174.  
  175.         case 6:
  176.             local.icon = "textures/hud/stickybomb6"
  177.             break
  178.  
  179.         case 7:
  180.             local.icon = "textures/hud/stickybomb7"
  181.             break
  182.  
  183.         case 8:
  184.             local.icon = "textures/hud/stickybomb8"
  185.             break
  186.  
  187.         case 9:
  188.             local.icon = "textures/hud/stickybomb9"
  189.             break
  190.  
  191.         default:
  192.             println "~~~~~~~~~~~~~~~~~~~~~~~ invalid stickbomb icon"
  193.             break
  194.     }
  195.  
  196. end local.icon
  197.  
  198.  
  199. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  200. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  201. //
  202. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  203. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  204. do_switch local.fromicon local.toicon local.predelay local.holddelay:
  205.  
  206.     if ( local.predelay == NIL )
  207.         local.predelay = 0.25
  208.     if ( local.holddelay == NIL )
  209.         local.holddelay = 2.75
  210.  
  211.     local.hudindex = 77
  212.     local.finalalpha = 0.8
  213.     local.alphastep = 0.12
  214.  
  215.     huddraw_alpha local.hudindex 0
  216.     huddraw_align local.hudindex right top
  217.  
  218.     huddraw_shader local.hudindex local.fromicon
  219.  
  220.     local.xpos = -78
  221.     if ( (level.item_total != NIL) && (level.item_total > 0) )
  222.         local.ypos = 72
  223.     else
  224.         local.ypos = 8
  225.     huddraw_rect local.hudindex local.xpos local.ypos 64 64
  226.  
  227.     for ( local.i = 0.0; local.i <= local.finalalpha; local.i += local.alphastep )
  228.     {
  229.         huddraw_alpha local.hudindex local.i
  230.         waitframe
  231.     }
  232.  
  233.     huddraw_alpha local.hudindex local.finalalpha
  234.     wait local.predelay
  235.  
  236.     huddraw_shader local.hudindex local.toicon
  237.  
  238.     wait local.holddelay
  239.  
  240.     for ( local.i = local.finalalpha; local.i > 0.0; local.i -= local.alphastep )
  241.     {
  242.         huddraw_alpha local.hudindex local.i
  243.         waitframe
  244.     }
  245.  
  246.     huddraw_alpha local.hudindex 0
  247.  
  248. end
  249.  
  250.  
  251.  
  252.