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

Using 'do' statement for longer function

Q

Qstom

Guest
Hi! I'm really sorry but I am complete beginner and I know that I still have a lot to learn (and I was learning a lot) but also I really love to study something by asking questions. It gives me much bigger results.

{
do
{
hp -= dmg;
{
alarm[0] = 300;
draw_self();
draw_text(x+10,y,dmg);
}
}
until (hp <= 0)
}

I'm trying to learn anything by doing little steps and adding something new and trying different stuff.
Here let's say I just started with one object that had 100 hp drew on it and every time I clicked on it, it was damaged for 10.

So cool, everything worked fine but now I want to do that when I click button 'start' fight start automatically and object takes hits until his hp hits 0.
It's also ok everything seems to work but finally:
I want to see what is going on, let's say how in turn based battles.
Code you see above is me desperately trying to game show me information on every hit that object is getting 10 damage.
Right now I have no idea how I can do it. Program seems to ignore everything that is under
{
hp -= dmg;
{

and object, like earlier, just die instantly when I click start.


I really like this program and I like that it has so huge community so I hope that I will stay here on forum for longer ^^
 

Sabnock

Member
draw_text(x+10,y,string(dmg));

you need to convert numbers into strings for the draw function to display them.

also what does the alarm do?
 
Q

Qstom

Guest
Like I said I was desperately trying to do it somehow and I thought that maybe code after 'hp-=dmg' is ignored because it just have no time to do anything else.
So I was trying to implement any timer or something but I still didn't figure out how it works.

adding 'string' don't do to much from what I see, because my drawing on player to show its hp works normally without 'string' used
in this code it still ignore everything after 'hp-=dmg' :(

but thanks very much for fast answer ^^
 
S

SyntaxError

Guest
While, do and for loops continue to execute until the condition is met. Every cycle of the loop will happen in 1 step.

Also, that code above is much easier for other forum users to read if contained within a [code][/code] block.
Code:
// Code here.
 
Top