Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Enemy health?

    Beginners
    4
    8
    341
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • poof92
      poof92 last edited by

      I have multiple enemy images and I have multiple health variables for each! How would I assign the correct variable to the correct enemy?
      20211023_201945.jpg 20211023_201941.jpg

      1 Reply Last reply Reply Quote 0
      • pianofire
        pianofire Fuze Team last edited by pianofire

        You can assign user defined properties to sprites: https://fuzearena.com/forum/topic/521/sprite-properties?_=1634995896862

        So create a sprite from your images and then add properties

        monsterImage = loadimage("Untied Games/Creeper")
        monster1 = createsprite()
        setspriteimage(monster1, monsterimage)
        monster1.health = 100
        
        1 Reply Last reply Reply Quote 3
        • waldron
          waldron F last edited by

          If an enemy has low hit points and to save on variables I'v started using rgba values, so on each hit it would minus enemy1.r -= .1 then if enemy.r <= .5 it gets removed. You could do it in many ways you could increase there speed and access it that way to get some extra challenge to the fight.

          1 Reply Last reply Reply Quote 1
          • poof92
            poof92 last edited by

            Thanks so much I'll give it a shot

            1 Reply Last reply Reply Quote 0
            • Ben 2.0
              Ben 2.0 last edited by

              I like to use a data table to store the Information.
              Enemydata = [
              [.img = loadimage("image1"), .health = 5],
              [.img = loadimage("image2"), .health = 10]
              ]

              poof92 1 Reply Last reply Reply Quote 3
              • poof92
                poof92 @Ben 2.0 last edited by

                @ben-2-0 how would I access a data table?

                1 Reply Last reply Reply Quote 0
                • Ben 2.0
                  Ben 2.0 last edited by

                  Enemyid = random(len(enemydata))
                  Enemy.img = enemydata[enemyid].img
                  Enemy.health = enemydata[enemyid].health

                  Something like this. This picks a random enemy from the table and gives it the values inside the inner tables. This is kinda complex so if you are just starting out you may not want to use this method.

                  1 Reply Last reply Reply Quote 1
                  • poof92
                    poof92 last edited by

                    I got it working thanks everyone

                    1 Reply Last reply Reply Quote 2
                    • First post
                      Last post