I have yet to implement terrain height into my game, but I think there are a couple ways to accomplish this.ġ.) I can store the part of the asset touching the ground for all assets stacking upwards (like a multistory building). the height of the rectangle) per tile of height. something flying one tile off the ground), you just need to move the sprite's screen.y position up the sprite's height (i.e. In order to simulate a camera looking into a 3D world, I need to draw everything from the top of the screen to the bottom, in that order, so assets with height are drawn over everything behind it (in world space)įor simulating world height (e.g. Thus the sprite's rectangles overlap like this: Of course, since it's pretending to be a 3D game, you have to draw/place the isometric tiles oddly so the inner rhombus (or hexagon, which is what an isometric cube is without shading) are drawn flush, since the graphics engine is working with rectangles. All assets are square (for top down) or rectangle (for isometric) sprites. My game is an "old fashioned" isometric game, meaning it is a 2D game through and through. It's very fast!Ĭaveat: I dont have any experience with 3D games, so we may not be speaking the same dialect. And for units/vehicles, I do a rectangle collision check (unit rectangle compare to screen space rectangle). Unfortunately I dont have a video of this yet.Īs for efficiency, I implemented static quads (for non moving items) and only draw items within the quads on screen. I had to implement "snap to grid" calculations in the background for moving units inside buildings, meaning for the depth sorting algorithm, I pretend they are on a different tile (when needed). Since my game will display the interior of buildings, this means the typical approach of sorting everything by the screen.y position (so long as every asset is a cube (or stack of cubes), or broken up into cubes) fails, because the bottom of the wall texture can be a whole tile-size away from the bottom of the asset. I have walls that sit on the edge of a tile, i.e. It took me awhile to figure out how to depth sort all assets properly and quickly. I'm currently working on an isometric city builder game.
0 Comments
Leave a Reply. |