+void
+collide_with_list(Sprite *s, Sprite *list)
+{
+ for(; list; list=list->next)
+ if(collide(s, list)) do_collision(s, list);
+}
+
+void
+collisions(void)
+{
+ int i, end = gw*gh;
+ Sprite *s;
+ for(i=0; i<end; i++) {
+ for(s=sprites[set][i]; s; s=s->next) {
+ collide_with_list(s, s->next);
+ if(i+1 < end) collide_with_list(s, sprites[set][i+1]);
+ if(i+gw < end) collide_with_list(s, sprites[set][i+gw]);
+ if(i+gw+1 < end) collide_with_list(s, sprites[set][i+gw+1]);
+ }
+ }
+}
+