Navigation

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

    enemy's death condition/animation

    Beginners
    3
    5
    331
    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.
    • waldron
      waldron F last edited by

      so at the moment my enemies die if i jump on them (detects velocity) but i want them to die from a button press say X which is my attack button .?
      then could i trigger the enemy's death animation with
      if player 1 c.x enemy = death ......

      1 Reply Last reply Reply Quote 0
      • pobtastic
        pobtastic F last edited by pobtastic

        The way I've been handling things like this, is that I give each sprite a state. Rather than control everything directly, certain "actions" cause the state to change ~ then the last (or first) thing to happen is for that state to be actioned. It's kind of like;

        IDLE = 0
        UP = 1
        DOWN = 2
        LEFT = 4
        RIGHT = 8
        JUMP = 16
        FALLING = 32
        DEAD = 64
        

        I use bitwise comparisons to set multiple states for a sprite, e.g. Willy is JUMPing LEFT, or JUMPing RIGHT but also can simply be JUMPing. Anyways, for example the directions cause the state to change to LEFT or RIGHT and then the result of that state change happens later not right at the time of the action. This allows me to also set a state of say, FALLING when applying gravity which isn't untriggered until Willy is either DEAD or he lands (IDLE).

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

          So then jumping left would return 20?

          pobtastic 1 Reply Last reply Reply Quote 0
          • waldron
            waldron F last edited by

            Oh I get it same as you would set states for your character you do the same for the enemy and code the actions in

            1 Reply Last reply Reply Quote 0
            • pobtastic
              pobtastic F @lawyerlounge last edited by

              @waldron said in enemy's death condition/animation:

              Oh I get it same as you would set states for your character you do the same for the enemy and code the actions in

              Yeah absolutely! There's no reason why not right?! ;)

              @lawyerlounge said in enemy's death condition/animation:

              So then jumping left would return 20?

              Yeah, that's it! And you test the condition with e.g.

              if game.willy.state == LEFT | JUMP then
                // Willy is jumping left.
              endif
              
              1 Reply Last reply Reply Quote 0
              • First post
                Last post