 (defn move-boxes [boxes]
   (vec (map move-box boxes)))
 
+(defn has-col [player box]
+  (let [left-player (- (:x player) (/ (:width player) 2))
+        right-player (+ (:x player) (/ (:width player) 2))        
+        left-box (- (:x box) (/ (:width box) 2))
+        right-box (+ (:x box) (/ (:width box) 2))        
+        up-player (+ (:y player) (/ (:height player) 2))
+        down-player (- (:y player) (/ (:height player) 2))        
+        up-box (+ (:y box) (/ (:height box) 2))
+        down-box (- (:y box) (/ (:height box) 2))]     
+    
+   
+  (or  
+  (and (> right-player  left-box) (< down-player up-box)
+       (> up-player up-box) (< left-player left-box))
+  (and (> right-player left-box) (> up-player down-box)
+       (< down-player down-box) (< left-player left-box))  
+   (and (< left-player right-box) (> up-player down-box)
+        (< down-player down-box) (> right-player right-box))
+   
+  (and (< left-player right-box) (< down-player up-box)
+       (> up-player up-box) (> right-player right-box)))))
+
+(defn has-collide [player boxes]
+  (let [collision false
+        collision (loop [x (dec (count boxes))]
+                    (when (>= x 0)
+                      (if (has-col player (get boxes x))
+                        true
+                        (recur (dec x)))))]
+    collision
+    ))
+
 (defn moving [entities]    
   (let [backgr (first entities)
         player (last entities)

                  []))]
    (conj (apply conj (conj [] backgr) boxes) player)))


(defscreen main-screen
  :on-show

  :on-render
  (fn [screen entities]
    (clear!)
    (render! screen 
             (->
               (moving entities)
               (collision)
               ))) 
       
  :on-timer
  (fn [screen entities]
