Hey all,
I recently purchased codea and have been using it nonstop since. I can’t seem to put down my ipad now. This app simply rocks!!
Now to my question. Has anyone been able to get an autotile system working for a 2d rpg type game to read tile sheets and print a flawless map?
I have been basically trying to develop an rpg “engine”, something similar to rpg maker, but exclusively for codea. I can read the tile sheets and pull out the correct tiles for the most part, but the process causes a lot of lag. I don’t understand how it could be lagging so much with such simple sprites and such a small map (20 by 20 tiles). I am essentially taking a large tile sheet and pulling out each individual 16x16 tile that is needed, then splitting that into 4 to adjust for corners and such.
I am currently only drawing the tiles needed to fill the screen, which is 19 by 15. The player is always drawn in the center so it uses the player position on the grid map to determine which tiles need to be drawn.
I am using 2 grid maps at the moment: one for ground tiles, the other for objects on the ground (Later will need to add an events grid). Every map I make will need to have their own grids.
When I draw the map, I loop through the x and y coordinates using a nested for loop. For each coordinate, I draw the autotiled ground and then the object and finally the player (only when x and y match the players current coordinates). Drawing it out this way guarantees that the player can go behind things such as walls, trees, buildings, etc.
Like I said, I got the autotile to work correctly (with a few graphical errors), but the lag it creates is horrible and I can’t seem to figure out why it would be running so slow.
Example map:
Map = {
{1,1,1,1,1,1,3,1,1,2,2,1,1,1,2,2,3,3,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2},
…
}
Object map is the same format. The numbers indicate a tile id. Stored in the tile array are the tiles copied from the tile sheet (I programmatically create every tile from the tile sheets).
Tiles array example:
Tiles = {readimage(tile sheet):copy(x,y,32,48), readimage(tile sheet):copy(x2,y2,32,32), …}
These x and y variables are hardcoded numbers since the position of the tile in the tile sheet will never change. The tiles above are actually 6 tiles which I further chop up to be used when autotiling.
Is the lag due to me making so many image copy calls? If so, I have no clue to work around this except to simply save out every single tile as its own individual sprite, which would definitely be a pain but I did, however, make a quick app that does just this, except every image on the tile sheet must be the same size (like character sheets).
Hopefully I didn’t just confuse you all. When I do get this autotile to work properly and without lag, I will definitely share the code as it will help many of you who are trying to develop an rpg of some sort.
Thanks,
Slashin8r