Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (dr_panther, TedMar, AndrewAMD), 986 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 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 | chip programmers | 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