collision detection & resize

1. The collision detection feature is added.
2. When resize the window, layout can display in right way.