   sprites
  I've got my terrain rendering down and I'm thinking about sprites now.   I implemented a little 3D array, layer 1 for terrain, layer 2 for static world objects and layer 3+ for anything else.  Now my question is should all things be tied to specific tiles or should they be independent.  Also if they are tied to tiles how am I to move the characters or mobs around the map without them jumping from tile to tile.  Is it a smooth scrolling thing like the terrain or do I need to do something else.I have read all of the tutorials and didn’t really see anything useful about object management.also...for rendering everything im using Direc3d....and have a nested loop to do the drawing.  Is that the most efficient way to do the drawing?it's a 3D array soFor all in x   For all in Y For all things to draw    draw()   
  Your ideal solution may be different depending on how your game works.That being said, I have used/am using a combination of both. I am doing an overhead 2d action/RPG (non-isometric like Zelda3) tile based game so it may be different than what you are doing.My entities all reside in a large list that gets insert sorted by y value when they move. I pop the entity from the list and search from it's last position in the list where to sort it. I also check to see what tile it's new position is on and do the same type of pop/insert on the tile if it is necessary (most times it isn't depending on how populated the area is). The lists are all lists of pointers btw.My rendering is done from the large list as they are already sorted in drawing order already (and doing it on a per tile basis causes some wierd drawing order issues with neighboring tiles). The AI is figured out on a radius basis to which the smaller lists on the tiles help out. For example certain agressive NPC's attack within a 1-2 tile radius (or box as it happens) while others like guards will notice from up to  8 tiles away if you are so flagged. This is made easy by just traversing the lists of the surrounding tiles instead of the whole list.I hope that helps a little.   ;  I would also like some help on drawing large sprites like say...beds.Things that take up more than one tile confuse me.  If an objects spans more than one tile do i have to figure out which tiles it crosses and make those non walkable?  In the case of things standing up...walls and the like..the character just walks behind it...but that doesn't work for things that lay flat on the ground like a bed.thanks;  The only thing i have found so far is that i need to define in the meta data that this certain sprite will take up 4 tiles....and i need to make those 4 tiles non walkable.  It might get quite annoying to do all of that by hand.  I am about to go implement this as its the only solution i have.  It just seems a bit primitive.   ;Quote:Original post by nex7The only thing i have found so far is that i need to define in the meta data that this certain sprite will take up 4 tiles....and i need to make those 4 tiles non walkable.  It might get quite annoying to do all of that by hand.  I am about to go implement this as its the only solution i have.  It just seems a bit primitive.Large objects that would span multiple tiles are usually cut up into smaller pieces by the artists.Sprites can cover many tiles. A sprite with the same size as the tiles will cover either 1, 2 or 4 tiles. 1 when it's standing right on top of a tile, 2 when it is moving horizontally or vertically and 4 otherwise. If you want to get the tile coodinate from a sprite, divide the sprite coordinate with the tile size. If you want to check coverage, just check where the 4 corners of the sprite stand. The tiles covered by the sprite will be the box between the 4 corners. (you can mark this area nonwalkable with a double for cycle)Always use temporary marker bits, that are different from the background, because you have to erase these bits every time the sprite moves and redraw them after the movement. First, this stops the sprite from getting caught on its own 'shadow' and it results in the automagical update of the walkable map. Since you only move 1 sprite at a time, cycling through all moving objects, they will respect both the nonwalkable terrain and each other's shadows.Viktor   ;  So something like a bed that takes up 4 tiles would be cut into 4 pieces and then drawn?what if its say...a very large monster like a dragon or something.  This dragon is drawn and he takes up 8 tiles.  His feet are on the corners of the tiles so any tile that he is covering needs to be non walkable.  the Parent tile is of course non walkable but how do i know that he takes up 7 other tiles?;  Actually the dragon would take up an 8 tile standing area with the rest of him extending up...wings and neck and the like.  so the sprite actually covers 8 for his standing area and another 4 for his neck and wings....now the tiles behind his wings and neck are still walkable while the 8 that he is standing over are non walkable.I am just at a loss as to how to get that into code other than to hardcode the parameters in some sort of meta data for each sprite...sprite   Height   Width   TileCoverage   Image   ;  i present to you...the bed problem red is auto marked non walkable...green is walkableand i really really want to mark the yellow tiles non walkable.;  There are two solutions I can think off:1. I assume you have map editor [smile]. You may add to every tile bool variable that shows is a tile walkable or not. In map editor simply check or uncheck values.2. You can make it with pointer to object, so tiles will have pointer that there is some object and make again tile non-walkable. Your object is located on red tile, yellow tiles have reference to object tile.I'll prefere first solution. It is fast, simple, no precompute.   ;  ok so the bed was a bad example....lets pretend that a wizard animated the bed..and it now has huge teeth and can walk around in our world causing all manner of trouble.Those walkable tiles have to be updated as our evil bed moves around the world.The best solution I have come up with is a sort of Walkable Mask...i would make an 4bit bitmap the size of my world...so say a 2000x4000 bitmap and each monster bed would also come along with a walkable mask... a tiny bitmap that would represent the tiles it takes up.  then every time something moves it would blit its walkability mask to the main bitmap and you would have a nice bitreference to check.if color == red   non walkableif color == blue  water..use boatif color == green walkable terrainif color == white air must use flying carpet   