Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (NewbieZorro, Grant, TipmyPip, AndrewAMD), 13,040 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
question about "wait(...)" function #297248
11/06/09 13:13
11/06/09 13:13
Joined: Aug 2009
Posts: 26
Goiânia - Brazil
D
dmBlack Offline OP
Newbie
dmBlack  Offline OP
Newbie
D

Joined: Aug 2009
Posts: 26
Goiânia - Brazil
Hi there,

I am working on this 2d panel based game. What I want to do is to control the frequency of attacks of enemies. I was thinking of using wait(x) where x is the amount of seconds to wait until a new attack is possible. Like this:

...
if (enemy_active == 1) { }
if (enemy_active == 0)
{
enemy_active == 1;
attackPlayer(); //do needed stuff
wait(-5);
enemy_active == 0;
}
...

Is that ok? Will the wait(x) slow down my code? I am asking that because the player will have a faster attack rate, like 2 seconds between attacks, and each attack player does grants a chance of being attacked by nearby enemies. I´ve read somewhere that the wait() function allows the other functions to resume their execution while waiting, so I don´t know if that is a problem or not...

Thanks

Re: question about "wait(...)" function [Re: dmBlack] #297274
11/06/09 14:21
11/06/09 14:21
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!


Because you want your game to flow with the action
use something like

While (!panelxyz) {wait (1);}
or
while (panelxyz != condition) {wait (1);}

This type of code waits until the action as been done
and you don't have to count.


Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: question about "wait(...)" function [Re: Ottawa] #297289
11/06/09 15:12
11/06/09 15:12
Joined: Mar 2009
Posts: 276
Cebu City, Philippines
boyax Offline
Member
boyax  Offline
Member

Joined: Mar 2009
Posts: 276
Cebu City, Philippines
try to look at this function/macro: wait_for()

Re: question about "wait(...)" function [Re: boyax] #297290
11/06/09 15:19
11/06/09 15:19
Joined: Aug 2009
Posts: 26
Goiânia - Brazil
D
dmBlack Offline OP
Newbie
dmBlack  Offline OP
Newbie
D

Joined: Aug 2009
Posts: 26
Goiânia - Brazil
Thanks guys!!
I´ve just tested here during my lunch break and that way works fine. My way also works but needs improvement.
This wait_for() is interesting and I wasn´t aware of it...

Re: question about "wait(...)" function [Re: dmBlack] #297316
11/06/09 18:31
11/06/09 18:31
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

@dmBlack : Anytime wink

@boyax : I'll try that one soon.

Ottawa wink


Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1