if else code

  1. Diegoegoeog

    SOLVED What code line is the best?

    I have these 2 code lines for act in sprite anim. I prefer use switch case, but in comparison with if else, seems more slow or something. Switch Case //Sprite Animation var spriteAnim = abs(sign(velocity_[vector2_x])); switch(spriteAnim) { case 0: sprite_index =...
  2. R

    Windows distance_to_object in the left or right side of the player

    I need a get right or left side of distance_to_object(Pak). For example if distance_to_object(Pak) < 80 only in the left side of the player. (distance_to_object(Pak) < x - 80) // ?????
  3. FrostyCat

    GML Why Yin-Yang if Blocks suck

    Why Yin-Yang if Blocks suck GM Version: N/A Target Platform: All Download: N/A Links: N/A Overview This article aims to document the rookie anti-pattern of adjacent opposite if blocks (i.e. if (xyz) { ... } if (!xyz) { ... }), its pitfalls and what to use instead of it. What are Yin-Yang if...
  4. E

    GML Global Variables not being updated

    Hey coders, I initialise all my global variables in my first page. When i move into a fight i want the if/else statements to allow for me to create a battle system but the global variables are not being updated. (Also to note the global.MonsterSpeed> global.Spd is always called even if Spd is...
  5. U

    How to change sprite/function when certain criteria are met?

    I want to set things up so that certain objects have different sprites and functions depending on the number a variable is at. Such as only being able to select the load game option if the 'saved games' variable is at or above 1. I know it's a matter of using the 'if' statement but I'm having...
  6. A

    GMS 2 [SOLVED]The instance create layer coding does not work within the if else statements?

    The instance create layer coding statement does not create any object inside my if else statements? Here is my code for my object0.Draw Event to draw out my yellow colored sprite0 object. draw_sprite(sprite0,1,x,y); Here is my code for my object0.Left Down , so when I have pressed my left...
  7. W

    If Else not working??

    Hi all This code not working in GM studio 2. Player dies and no new player appears. if (global.life > 0) { global.life = global.life - 1; instance_create_depth(room_width/2,room_height/2,0,obj_player) } else { instance_create_depth(0,0,0,obj_gameover) } any ideas will be appreciated.
Top