Alambik Club Here you can view your subscribed threads, work with private messages and edit your profile and preferences Registration is free! Search Home Logout  
Alambik Club : Powered by vBulletin version 2.2.5 Alambik Club > Alambik > Alambik Script help > Somes hints to reduce time used by your machine to play an Alambik script
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
Alambik Script Team
Alambik Staff

Registered: Feb 2002
Location:
Posts: 15

Somes hints to reduce time used by your machine to play an Alambik script

Often, your script is a loop :

do()
process_player()
process_shots()
process_enemies()
if (%live==0)
break()
endif()
loop()


The solution consist to introduce a time.wait(0.3), in example to give a regulate delay to your loop :

do()
process_player()
process_shots()
process_enemies()
if (%live==0)
break()
endif()
time.wait(0.3)
loop()


But, time wait will be always 0.3 seconds to restart your loop. So, Total time is between 0.3 and 0.3+execution time. To have a constant time, you have to measure your procedure's time and withdraw it to 0.3 :

do()
!begin=time.get()
process_player()
process_shots()
process_enemies()
if (%live==0)
break()
endif()
!end=time.get()
time.wait(0.3-(!end-begin))
loop()


There is a automatic instruction who can make this operation, it's time.wait() without parameters.
It allows to liberate necessary time to not exceed the value in sequence.refresh.set() :


// we choose to put 30 images per second
sequence.refresh.set(30)
do()
process_player()
process_shots()
process_enemies()
if (%live==0)
break()
endif()
// wait about 1/30 second maximun
time.wait()
loop()


There exists too lot of methods to reduce time machine used by Alambik :

"sequence.refresh.set" can define frame rate from object. By default, system define 70 images per second but in major cases this value is too big. It's advised to put a value between 20 and 50 according to need of application.


sequencerefresh.tv

screen.resolution.set (320,240)

@spr=sprite.load ("avo\dinosaur.spr")
sprite.play (@spr)

@track=track.create (TRACK_LOOP|TRACK_PINGPONG)
track.key.set (0)
track.key.position.set (0,CENTER)
track.key.set (4)
track.key.position.set (320-27,CENTER)
track.end ()

@sequence=sequence.play (@track,@spr,TRACK_KEEPALL)

sequence.refresh.set (50)

%data=sequence.refresh.get ()
text.display ("The refresh rate of the sequence is : " + STR (%data),CENTER,10)
text.display ("Press a key to change.",CENTER,350)

keyboard.wait ()

sequence.refresh.set (20)

%data=sequence.refresh.get ()
text.display ("The refresh rate of the sequence is : " + STR (%data),CENTER,10)
text.display (" Press a key to exit. ",CENTER,350)

keyboard.wait ()

script.stop ()

A last method consist to work in mask mode. There is an screen.mask() instruction who can accumulate screen modification and execute it only with screen.mask(off) instruction or screen.display() :

sequence.refresh.set(30)
do()
screen.mask(on)
process_player()
process_shots()
process_enemies()
if (%live==0)
break()
endif()
screen.mask(off)
time.wait()
loop()

OR

sequence.refresh.set(30)
screen.mask(on)
do()
process_player()
process_shots()
process_enemies()
if (%live==0)
break()
endif()
screen.display()
time.wait()
loop()
screen.mask(off)

Report this post to a moderator | IP: Logged

Old Post September 8th, 2004 04:50 PM
Alambik Script Team is offline Click Here to See the Profile for Alambik Script Team Click here to Send Alambik Script Team a Private Message Visit Alambik Script Team's homepage! Find more posts by Alambik Script Team Add Alambik Script Team to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 01:45 PM. Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 

< Contact Us - Alambik Club >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.