A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Trying to create a smart, scalable weapon HUD :/

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    15

    Trying to create a smart, scalable weapon HUD :/

    First, what I want the weapon hud to do, is jump past the weapons that don't have any ammo and stop at the next one that has. And as soon as the selected weapon runs out of ammo, I want the weapon hud to go to the first weapon ("regular") which has got infinite bullets.

    My problem is basically that I'm still a beginner when it comes to programming, and I simply don't know how to do that :(
    I've tried everything I know; for-loops, arrays, if's, switches (as seen below) etc. but this problem might be more advanced than I can handle at the moment...

    Right now, the weapon hud consists of three frames (named "regular", "auto" and "fire"), which the player can navigate through to select the weapon of choice. This is done with the following code (I also have a similar code block for SHIFT + LEFT...):

    Actionscript Code:
    if (SHIFT && RIGHT && DOUBLE_TAP && nextWpnAmmo != 0) {
                   
                    if (Engine.weaponHUD.currentFrame == Engine.weaponHUD.totalFrames) {
                        Engine.weaponHUD.gotoAndStop("regular");
                        DOUBLE_TAP = false;
                       
                    }
                    else {
                        Engine.weaponHUD.nextFrame();
                        DOUBLE_TAP = false;
                    }
                   
                }

    - SHIFT and RIGHT means those keys have to be pressed.
    - DOUBLE_TAP is a kind of lock feature I have to prevent the weapon hud from changing more than one weapon at a time.
    - nextWpnAmmo is a variable that represents the current ammo count in the next weapon hud slot.

    I have a function that checks available ammo, among with some other stuff. This is how it looks:

    Actionscript Code:
    private function checkAmmo():void {
               
                switch (currentWeapon) {
                   
                    case "regular":
                    currentWpnAmmo = Engine.regularMAX;
                    nextWeapon = "auto";
                    nextWpnAmmo = Engine.autoMAX;
                    prevWpnAmmo = Engine.fireMAX;
                    break;
                   
                    case "auto":
                    currentWpnAmmo = Engine.autoMAX;
                    nextWeapon = "fire";
                    nextWpnAmmo = Engine.fireMAX;
                    prevWpnAmmo = Engine.regularMAX;
                    break;
                   
                    case "fire":
                    currentWpnAmmo = Engine.fireMAX;
                    nextWeapon = "regular";
                    nextWpnAmmo = Engine.regularMAX;
                    prevWpnAmmo = Engine.autoMAX;
                    break;
                   
                }
               
                // Jump to next available weapon with ammo
               
                if (currentWpnAmmo == 0) {
                    Engine.weaponHUD.nextFrame();
                }
                if (Engine.weaponHUD.currentFrame == Engine.weaponHUD.totalFrames && currentWpnAmmo != 0) {
                    Engine.weaponHUD.nextFrame();
                }
                else if (Engine.weaponHUD.currentFrame == Engine.weaponHUD.totalFrames && currentWpnAmmo == 0) {
                    Engine.weaponHUD.gotoAndStop("regular");
                }
               
            }


    I've changed the above code MANY, many times, btw...

    So, now i turn to you FlashKit, please help me! (>_<) I want to move on to the other parts of the game, but this problem is stopping me from doing that :(

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Moved to games.
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center