• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

if statements

  1. M

    Computing Result from a Percentage Dice Roll

    Hello, I am making a game where a player will make a gold bet and then a 100d dice roll is made to modify the bet made whether add X amount, subtract X amount, multiply by X or divide by X. I haven't decided the best practice whether using "choose()", or a state machine system or what I have...
  2. F

    GML Time based if statements

    Hello, is there a way to make a time based if statement. I have searched for a while but havent found anything. What I want: if (maxSpeed for 2 seconds) { bla bla bla } Any help is very much appreciated
  3. D

    SOLVED Detecting a button press two separate times, but they register simultaneously

    Hello there. I have an object used for dialogue called "obj_combatIntroDiag" and inside of it i have the following code: /// @description draw the text in the box (DRAW EVENT) draw_self(); draw_set_font(global.fnt_b); draw_set_color(c_black) if dialogue_on == true { // Set current sprite...
  4. M

    instance_destroy() occuring too early

    I'm currently making a platform-esque game where 2 players are shot up into the room and have to bounce on cloud platforms to stay on-screen. I'm having issues with my instance_destroy() command, as it's preventing the clouds from spawning/destroying them too early. The code I'm using is...
  5. flyinian

    How to deal with lots of true/false arguments

    Example: I have a job in my game and lets say it requires over 1000 requirements. In order for the player to apply for this job, they must meet or exceed all of the requirements. How should I go about doing this? The below code is how I would be doing it. if (requirement1 >= 1 && requiremnt2...
  6. flyinian

    SOLVED Getting a sprite to switch between three sub images

    I am trying to get a sprite to switch through three sub images. If the player doesn't have the requirements to activate the button, display sub image 2. If the player has the requirements, Turn the sprite to sub image 1. if the player has the requirements and clicks on the sprite/instance, turn...
  7. 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...
  8. HATER

    Need help with IF SCORE code

    The if statement that is shown is trying to get the score code from obj_counter_15_red. when I put the global code (score) nothing happens. If I put this same code in drag and drop and make the IF SCORE apply to the same object, it works. Can someone tell me the syntax for IF SCORE to apply to...
  9. D

    GameMaker If statement not working

    I've been trying to make a spawner in a game and the code wont spawn anything. in the step event if(obj_stats.level < 5 and spawn == true) { alarm[0] = 30 spawn = false alarm[2] = 32 } else if(obj_stats.level < 10 and spawn == true){ alarm[0] = room_speed * 7.5 alarm[1] =...
  10. M

    Legacy GM Not reading initialized variables [SOLVED]

    Hey coders, As I am new to this forum I was hoping to get some help on a issue I have some time in my code and cannot get fixed myself. The context is that I am making a simple tower defense game for my IT classes. The specific problem is that I want my towers to be able to level. For this I...
  11. E

    GML Controller Connect Sound

    Hi GM community! I am trying to make it so that if a controller is connected, a sound will play. So far I have not been able to stop it from playing repeatedly nonstop (this code is in a step event btw) whilst the controller is connected. any ideas on what could be changed to make it work? var...
  12. F

    Help!!!

    Ok, so I am making a game and i've hit a problem. this is what I'm trying to do. If (keyboard_check(vk.right)): if (keyboard_check(vk_left)): go left else: go right The problem is is this concept correct and can you do if statements in if statements and finally how to do else
  13. W

    Too many conditions

    How many conditions are too many when it comes to booleans or anything else in a game? Because I just finished setting up my view map stuff for the player and there's quite a few checks I need to make sure everything happens how I want. It works but I just wonder is it normal to have so many...
  14. R

    Legacy GM Problems with if statements

    I have a set of if statements that are not executing like it should. The player name starts as an array of 9 characters due to an algorithm that will do something based on math done on the asni char values of the characters. The array is then put into a test string and checked. The set of code...
  15. B

    [CLOSED] Help with my "if" and "while" statement

    Hi, I have an If statement with two while statements in it. My game keeps crashing due to it. if aggression = 3{ while distance_to_object(obj_player) < 300{ image_angle = point_direction(x, y, obj_player.x, obj_player.y); } while distance_to_object(obj_galaxy_npc) < 300{...
  16. A

    GML Attack Phases/Player Distance [SOLVED]

    I have an enemy that will use different patterns of attack depending on how close the player is to said enemy. however I am not sure how to use the && symbol when trying to make additional conditions in an if statement in regards to the distance of the player. Here is a sample of my code: if...
  17. A

    Legacy GM mouse_check_button(mb_right) issue.

    I'm designing a RPG character sheet and right now what i have is a button that opens an image (the sheet itself) with its fields. I have an object (obj_ficha) with this sprite: I want to click the little circles in order to fill them, representing the points invested in character creation, so...
  18. R

    Legacy GM Some help with dialogue

    Hi again everyone! I'm almost disappointed I needed to come and bother everyone here with this question, because for the first time I actually felt like I was beginning to get the hang of GML. It seems though that I may have hit a bit of a brick wall, so I was wondering if you fantastic people...
  19. C

    How to check if an object was clicked

    Hello - Currently I'm trying to figure out how to check if an object was click. Sort of like: if (object was clicked) { x += 1 } How would I go about doing that? What I'm trying to do is have a player buy a weapon and then let them have the ability to switch weapons IF they clicked...
  20. B

    Windows {solved} Get speed compared to image_angle

    Hallo I'm a noob and i can't seem to figure out how you can make a tjek to see if an objekt is moving downward will not facing downward. The resound for this, is that am making a plane which accelerate with forward with W and turns op and down with A and D. But the plane is also affected by...
Top