for

  1. FrostyCat

    GML GML Joseki Series: for Block Recipe Cards

    GML Joseki Series: for Loop Recipe Cards GM Version: GMS 2.3+ Target Platform: All Download: N/A Links: N/A Summary: A quick reference for a range of common use cases for the for loop. Summary This guide documents a number of common for loop patterns, best practices, and novice mistakes as...
  2. G

    Grid of Maps Question

    Hi All, I am working on a project that involves populating a ds_grid (jigsaw puzzle) with a number of maps (which contain info about the tabs and slots of the puzzle pieces). Ideally, the grid and map would be initialized, and then nested for loops iterate through the x and y coordinates...
  3. S

    Trouble getting out of loop when creating instances on my Enemies

    So I am trying to make a multi layered shield (randomly set) anywhere from 1 to 3 objects on top of my enemy and each shield chooses a different frame depending on what layer it is. theres 3 different color shields and I want it to choose 1 color per layer but for some reason it continues the...
  4. YamboGames

    For-Loop Issue / Question

    Hey, I have no Idea why this is not working. Can you guys explain that to me? In Java i can initialize multiple variables in one for loop. Gamemaker gives me an error :(
  5. josyanf1

    GML Different objects in a 'for' loop (SOLVED)

    Hi all! Programming objects that have different directions I thought I could make a for loop to optimize code. I usually do it this way to assign attributes to an object: var particle_1 =instance_create(x,y,obj_firework_particle); with particle_1 {direction = 30}; var particle_2...
  6. M

    GML [SOLVED, IM DUMB] Strange issue that makes a "for" stop drawing a text to the screen.

    (all the code and the project at the end) this is form gms2 I need help from experienced developers because i'm new and i'm facing a strange issue with drawing a menu. I have watched a tutorial on you tube that explains how to make GUI menu. The video explains how make the menu react to y...
  7. M

    Destroying and creating objects in the same step

    Step event for enemy: if (collision_circle(x,y,320*vision_size,p,true,false)){//If player is inside the enemy vision //Note: p stands for obj_player var recover; var i; var detected = false for(i = 0; detected = false; i += 1){ collision =...
  8. M

    Bullets not spreading correctly

    im making some test attacks, one of them is this: alarm 0: var bull; for(bull = 200; bull != -300; bull -= 100){ with instance_create(x,y,obj_bullet){ direction = point_direction(x,y,obj_playerparent.x,obj_playerparent.y + bull); } } and the result was exactly what i want, if...
  9. P

    GMS 2 [SOLVED] Can I set the size of a ds_list without a for loop?

    I want to make a ds_list that is n values long. Can I do this in GML without using a for loop?
  10. P

    GMS 2 [ SOLVED ] repeat/for loop not working as intended

    This is the code: repeat (instance_number(obj_work_table)) { var xx = obj_work_table.x; var yy = obj_work_table.y; var notif = obj_notif_arrow_down; var notif_x = xx; var notif_y = yy - 450; // Create the arrow notification above the workbench notif_work_table =...
  11. MartinK12

    GML [SOLVED] Simple code to move object's x using for is not working

    I'm working in GMS2 on simple code than will move object 100px left when clicked and I want this move to be slow. I don't want to use alarms and I think simple for should do it but it's not working - object is moving instantly to position = x - 100px, and I want to move it slowly. if clicked {...
  12. Carloskhard

    GML Passing "i" in "for" function to script inside it[SOLVED]

    This may be a stupid question but I have a 'for' loop and inside I'm running a script, and inside that script I need to know that "i" number. Up until yesterday I was using just "i" inside the script and the script was reading "i" perfectly.However in today's version of the proyect "i" is not...
  13. Pfap

    Help understanding continue and for loops

    Hi, when you use the continue key word doe it automatically add to the value of the iterator? repeat(4){ show_debug_message(i); if is_undefined(id_sprite[i]){ show_debug_message(i); show_debug_message("continuing"); continue; } show_debug_message(i); if id_sprite[i].sprite_index ==...
  14. Fixer90

    GMS 2 DS Lists - Not enough room in this town for the both of us. (SOLVED)

    I'm trying to find out a way to check a DS list to see if it has 2 or more of the same string in it, and remove any that are in the earlier part of the list, where if I were to add a string to the DS list, all the copies of it that were in there before get removed. I'm experimenting with for...
  15. PlayerOne

    GMS 2 draw objects within camera view & re-initialize a for loop?

    As I'm about to complete my inventory system I have 2 problems that I can't resolve on my own. 1) How do you draw objects to the GUI and having said objects follow within the camera? I know this is possible given that I have the code for GM8 lite, but since transitioning to GMS2 the code itself...
  16. WimpyLlama

    Is there a limit to how many "For" loops you can have

    I was working on a placing system for blocks, and I needed to make it so you couldn't place certain ID numbers, which were items. The placing system already had 2 "for" loops, but when I added the 3rd for the non-placing of items, it did something strange. I could still place down the items...
  17. Y

    Legacy GM instances not getting created

    hello, first of all bear with me because this is probably going to be long. so I'm trying to make my wave system work. first I've set some variables in the create event: Last_Pause = 0 //how many times the spawner spawned enemies in 1 wave( a wave is split into 5) global.Wave = 0 //current...
  18. matharoo

    Portfolio - Programming Experienced, Professional Freelancer ($18/hr)

    Hi, I am a programmer. ...or am I? Let's see. vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Please see my updated portfolio on my site (click here) for updated info...
  19. A

    REALLY basic thing i cant figure out

    Hey, im trying to learn GML so i started creating a really basic game. My objective now is to create a moving enemy, make it move 2 seconds to the left, idle 1 sec and 2 seconds to the right, then repeat. This is the thing, ive write this code and what happens is that the object starts...
  20. K

    For each or Do Until?

    Hi there. In my game, I want there to be a mechanic in which the player can absorb x amount of objects and then fire them off (something a la Kirby but not quite), but once the fired object collides with a wall, I want to create the same number of moving instances as there were objects absorbed...
Top