• 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!

for loop

  1. Hirou

    SOLVED How could I accomplish this for loop to stop if an object is on the way so it can stop before reaching the condition.

    Sorry if my title was vague since this is more of a technical question. I have this code that creates tiles that let the player move to, the thing is that I want this for loop to stop if o_piece, in this case is on the way. Any ideas on how to accomplish this? case BISHOP...
  2. Dinh Quoc Trung

    For loop never end

    Hello everyone. I have a question: /// EXAMPLE 1 for (masd=1; masd<2; masd+=1) { show_message(string(masd)) }; /// EXAMPLE 2 for (masd=0; masd<2; masd+=1) { show_message(string(masd)) }; But it didn't stop! Example 1: msad = 1, never stop !!! Example 2: msad = 0 and 1, , then 0,then 1...
  3. T

    GML How do I draw a list of items on multiple rows once the list has reached a certain size?

    Hi. I consider myself a decent enough programmer for the most part, but I've never quite wrapped my head around loops, beyond their most basic uses. I just recently started remaking my game's inventory system, which works fine for the most part, but one thing is driving me insane, and I know...
  4. Y

    *CLOSED* Not reading array in order

    Hello, I have had little luck here, but I will try again. I have an array that i stash values to and if there is nothing to stash the index stays an empty string.I draw this to the screen using a for loop (see below). But when it is drawing to the screen it is not drawing in order even though...
  5. M

    Lag from too many instances with for loops

    I've searched high and low but can't seem to find how performance heavy FOR LOOPS are. I have an object that runs a for loop with no issue, but as soon as I create 10+ instances of the same object, the FPS drops below 60fps. The more instances on screen, the lower the FPS - all the way down to...
  6. mmmmmmmmmmmmm

    [SOLVED] Loop not creating array or list of arrays as expected

    I'm trying to use a for loop to create an array of arrays and I have no clue why it doesn't work. The same problem is encountered if I try to use a DS list of arrays. A reproduction of my code is: var k = 4; var array; var list = ds_list_create(); for (var i=0; i<k; ++i) { var t...
  7. G

    How do I loop over an array?

    Dear GMS2-community, I'm trying to loop over an array using the following bit of code: Click event object Q: a[0] = 0; a[1] = 3; a[2] = 5; for(i = 0; i < 3; ++i; ) if(instance_number(global.obj_target[a[0]])=0){ instance_create_layer( xx, yy, "Instances", global.obj_target[a]) } But for...
  8. D

    For Loop not working

    Just updated to the most recent version (2.3.1) and my For loops have suddenly stopped working and I don't know why. I found it odd that the new one I did wasn't working, even though I had one running perfectly fine last week or two, but even that one is broken right now. Checked the usual...
  9. I

    Solved - Drawing Rectangle over time in GUI

    Hi, I have some semi-working code in my project that runs a script when the player clicks on certain tiles in-game. I'm struggling with slowing things down to get a smooth look! What I want to happen is: The player clicks the tile. A small blue bar appears in the tile below and fills from...
  10. K

    change multiple variables value in a for loop

    hello everyone. i'm new to coding in general and i was wondering if you can help me with this problem: i have this variables global.StatLvl1 = 2 global.StatLvl2 = 2 global.StatLvl3 = 2 global.StatLvl4 = 2 global.StatLvl5 = 2 global.StatLvl6 = 2 global.StatLvl7 = 2 global.StatLvl8 = 2...
  11. C

    GML [Resolved] Difficulty with arrays and for loops

    I'm trying to code a basic turn-based battle system where each character has a variable called "time," which, when it hits 0, allows that character to select a move (think ATB system in Final Fantasy in reverse?) I made a ds_map for each character, and then, for the battle system, made...
  12. Z

    (SOLVED) Changing a group of instances with the same pre-condition

    Hi everyone! I have an object that is spread across a room, meaning there are many instances of that object. In the instances creation code (not in the object create event, but in the instances creation code in the room editor) I gave "groups" of these instances a specific value. Some of these...
  13. T

    Objects Id connected to draw sprite

    Hello everyone. Have a cool person who used pseudo code to help me understand. I'm pretty sure im getting it but something isnt working right and Im not sure. Been reading in on for loops, with statements and ds_list for days. Been on this issue a little long and think it's time to ask for...
  14. C

    GameMaker Does GMS2 use multithreaded for?

    DIfferent programming languages like C# or C++ offer the option to use a for loop that runs in parallel creating different threads wich is faster than the regular and other languages like Java use this type of for as their standard one. Do any of the compilers for Game Maker Studio 2 use...
  15. E

    GML Getting Weird Behavior in a Widget

    I've been staring at this code for an hour and I need a fresh set of eyes. I made a color-picker widget for a thing. It looks like this, and it works by clicking on the number you want to change and dragging either left or right. It all works too, except for this one weird bug I can't figure...
  16. M

    GML Help with FOR LOOPS

    Hi All, I am making a game. The player has no hp at the start, but with each 3 hearts that he gathers, one hp is added. I tried with if statement, with do... until, and I tried a for loop, but nothing seems to work. It either adds just one hp and stops there, or keeps adding infinite number of...
  17. E

    Legacy GM [SOLVED] "for" statement for arrays malfunction

    Hello, fellas. I have a small problem with using “for” statement to set all the arrays to 0 by subtracting them while they are not smaller or equal to 0. So when all my arrays are smaller or equal to 0, the object needs to be destroyed. But it does not work as I expected: object is destroying...
  18. A

    GameMaker Iterating through DS List Works when Debugging only [Solved]

    I have encountered a bug in my code when I attempt to iterate over a ds_list containing objects returned from a json file. When the application runs normally this error appears, as well as when I debug the code and hit F5 to move to the break point after the for loop (the error on line 23...
  19. F

    painting with a for loop

    Hi there I am building a paint-like program and I've run into some trouble. I have a brush size manager called scalemanager which let's say has its scale variable set to 5, it should be creating 5 rows of black boxes 1 pixel in width in height but instead after reaching the end of the second or...
  20. W

    Legacy GM Drawing Object sprites from a ds_list[solved]

    I need to draw the sprites of objects I store in a list but every time I try for some reason my inventory object draws my sprite above the object writing the code no matter where I put the y value. I'm just doing a loop and drawing whatever's in the array at the checked position if there's...
Top