It is quite hard to place ELSE - any easier way?

This forum is currently in read-only mode.
From the Asset Store
Spooky Places game assets for 2D endless runner action adventure game.
  • Currently I am having trouble with placing else in the event sheets, especially when I try to connect the else with the right condition.

    For instance, take a look here:

    <font face="Courier New, Courier, mono">

    if (user press Z){

    if (weapon is 1){

        if (user press UP){

          //shoot up

        }else if (user press DOWN){

          //shoot down

        }else{

          //shoot forward

        }

    }else if (weapon is 2){

        if (user press UP){

          //shoot up

        }else{

          //shoot forward

        }

    }

    }</font>

    Something like that. This is just one fraction of something bigger. There are more ELSE but placing these ELSE are quite a pain. It is very hard to snap them in the right places. Are there easier ways to deal with placing ELSE?

  • Could you please explain, what you want to achieve?

    Maybe I could suggest an alternative, but I need to know, what kind of game and effect you want to have.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Dont use else that too buggy, instead use a structure like and equivalent to C++ switch.

    something like this:

    + MouseKeyboard: Player 1 "fire" is down

    + player: Value 'weapon' Equal to 0

        + MouseKeyboard: Player 1 "upkey" is down

          -> player: Set animation to "fire_up_weapon0"

        + MouseKeyboard: Player 1 "downkey" is down

          -> player: Set animation to "fire_down_weapon0"

    + player: Value 'weapon' Equal to 1

        + MouseKeyboard: Player 1 "upkey" is down

          -> player: Set animation to "fire_up_weapon1"

        + MouseKeyboard: Player 1 "downkey" is down

          -> player: Set animation to "fire_down_weapon1"

  • You can do "Else if" like this:

    if (weapon is 1){

        if (user press UP){

          //shoot up

        }else{

            if (user press DOWN){

            //shoot down

            }else{

            //shoot forward

            }

    }else{

        if (weapon is 2){

            if (user press UP){

            //shoot up

            }else{

            //shoot forward

            }

        }

    }

    "Else if" is like puting an "if" inside an "else"...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)