Collision detection when considering drawing through iteration.

Started by
9 comments, last by EricsonWillians 10 years ago

I've handled things in a somewhat unconventional way, I suppose. First of all, I don't exactly move things in my engine by pixel. I've created a generic Grid class that takes in its constructor a number of tiles in width, a number of tiles in height, the width of each tile and the height of each tile. I've created another class called GridMap, where I permute every possible "tile position combination" in the map (20x20 tiles, por example, than I would have: (0,0), (0,1), (0,2), ........ (5,7).... and so on). These tuples are keys in a dictionary, and I store the surfaces as a value for each key (And I draw them by iterating over the whole HashMap (Actually is more complicated, because of the XML file. So each value for each key-position of the hashmap has a tile ID and a surface asssociated with it.)). I did not show code because I would need to explain firstly how I've implemented the whole "grid system".. It's all based in keys/hashmaps, and things move by keys instead of pixels (And one can use more than one grid in the engine. Big tiles for drawing and small tiles for locomotion, for example.. But everything always fixed).

Creator and only composer at Poisone Wein and Übelkraft dark musical projects:

This topic is closed to new replies.

Advertisement