Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark Physics & Dark A.I. & Dark Dynamix / creating cool down for adding entity, help

Author
Message
xninzx
14
Years of Service
User Offline
Joined: 11th May 2010
Location:
Posted: 12th May 2010 05:18
I'm trying to create an amount of entities, e.g. 20 entities.
I have no problem with this.

But all entities just show in the same time at once, while I want it to show up in sequence. let's say 3 secs before next entity shows up, while keep all previous entity do their business.


this is my main loop

[Do

gametime = timer()/1000-time

rem *** General Infomation ***
set cursor 0,110
print "Width"," ",screen width()
set cursor 0,130
print "Height"," ",screen height()
print gametime
print timer()
print get time$()
print get date$()
print


rem ***number of maximum entity 'i'***
for i=1 to ent-1

rem ***Check the entites existing and***
if ai entity exist(i)=0
rem ***Timer***
if cooldown = 0

addentity(i)
addentbehav(i)
addentobj(i)

cooldown = 5
endif

endif

if ai entity exist(i)=1
drawentity(i)
endif

next i


rem ***adding cool down***
if gametime = 10

dec cooldown, 5

endif

print "Number of current entities: ", i
print "Press "Space" to reset"

rem *** Spacebar input to reset programme***
if spacekey()=1
for i=1 to ent
AI kill entity i
next i
exit
endif

AI update


Loop]

*****************************************

I try by adding cool down parameter after create one entity and assume that the cool down function work fine(since I can't find a way to do it yet). but after the condition is met in cool down function, all entities are add up at the same time again.


I'm quiet new for programming, but I got a clue that I have to use timer() in some reason.


Any example code would be very helpful.

Cheers
Dia
19
Years of Service
User Offline
Joined: 16th Jan 2005
Location:
Posted: 12th May 2010 13:44 Edited at: 12th May 2010 13:44
just for a start, use the [ code] and [ /code] tags for your code snippets on this forum. (no real biggy )

if you declare a cooldown variable before you do loop starts (i.e. cooldown = 5000 or something, remember timer() increments in 1000ths of a second, so 5000 = 5 seconds)

then in your conditional statement that calls your entity building functions, use something like:



in this case, every time you build an entity, the time of build is recorded in the 'lastbuild' variable. every loop, current time is evaluated, and once it is greater than the "last build time" plus the cooldown time it will build another entity

This is not the Sig you are looking for....
xninzx
14
Years of Service
User Offline
Joined: 11th May 2010
Location:
Posted: 13th May 2010 22:14
Thx a lot

I'll try it out! =w=
xninzx
14
Years of Service
User Offline
Joined: 11th May 2010
Location:
Posted: 13th May 2010 23:09
That's work just exactly what I want!

Thank you so much!

Login to post a reply

Server time is: 2024-11-24 12:52:53
Your offset time is: 2024-11-24 12:52:53