Jump to content
  • Advertisement
Sign in to follow this  
kingpinzs

How to animate tiles

This topic is 4898 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I put animated tiles in my isometric tile engine? I can draw a layer of tiles but I cant figure out how to add animated tiles in.
oid draw_tiles(void)
{
    for(Tileset.y=0; Tileset.y <Mapy;Tileset.y++)
    {for(Tileset.x=0; Tileset.x < Mapx; Tileset.x++)
    {  //what does this do?
    
    Tileset.scroll_x = Tileset.x + (Tileset.world_camerax/Tileset.Tile_Width  );//this allows scrolling on y axis
    Tileset.scroll_y  =Tileset.y+ (Tileset.world_cameray/Tileset.Tile_Hight );//this allows scrolling on x axis
      
  
      Tileset.offset_x= Tileset.world_camerax+ (screenx/2);
      Tileset.offset_y=Tileset.world_cameray+(screeny/2);
     
             
          Tileset.tiles = map[Tileset.y ][Tileset.x ];        

 
    tile_src.left = ((Tileset.tiles -1 )%20) *Tileset.Tile_Width;
    tile_src.top =  ((Tileset.tiles -1 )/20) * Tileset.Tile_Hight ;
    tile_src.right = tile_src.left + Tileset.Tile_Width ;
    tile_src.bottom = tile_src.top + Tileset.Tile_Hight  ; 

dstr.left= ((Tileset.x-Tileset.y)*Tileset.Tile_Width/2)+Tileset.offset_x;
dstr.right = dstr.left + Tileset.Tile_Width  ;

dstr.top=  ((Tileset.y+Tileset.x)*Tileset.Tile_Hight/2)-Tileset.offset_y;
dstr.bottom = dstr.top +(Tileset.Tile_Hight + Tileset.Tile_Width) ;



lpBackBuffer->Blt(&dstr,g_pddTile,&tile_src,DDBLT_WAIT|DDBLT_KEYSRC,NULL);  
} 
 }
 } 

would I have to make another drawing function so when the above function hits tile id 10 then it jumps to the other function and draw those tiles or is there a better way to do it? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Well one way I done it a few years ago (and thinking of doing it again for a small project) is to have your tiles as structures with all the info you need.
In this you could also have an array of say 4 different ID numbers and a time variable.

After the length your time variable in the game then you change the current ID to the next one in the array. Each ID points to a different tile in your set and this will animate it. After the last tile in the array your ID should be reset to the start of the array.

You could if memory etc isn't that much of a concern store a linked list of ID's so that each tile coud have as complex an animation as you want.

I hope I explained this clearly, it did actually turn out to be a good implementation for me.

Share this post


Link to post
Share on other sites
I think what I am meaning to ask is. When I draw my tiles it loops throgh the array that has been loaded from a text file. So when the drawing function hits the water tile id and a sertin amount of time has gone buy then what should I do?

should I
A. tell it to go to another tile in the bmp that is holding all the tiles or

B. Should I jump to another drawing function and draw it seprate from my main function or

C.have a list of just the animated tiles and when the tile ID matches the animated tiles then it runs through the set of tiles in that arey of the map.

I have heard alot about link list but I am not sure how to use them or even put them in my progam.

What method would give me the best visual affect with speed?

Can some one show me a example of how it is done?

whould the same method work for making layers and adding in movable objects?

Should I make a link list?(if so can some one show me sample code of using link list?

or should I use a bunch of arrays?

I think once I got these questions answerd then I can try to make a map editor and start making some levels.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!