GLBasic forum

Main forum => GLBasic - en => Topic started by: badrush on 2009-Feb-08

Title: Initializing/creating variables after game has started
Post by: badrush on 2009-Feb-08
Hi i where just wondering as for example if you have an emitter object wich creates other objects then you would like to have variables to that object. And lets say this emitter does not create those variables in the beginning of the game but like everytime you press a button.

Here is how it would look in the program i used before called gamemaker.
creating the object//this can be at any time of the game
Quote
variable_local_set("bullet_x[bullets],x);//set x_pos
variable_local_set("bullet_y[bullets],y);//set y_pos
variable_local_set("bullet_dir[bullets],angle);//set dir
bullets+=1
drawing the object

Code (glbasic) Select

var loc_bullet;
loc_bullet=0

repeat(bullets)//draw and update the bodies off the bullets
{
draw_sprite(s_bullet,0,bullet_x[loc_bullet]),bullet_y[loc_bullet])
loc_bullet+=1
}


I hope you understand my blurry described text, thanks in advance.
Title: Re: Initializing/creating variables after game has started
Post by: Moru on 2009-Feb-08
In the help (F1) look at the command FOREACH, the example is showing how to do all this if I understand you right.
Title: Re: Initializing/creating variables after game has started
Post by: badrush on 2009-Feb-08
THANKS!!! =D