2323
2424(defn add-random-planet
2525 [{planets :planets
26+ [x, y] :position
2627 [width, height] :size
2728 :as world}]
28- (let [radius (-> (min width height) (/ 4 ) rand)
29- x (rand-range radius (- width radius))
30- y (rand-range radius (- height radius))]
29+ (let [radius (-> (min width height) (/ 5 ) rand)
30+ x (rand-range ( + x radius) (- ( + x width) radius))
31+ y (rand-range ( + y radius) (- ( + y height) radius))]
3132 (assoc world
3233 :planets (conj planets (make-planet [x, y] radius)))))
3334
5960 :missiles (conj missiles new-missile)
6061 :traces (conj traces []))))
6162
62- (defn add-random-missile
63- [{[width, height] :size
64- :as world}]
65- (let [x (rand-range missile-radius (- width missile-radius))
66- y (rand-range missile-radius (- height missile-radius))
67- vx (rand-range -300 300 )
68- vy (rand-range -300 300 )]
69- (add-missile world [x, y] [vx, vy])))
70-
71- (defn generate-missiles
72- [world]
73- (-> (iterate add-random-missile world)
74- (nth amount-of-missiles)))
75-
7663; ;; Fragments related stuff
7764
7865(defn make-fragment
9380 :radius player-radius})
9481
9582(defn add-random-player
96- [{[width, height] :size
83+ [{[x, y] :position
84+ [width, height] :size
9785 players :players
9886 :as world}]
99- (let [x (rand-range player-radius (- width player-radius))
100- y (rand-range player-radius (- height player-radius))]
87+ (let [x (rand-range ( + x player-radius) (- ( + x width) player-radius))
88+ y (rand-range ( + y player-radius) (- ( + y height) player-radius))]
10189 (assoc world
10290 :players (conj players (make-player [x, y] [0 , 3.0 ])))))
10391
119107 :traces []
120108 :exit false }
121109 generate-players
122- generate-planets
123- generate-missiles))
110+ generate-planets))
0 commit comments