microspace Posted December 9, 2018 Share Posted December 9, 2018 Is there a way to determine sprite position in terms of tiles, faster than in the example: update: function () { var cposx = Math.floor(player.x / TileSize); var cposy = Math.floor(player.y / TileSize); } I dont want to load too much calculations inside update function. Maybe there is asynchronous way to do this or maybe there is built-in function to od this. Link to comment Share on other sites More sharing options...
nrbdch Posted December 16, 2018 Share Posted December 16, 2018 Is it necessary to calculate position every frame? Maybe you could update players position only when he is actually moving, or even only once after the move ends. Besides, I do not think that such simple calculations could slow down game in any noticeable way. Link to comment Share on other sites More sharing options...
microspace Posted December 18, 2018 Author Share Posted December 18, 2018 No, I don't need to calculate position every frame, only once he crosses tile boundary. On 12/16/2018 at 7:53 PM, nrbdch said: Besides, I do not think that such simple calculations could slow down game in any noticeable way. Maybe you are right Link to comment Share on other sites More sharing options...
Recommended Posts