HUD.as – Heads Up Display


// Authors: Team 2: Andrew Bertino, Aaron Sagan, Matt Bloise, Michael Luongo
// Email: abertino@fiea.ucf.edu, asagan@fiea.ucf.edu, mbloise@fiea.ucf.edu, mluongo@fiea.ucf.edu
// File: HUD.as

package 
{
     import net.flashpunk.Entity;
     import net.flashpunk.FP;
     import net.flashpunk.graphics.Spritemap;
     import net.flashpunk.Screen;
     import net.flashpunk.graphics.Image;
     import net.flashpunk.Sfx;
     import net.flashpunk.utils.Input;
     import net.flashpunk.utils.Key;
     
     public class HUD extends Entity
     {
          private var hudArrowRef:HUDArrow;
          
          [Embed(source = '../assets/art/hud.png')] 
          private const HUD_DISPLAY:Class;

          public var theHUD:Image = new Image(HUD_DISPLAY);
          
          public function HUD():void 
          {
               graphic = theHUD;
               type = "HUD";
               
               layer = -1;
               
               this.x = 185;
               
               //Create arrow
               hudArrowRef = new HUDArrow();
               FP.world.add(hudArrowRef);
               hudArrowRef.setArrowX(227);
          }
          
          override public function render():void
          {
               super.render();
               this.graphic.scrollY = 0;
          }
          
          override public function update():void
          {
               //KEYBOARD
               if ( (Input.check(Key.DIGIT_1)) || (Input.check(Key.NUMPAD_1)) )
               {
                    setSpawnType(1);
                    hudArrowRef.setArrowX(224);
               }
               else if ( (Input.check(Key.DIGIT_2)) || (Input.check(Key.NUMPAD_2)) )
               {
                    setSpawnType(2);
                    hudArrowRef.setArrowX(313);
               }
               else if ( (Input.check(Key.DIGIT_3)) || (Input.check(Key.NUMPAD_3)) )
               {
                    setSpawnType(3);
                    hudArrowRef.setArrowX(385);
               }
               else if ( (Input.check(Key.DIGIT_4)) || (Input.check(Key.NUMPAD_4)) )
               {
                    setSpawnType(4);
                    hudArrowRef.setArrowX(467);
               }
          }
          
          private function setSpawnType(spawnTypeToSet:uint):void
          {
               if (GameWorld.TURN_OFF_HUD_SELECTING == false) {
                    trace("Spawn setting changed.");
                    GameWorld.spawnType = spawnTypeToSet;
               }
          }
     }
     
}