|
wait()?
#175180
12/28/07 22:57
12/28/07 22:57
|
Joined: Jun 2007
Posts: 63 Italy
Sonic220
OP
Junior Member
|
OP
Junior Member
Joined: Jun 2007
Posts: 63
Italy
|
I've a sort of problem with wait and a while loop Code:
while(my) { my.x -= 3* time; if (my.x < -3600) { my.y += 10*time_step; if (my.tilt <= 15){ my.tilt += 5*time_step; } ent_create(bullet1,vector(my.x-20,my.y,my.z),move_bullet1); wait(10); } wait (1); }
This is a ship, it moves and when is .x is smaller than -3600 start fire and move towards y. Cause of the wait the ship doesn't move quikly. I've tryed to divide the while loop and create 2 different, but that's the same thing. how to do?
Last edited by Sonic220; 12/28/07 22:58.
~Vision Divine~
|
|
|
Re: wait()?
[Re: Sonic220]
#175181
12/29/07 00:15
12/29/07 00:15
|
Joined: Jan 2003
Posts: 4,305
Damocles
Expert
|
Expert
Joined: Jan 2003
Posts: 4,305
|
Kind of strange function, but the main thing you should change is to never use wait(10); this waits 10 frames, and not a specific time, use the negative number like wait(-0.1); or so for time in seconds. (is like sleep() function)
var fps_max=120; //limiting the framerate an fast computers
...
while(my) { my.x -= 3* time; if (my.x < -3600) { my.y += 10*time_step; if (my.tilt <= 15){ my.tilt += 5*time_step; } ent_create(bullet1,vector(my.x-20,my.y,my.z),move_bullet1); wait(-1); //or another value, that is not framerate dependent } wait (1); }
|
|
|
Re: wait()?
[Re: Damocles]
#175182
12/29/07 08:56
12/29/07 08:56
|
Joined: Jun 2007
Posts: 63 Italy
Sonic220
OP
Junior Member
|
OP
Junior Member
Joined: Jun 2007
Posts: 63
Italy
|
ah, I see, but the problem isn't this. Cause the wait is in the while and must be after the ent_create(a bullet for 2 seconds for example), the ship moves like: +10 stop +10 stop. Sorry my bad english, I can't explane myself better.
~Vision Divine~
|
|
|
Re: wait()?
[Re: Sonic220]
#175183
12/29/07 10:09
12/29/07 10:09
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
var tempa; while(my) { my.x -= 3* time; if (my.x < -3600) { my.y += 10*time_step; if (my.tilt <= 15){ my.tilt += 5*time_step; } int(tempa); if(tempa == 8) { ent_create(bullet1,vector(my.x-20,my.y,my.z),move_bullet1); } tempa += 1; tempa %=9;//must be one higher then the one in the if(tempa,enz. } wait (1); }
change tempa the red parts for longer ore shorter
Last edited by flits; 12/29/07 10:13.
|
|
|
Re: wait()?
[Re: flits]
#175184
12/29/07 11:37
12/29/07 11:37
|
Joined: Jun 2007
Posts: 63 Italy
Sonic220
OP
Junior Member
|
OP
Junior Member
Joined: Jun 2007
Posts: 63
Italy
|
Thx a lot! It work, but I don't understand how. There are a var int, and... °A°
~Vision Divine~
|
|
|
Re: wait()?
[Re: Sonic220]
#175185
12/29/07 12:47
12/29/07 12:47
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
the int cuts evthing after "," so 33,23 woulde be 33 dont know if its necery tempa += 1; ads 1 every frame tempa %= 9; if(tempa == 9) tempa = 0
"empty"
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|