vrld / HC

General purpose collision detection library for the use with LÖVE.
http://hc.readthedocs.org/
402 stars 48 forks source link

Shape:move, Shape:rotate, Shape:neighbors, Shape:_removeFromHash #13

Closed kikito closed 12 years ago

kikito commented 12 years ago

These four Shape methods are defined on the instance level (added to each instance on creation instead of being on the class) inside HC:new_shape.

I imagine that the reasoning behind this decision is that shapes don't have to "know about HC".

This seems a bit "backwards" to me. In my opinion, if rotate affects both HC and the shape, then it should either be a method of HC exclusively (HC:rotate(shape)) or shapes should hold a reference to HC so they can notify it (shape:init(HC, ...))

vrld commented 12 years ago

The shapes need to update the spatial hash when moved/rotated, but only when created using the main module.

Because HC is modular - you can roll your own shape management if you want to - shape:move(...) is required to be bound to the shape. HC:move(shape, ...) would duplicate functionality. For the same reason - i.e. transparent, modular API - shapes may not hold a reference to the HC instance.