Speeding up this handler

Shari gypsyware at earthlink.net
Fri Apr 11 22:52:01 EDT 2003


I'm trying to shave the first handler down to about 150 milliseconds. 
Handler 2 was just a test to see how quickly Metacard could set the 
filename of 99 images.  I've tried several variations, but so far the 
620 is the fastest, but it isn't fast enough.

Imagine a grid of images, and at any given time, you need to take the 
info from a non-contiguous block of these images, and use their 
filenames to set another block of images.  So you have a huge square. 
And with this handler, you carve out a square from inside the bigger 
square.

The big square has 22 rows, the small square has 9.
The big square has 43 columns, the small square has 11.
The small square has 99 images with filenames that need to be set, 
and the screen updated instantaneously afterward.

bMap[] contains 99 elements, which are the name of the images (Map 1, 
Map 2, Map 3, Map 4...)
cMap[] contains 22 elements (one for each row) and 43 items per 
element (one for each column)
cMap contains the entire grid of the big square, which is an array of 
filenames to use

on moveUnit # 620 milliseconds
   global gRow,gCol,gTemp,aMap,bMap,cMap
   put the milliseconds into tit
   lock screen
   put 1 into z
   repeat with x = gRow to (gRow + 8)
     repeat with y = gCol to (gCol + 10)
       set the filename of image bMap[z] to line y of cMap[x]
       add 1 to z
     end repeat
   end repeat
   unlock screen
   put the milliseconds - tit & comma after gTemp
end  moveUnit


on moveUnit # 130 milliseconds (BOGUS HANDLER, just testing 
Metacard's potential speed)
   global gTemp,aMap,bMap
   put the milliseconds into tit
   lock screen
   repeat with x = 1 to 99
     set the filename of image bMap[x] to aMap[56]
   end repeat
   unlock screen
   put the milliseconds - tit & comma after gTemp
end  moveUnit

--- a few things I've tried, there were more ---

on moveUnit # 650 milliseconds
   global gRow,gCol,gTemp,aMap,bMap,cMap
   put the milliseconds into tit
   repeat with x = gRow to (gRow + 8)
     put line gCol to (gCol + 10) of cMap[x] & return after blit
   end repeat
   lock screen
   repeat for each element x in bMap
     set the filename of image x to line (word 2 of x) of blit
   end repeat
   unlock screen
   put the milliseconds - tit & comma after gTemp
end  moveUnit


on moveUnit # 729 milliseconds
   global gRow,gCol,gTemp,aMap,bMap,cMap
   put the milliseconds into tit
   repeat with x = gRow to (gRow + 8)
     put line gCol to (gCol + 10) of cMap[x] & return after blit
   end repeat
   lock screen
   repeat with x = 1 to 99
     set the filename of image bMap[x] to line (word 2 of bMap[x]) of blit
   end repeat
   unlock screen
   put the milliseconds - tit & comma after gTemp
end  moveUnit

on moveUnit # 813 milliseconds
   global gSpot,gTemp,aMap
   put the milliseconds into tit
   lock screen
   put 1 into x
   put gSpot into y
   repeat 9
     repeat 11
       set the filename of image ("Map" && x) to aMap[y]
       add 1 to x
       add 1 to y
     end repeat
     add 33 to y
   end repeat
   unlock screen
   put the milliseconds - tit & comma after gTemp
end  moveUnit

on moveUnit # 822 milliseconds
   global gSpot,gTemp,aMap
   put the milliseconds into tit
   lock screen
   put gSpot into y
   put 1 into z
   repeat with x = 1 to 99
     set the filename of image ("Map" && x) to aMap[y]
     add 1 to z
     if z > 11 then
       put 1 into z
       add 33 to y
     else add 1 to y
   end repeat
   unlock screen
   put the milliseconds - tit & comma after gTemp
end  moveUnit

on moveUnit # 710 milliseconds
   global gSpot,gTemp,aMap,bMap
   put the milliseconds into tit
   lock screen
   put gSpot into y
   put 1 into z
   repeat with x = 1 to 100
     set the filename of image bMap[x] to aMap[y]
     add 1 to z
     if z > 11 then
       subtract 11 from z
       add 33 to y
     else add 1 to y
   end repeat
   unlock screen
   put the milliseconds - tit & comma after gTemp
end  moveUnit

on moveUnit # 690 milliseconds
   global gSpot,gTemp,aMap,bMap
   put the milliseconds into tit
   lock screen
   put gSpot into y
   repeat with x = 1 to 99
     set the filename of image bMap[x] to aMap[y]
     set the numberFormat to "#.00"
     if (x > 11) and (char -2 to -1 of (x / 11) = "09") then
       add 33 to y
     else add 1 to y
     set the numberFormat to "0"
   end repeat
   unlock screen
   put the milliseconds - tit & comma after gTemp
end  moveUnit






-- 
--Shareware Games for the Mac--
http://www.gypsyware.com



More information about the metacard mailing list