answersLogoWhite

0

How does a REPEAT loop work?

Updated: 9/13/2023
User Avatar

Wiki User

14y ago

Best Answer

The repeat loop is very simple. It allows you to repeat a statement or block of code without needing to copy-and-paste it. Here are some examples:

{repeat(5)

{x += 15;}}

{repeat(3)

{x += 15; y -= 5;}}

The number in the parentheses dictates how many times you want to repeat the statement/code block.

You may also use a variable:

repeat(self.x)

{instance_create(irandom(400),irandom(400),object_obj);}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How does a REPEAT loop work?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Basic Math

Write program that read an integer and display all its smallest factors?

All the smallest factors of a number must be its smallest factor, which for any number is 1, so: loop loop loop print "Enter an integer number: ": input n until num(n) do print "Please enter a number" repeat until n = int(n) do print "Please enter an integer" repeat print "Smallest factor of ":n:" is 1" repeat


How does a FOR loop work in GML?

FOR loops work as follows:{for( [initialize a variable]; [expression]; [increment the variable] ) {//Do this code}}Here as an example of a FOR loop:{for(i = 1; i < 10; i += 1) {show_message(string(i));}}What this will do is show a message 10 times displaying the value of "i" so you would get a message that says "1," another one after that saying "2," etc... The way this works is that you have the variable "i" initialized in the FOR loop. The FOR loop will keep looping until i >= 10, because the middle statement dictates that i must be smaller than 10 for the FOR loop activate. The third statement in the for loop is the statement that you increment the i variable with. If you change i += 1 to i -= 1 then the FOR loop would go on forever, freezing the game. This is a critical mistake to make when constructing a FOR loop (as is with any loop.)


What does looping mean?

The definition varies based upon the type of loop being talked about. Generally a loop is anything that starts and ends at the same point in a circular or elliptical shape. For example a ring on your finger is a loop. The hoop on a Basketball court has a loop. A loop also generally implies anything that repeats itself. For example when a traffic light goes from green to yellow to red, then back to green, that is a looping cycle. Loops are also a common fixture in computer programming language. They are used to repeat a given series of commands until a certain condition(s) are met.


When a VBScript loop control variable is not altered during loop execution what kind of loop may result?

An infinite loop.


How does a WHILE loop work in GML?

The while loop works as follows:{while( [expression is true] ) {//Do this code}}The while loop re-runs until the expression contained within the parentheses is false. Take a look at this example:{while(!place_meeting(x,y,obj_ground)) {y += 1;}}This while loop tells the object to move down one pixel until it collides with obj_ground. Unfortunately, nothing guarantees that this loop will not run forever. Always make sure that when you construct a while loop that you make sure that it does not run forever. Take a look at this whileloop:{while(obj_ball.y < y) {draw_sprite(sprite_index,0,x,y);}} This while loop will run for ever. Why? It does not have any statements that insure that the while loop aborts. Again, Always make sure that when you construct a loop that you put statements in the loop that will eventually abort the loop. y -= 1; is the statement in this new while loop that eventually aborts the loop:{while(obj_ball.y < y) {draw_sprite(sprite_index,0,x,y); y -= 1;}}

Related questions

Repeat (10)Do sit up?

Loop


Why you use for loop inside switch statement?

Because you have to repeat something. (Or you can use while-loop, too.)


How do you get your windows media player to loop?

Start the media player. to the LEFT of the play button is a circular arrow. This is the repeat button. Simply click that to make it repeat. It will loop indefinitely until you click the repeat button again to turn the feature off.


What is a loop type?

A Loop is a programming language construct that instructs the processor to repeat a sequence of operations a number of times until a specific condition is reached. There are different types of loops. They are: * for loop * while loop * do while loop


What is meant by while looping?

A "While" loop is a part of computer programming. The logic is "while this condition is true, do the following commands and repeat". By default this will repeat forever creating a "loop" in logic. To stop looping you have to include a command that will change the original condition inside the loop.


What is repeat loop?

Most programming languages have some loop construct, that make it possible to repeat commands several times. The available commands vary, depending on the language; as an example, Java has the "for", "while", and "do...while" keywords.


What does animation loop mean?

Animation loop is the repetition of part of the animation. For example, an animator can animate a clock pendulum swinging from one side to the other just once, then repeat the animated portion using animation softwares instead of repeating his work manually.


What did the code inventor think when he had to repeat his message three times?

i just exited a for loop!


Write a note on indeterminate loop in visual basic?

Indeterminate loops in Visual Basic are loops that repeat for an unknown number of times. The programmer sets up the loop to repeat until a certain condition is reached, or while a certain condition is true.


What is the meaning of the repeat command?

The exact meaning will depend on the language. In general, however, the repeat command will repeat a block of statements while a condition remains true (much like a do...while or for loop).


What is he do loop?

A "do" loop is a construct in a programming language that lets you repeat instructions over and over, as long as a certain condition is true. The details vary, depending on the programming language.


What control structure allow you to repeat sequences?

A for loop, and a while loop can do that. Some languages support a for each loop, which repeats a sequence of commands for each element in a collection (e.g., an array). You can also achieve repetition using recursion.