while loop

  1. C

    GMS 2.3+ Need some help debuguing this infinite while loop

    Hi there guys, i hope someone can help me debug this, so i have this function: function ChooseRandomDirFromPositionArray(_array, _callingActor){ var array = _array, callingActor = _callingActor, currX = floor(callingActor.x/TILESIZE), currY =...
  2. Jmarlin3

    Issue with while loops

    The purpose of the next few lines is add a number to y to make my object move if(keyboard_check_pressed(vk_down)){ y += movespeed; } The code above works just fine, but when I change it to a while loop: while(keyboard_check_pressed(vk_down)){ y += movespeed; } The goal of the while...
  3. T

    GMS 2 [SOLVED] Problem with path_position, while, and x/y coordinates

    Hey guys! I stumbled upon a rather strange behavior of GMS2 regarding paths, path_position and x/y coordinates. Following scenario: I have an "obj_player" that can move 2D platformer style. A second object, called "obj_pathpos" (for path position) is assigned to path "pat_test". pat_test goes...
  4. B

    GML [SOLVED]ransomized placement of cards for a match 2 game

    So im trying to randomize placement of cards. 5 cards along the x axis and 4 cards along the y axis. wired stuff keeps happening. heres my code loop = 1; xri = 0; yri = 0; donuthin = 1; xi = 32; yi = 32; randomize(); global.cur_card_no = random_range(1,6); for (i = 0; i <= 20; i += 1) {...
  5. Papa Doge

    GML [Solved] Sticky bullets on nearest surface

    Hello, I'm playing around with some code to test different ways of finding the nearest collision using the collision_line function and I've created something that does what I want it to do but seems to crash the game pretty regularly. I'm down to trash this whole concept and try something...
  6. Papa Doge

    GMS 2 [Solved] While loop crashing when storing condition as a variable

    I'm working on a proof of concept, wall climbing platformer that has some pretty basic collision checks, one of which is to check if a player is about to jump over a wall — and if he/she is — move the player sprite so that it stops at the peak instead of jumping over the peak. The issue I'm...
  7. I

    GMS 2 Infinity While loop error?

    Hi guys, i had checked again & again but i cannot understand why this code of mine make my game frozen when var oPlayer.elDownDistance = oPlayer.elLineAmount Ummm >. < whyyyy? please! var evKeyDown = keyboard_check(vk_down); var evKeyUp = keyboard_check(vk_up); var evSpd = (evKeyDown -...
  8. B

    GMS 2 [SOLVED]Wierd Infinite While Loop

    Hello, I was trying to make a platform object works like platforms in Terraria. I made a very flawed collision for it for testing. My original collision script: hrepeat = hsp / 30; vrepeat = vsp / 46; hrepeat = abs(hrepeat); vrepeat = abs(vrepeat); hmod = hsp % 30; vmod = vsp % 46; hmod =...
  9. Patrick Johnson

    GMS2 While and If statements Error Malformed

    I'm having an issue with the "while" and "if" statement in my code. I run the compiler but it says that the function is malformed, regardless of whether or not I use "while" or "if". It works fine in GMS 1.4 but not GMS2. /// Code in the game > o_enemy > create event ///...
  10. T

    GML "with()" exits while loop

    Good evening. I have a while loop, supposed to generate a specified amount of objects. It runs fine unless i try to pass in a property with the with() method. If i do so, there is just one object created, and the while loop seems to be stopped. here is my code: particleAmount = 50; this runs...
  11. B

    Trying to spawn and object, and then making it move to a certain point, and then move to an object.

    This is the code i've written now. { while (obj_LETTERS.x <= 800); { move_towards_point(800, obj_LETTERS.y, 5); } while (obj_LETTERS.x >=800); { move_towards_point(obj_doggo.x, obj_doggo.y, 5); } } where obj_LETTERS is the object that is moving from the left side of the screen, and obj_doggo...
  12. R

    GML Need help with place_meeting

    while (place_meeting(x+(move*vitesse),y,oWall)) {x+=sign(move)} is supposed to move the player as close as possible to the wall if there is a collision between him and oWall, but it stops the player a few pixel away from oWall. Jon's reply fixed my issue but I want to understand what went wrong...
  13. Dagoba

    Legacy GM Wait until mouse_click

    Hello, long time no see! I am currently programming a Texas Hold'Em online game, and I am encountering a problem. There are turns for each player on the table, and it's running by for loop for each player. I need to make a method that waits until the player has clicked either call, check, fold...
  14. T

    GML Tetris: Break Blocks up into Pieces (To destroy rows)

    Hi everyone, I am creating a Tetris game and am trying to make it so that the rows get destroyed when a row is filled with blocks. I have 7 different sprites for the block pieces and they all contain 4 cells worth of blocks (each 16 pixels wide and long) In order to destroy a row, I would need...
  15. P

    Legacy GM Very basic help with loops

    So I'm brand new to programming and even newer to GML language. I'm making a game in which the player dodges traffic as the player speeds down a 4 lane highway in a small car. I have a step event that is supposed to check if a vehicle has passed the bottom of the room (being a y value of 800)...
  16. 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{...
  17. Dagoba

    Using while

    Hello! I am making a Poker engine that simply waits, until player has either clicked some of these buttons: Call, Raise or Fold. My script looks like this: do { scr_playersTurn(); } until (turn_used) Something like that, very simple. Inside of...
  18. S

    Exit while loop

    I have a while loop that gets executed as long active = true. In one part of my code I want to exit the the while loop instantly without executing everything else that comes after this section in the while loop. Can I just set active = false, or will still still execute the last part of the loop?
  19. F

    GML [SOLVED] Spawner Code While Loop Crashes - Platformer

    Hello everyone, I have a coding error that I cannot seem to solve by myself so I hope you can help. I have a spawn controller object that runs on an alarm event. There is a step event in the object besides the alarm. While in open areas, the spawn controller works well. However, when entering...
  20. D

    loop confusion

    Hey guys, I have a object that speeds upon at certain intervals, and I am wanting cap it at a certain value. I figured a while or a do until loop wrapped around this code would work, but now when I run my game, the object hits the goal which should speed it up a bit and increase the score by...
Top