Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Kingware, AemStones, RealSerious3D), 1,388 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Wait() problem #355341
01/26/11 16:55
01/26/11 16:55
Joined: Dec 2010
Posts: 87
R
romin2011 Offline OP
Junior Member
romin2011  Offline OP
Junior Member
R

Joined: Dec 2010
Posts: 87
Hello, my enemy comes out of cover after random seconds wait(-integer(random(10))). But wait stops the whole function animation etc for that amount of time. How to make him perform athor things like animation etc while wait for the some amount of time before coming out of cover? Thankyou

Re: Wait() problem [Re: romin2011] #355343
01/26/11 17:11
01/26/11 17:11
Joined: Jan 2011
Posts: 797
Da wo du nicht bist! Muhahaha!
xxxxxxx Offline
User
xxxxxxx  Offline
User

Joined: Jan 2011
Posts: 797
Da wo du nicht bist! Muhahaha!
wait(-integer(random(9)) + 1);
maby should fix that
sorry for my english

mfg
xxxxxxx

Last edited by xxxxxxx; 01/26/11 17:12.

Es ist immer wieder erstaunlich, dass Leute die riesen Scripte schreiben die einfachsten sachen nicht können zb. mich mit SIEBEN x zu schreiben! tongue
Re: Wait() problem [Re: romin2011] #355348
01/26/11 17:28
01/26/11 17:28
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Originally Posted By: romin2011
Hello, my enemy comes out of cover after random seconds wait(-integer(random(10))). But wait stops the whole function animation etc for that amount of time.

Congratulations, you just discovered what wait does.
How should it know that the only thing you want is to preserve the current state but nothing else?
The solution: Wait only one frame but check every time if the 10 seconds have already passed, then trigger the state change of the ENTITY


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Wait() problem [Re: WretchedSid] #355349
01/26/11 17:35
01/26/11 17:35
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
The solution: Wait only one frame but check every time if the 10 seconds have already passed, then trigger the state change of the ENTITY

To accomplish that increase an arbitrary skill, f.i. skill10 by time_step.
my.skill10 += time_step;
Every second my.skill10 will increase by 16 (because the engine time scale is "ticks"). That means if your skill is above 160, 10 seconds have passed:
if(my.skill10 > 160) { get out of cover }

Alternatively, you could increase by 1/16*time_step per frame and my.skill10 will equal to the seconds that have passed (it could be better to use time_frame instead).


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Wait() problem [Re: WretchedSid] #355354
01/26/11 17:38
01/26/11 17:38
Joined: Jan 2011
Posts: 120
United States
Logan Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
Or, move the other behaviors you want to keep going to other functions. I.e.:

You probably have:
Code:
function enemy() {

... your animation code here ...
... some other stuff here ...
wait(-integer(random(10))); // so this stops everything that this function is doing
}



Try moving your animation code and your other code to other functions, and the engine's multitasking should kick in.

Code:
function enemy_animate()
{
...your animation code here...
}

function enemy_otherstuff()
{
...other code here...
}

function enemy() {
enemy_animate();
enemy_otherstuff();
wait(-integer(random(10))); // now I'm pretty sure the other functions will continue to run
}



Give it a try?

Key ignore [Re: Logan] #355363
01/26/11 17:56
01/26/11 17:56
Joined: Dec 2010
Posts: 87
R
romin2011 Offline OP
Junior Member
romin2011  Offline OP
Junior Member
R

Joined: Dec 2010
Posts: 87
Thank you superku very much you have always better solutions and very helpful.
But i got another problem. how to ignore a key once it is pressed. I mean once you pressed the key_space it should continue the function ignoring if u kept space key pressed? While(key_space)wait(1); will simply not run the func till u release it. Thanl you

Last edited by romin2011; 01/26/11 18:07.
Re: Key ignore [Re: romin2011] #355369
01/26/11 18:11
01/26/11 18:11
Joined: Dec 2010
Posts: 87
R
romin2011 Offline OP
Junior Member
romin2011  Offline OP
Junior Member
R

Joined: Dec 2010
Posts: 87
Any one?

Re: Key ignore [Re: romin2011] #355377
01/26/11 18:23
01/26/11 18:23
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
var key_space_released = 0;

...
if(key_space) {
if(key_space_released) {
key_space_released = 0;
do something
}
}
else { key_space_released = 1; }


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Key ignore [Re: Superku] #355453
01/27/11 07:27
01/27/11 07:27
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
It's not as hard as you think, but takes too long to explain, create a variable/skill to handle it, use like wait(-time) in a function that changes the variable/skill.


Professional A8.30
Spoils of War - East Coast Games
Re: Key ignore [Re: Locoweed] #355454
01/27/11 07:29
01/27/11 07:29
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
Bad example, I know. Hard to explain.


Professional A8.30
Spoils of War - East Coast Games
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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