Jump to content


Photo

Text wont stop looping


  • Please log in to reply
3 replies to this topic

#1 lordputoman

lordputoman

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 11 May 2012 - 09:57 AM

Good Day

We made a code that will show a random question but it wont stop looping ,
Can Anyone help me

obj_text 'this is the object that produce text'

Event - Create
Execute Piece of Code
[var global.active = true;]




Event - Draw
Execute Piece of Code
[var human;
var answers
var a,b;
var random;
var counter;
var life;

a = random(20);
b = random(20);

a = floor(a);
b = floor(b);
counter = choose(1,2,3,4)
life = 2;

if (global.active = true)
{
draw_text(512,0,'Question: '+string(a)+'*'+string(b)+'?')
}]

Edited by lordputoman, 11 May 2012 - 10:12 AM.

  • 0

#2 Ukyuu

Ukyuu

    GMC Member

  • GMC Member
  • 89 posts
  • Version:GM8

Posted 11 May 2012 - 10:08 AM

I can't help you much with the code itself, however, if you wish for your post to be more readable, put the code part betwen [ code ] Your code goes there [ /code ] it will be easier to understand it :)
  • 0

#3 troido

troido

    GMC Member

  • GMC Member
  • 150 posts
  • Version:GM8

Posted 11 May 2012 - 10:24 AM

Every step, the code in the draw event is executed.
You need something to pause the game after you asked the question
One option would be to use mouse_wait() (for if the player should click a button) or keyboard_wait() (for if the player should press a key);
To wait until the player presses a specific key, you can use the code:
do keyboard_wait();
until keyboard_check_pressed(key)
you should replace key with the code/name of the key you want to end the pause with.

there is also an easier way to do this, and that is to use the get_integer function.
with this function, a pup-up message will appear, and the player can enter an integer.
you can use a code like this:
answer=get_integer('Question: '+string(a)+'*'+string(b)+'?',0);
if you also want decimal numbers, you can use this code:
answer=real(get_string('Question: '+string(a)+'*'+string(b)+'?',0));
answer will be the value that the player enters.
you don't have to put this code in the draw event, you can put it anywhere you want.

furthermore, instead of generating a random number for a, and then floor it, you can also generate a random integer with
irandom(20);
b=irandom(20);

  • 1

#4 lordputoman

lordputoman

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 11 May 2012 - 11:05 AM

Every step, the code in the draw event is executed.
You need something to pause the game after you asked the question
One option would be to use mouse_wait() (for if the player should click a button) or keyboard_wait() (for if the player should press a key);
To wait until the player presses a specific key, you can use the code:

do keyboard_wait();
until keyboard_check_pressed(key)
you should replace key with the code/name of the key you want to end the pause with.

there is also an easier way to do this, and that is to use the get_integer function.
with this function, a pup-up message will appear, and the player can enter an integer.
you can use a code like this:
answer=get_integer('Question: '+string(a)+'*'+string(b)+'?',0);
if you also want decimal numbers, you can use this code:
answer=real(get_string('Question: '+string(a)+'*'+string(b)+'?',0));
answer will be the value that the player enters.
you don't have to put this code in the draw event, you can put it anywhere you want.

furthermore, instead of generating a random number for a, and then floor it, you can also generate a random integer with
irandom(20);
b=irandom(20);

thank you sir . i'm going to try it out now
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users