Character Parameter

  • #1, by priabudimanWednesday, 14. January 2015, 12:09 5 years ago
    Hello! ;-D

    Guys, i need to work on a player character health, health bar, and make it reduce every couple minutes/seconds. I want to make the game over once the player characters health depleted.

    i wonder if you can help me with the scripts to do so?

    Thank you in advance!

    Newbie

    12 Posts


  • #2, by afrlmeWednesday, 14. January 2015, 12:35 5 years ago
    You could easily use the value system, an interface & an animation to do this.

    1. create a value & assign a max health value to it.

    2. create a single image that represents the full health bar image.

    3. take note of the width (in pixels) of the image, as you will need to calculate how many pixels to offset the image based on the width of the image vs. current health value. Ideally if the image was 100px or 200px wide then it would be much easier to calculate.

    4. create an interface, create a button, add an animation to it containing the health bar image.

    5. create the interface area. it should be the exact shape/size of the health bar image. This way when you start moving image to left or right, any parts of image past the defined area will be masked out, or at least they should be.

    Check out this button mash demo I made ages ago @ https://www.dropbox.com/sh/9t8yr643oivzknb/AABpQCD5MRHKodYLB...

    It featured a simple bar that filled up each time I pressed the "x" key on the keyboard.

    6. To have it automatically reduce health you could trigger a loop inside of a called by other action at the begin of each playable scene.
    pause for x minutes/milliseconds/seconds
    if value 'value_name' more than 1
    set value 'value_name' - 1
    else
    -- do/call game over actions
    quit action 'this_called_by_other_actions_name'
    end if
    jump to action part #1
    1
    2
    3
    4
    5
    6
    7
    8
    9


    There's other methods you could use too such as a fully animated bar/icon that represents health or even a health bar represented by numbers like in some of the old FPS games, such as: Doom, Duke Nukem & Quake, etc.

    Imperator

    6808 Posts

  • #3, by priabudimanWednesday, 14. January 2015, 13:55 5 years ago
    This is awesome, thank you so much for your help, ill try and check it out!

    Newbie

    12 Posts

Write post