Re: Subscript an atom Attempt Error

new topic     » goto parent     » topic index » view thread      » older message » newer message
ssallen said...

Ok, so I am guessing that you have a single bitmap with multiple images drawn into a grid. However, load_bitmap is not going to split those for you, its only going to load the entire image. You will need to programatically determine or specify where each frame begins and ends. A valid approach to your problem:

 
atom image 
integer cframe 
sequence framedata 
 
framedata = { 
              {0, 0, 100, 100},  -- frame 1 upper left and lower right (x1, y1, x2, y2) 
              {100, 0, 200, 100}  -- frame 2 upper left and lower right (x1, y1, x2, y2)            
            } 
cframe = 1 
 
image = load_bitmap("mybitmap.bmp", 0) 
 
if key(KEY_UP) then  
       if cframe = 1 then 
          cframe = 2 
       else 
          cframe = 1 
       end if 
end if  
 
blit(image,screen,0,0,framedata[cframe][1], framedata[cframe][2],framedata[cframe][3], framedata[cframe][4])  
 
 

Framedata is going to contain the coordinates of each frame on the bitmap. The example I used above will be a filmstrip pattern with two images side by side on the same y-plane:

----------- 
*IM1* *IM2* 
***** ***** 
***** ***** 
----------- 
This code really isn't usable without some pacing mechanisms but hopefully you can at least see where you are going wrong.

Edit: Here is a small EuAllegro demo I was playing with a couple years back. It illustrates a very simple game fairly well. It is written in Eu 3.2 but the code should still be fairly handy. http://www.mediafire.com/download.php?6mjk96nr5v2yyda

Thanks. I kinda figured I was doing something wrong. Now I have a better idea of what I am doing.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu