On Monday, August 5, 2013 9:58:31 PM UTC+2, Brandon Jumbeck wrote:
>
> The collision map is usually handled as an invisible layer in the tmx file.
>>
>
> Hmm I am not sure I get what you mean by invisible layer in the tmx file. 
> Could you explain this a bit more please?  
>

You create a layer with your map editor (I use tiled), you use a set of W&B 
tiles for the collision mask and you set your layer invisible. It appears 
this way in the tmx :

<layer name="collisions" visible="0" width="180" height="120">
  <data encoding="base64" compression="zlib">
   ...
  </data>
 </layer>
 
Of course, you have to code your own routine to check collision. 
Personnally, I used numpy.arrays of boolean for representing each 
"collision_tile". I wrote a function collision(collision_layer, 
collision_tiles, x, y) to check if the bit at position (x, y) on the layer 
is masked or not, then I test only the pixels on the edge of the object I 
want to test. It was fast enough on my first attempt, but my second being 
more ambitious, I'll use numpy abilities to work on entire array.

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to