|
23 | 23 |
|
24 | 24 | (defn add-random-planet |
25 | 25 | [{planets :planets |
| 26 | + [x, y] :position |
26 | 27 | [width, height] :size |
27 | 28 | :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))] |
31 | 32 | (assoc world |
32 | 33 | :planets (conj planets (make-planet [x, y] radius))))) |
33 | 34 |
|
|
59 | 60 | :missiles (conj missiles new-missile) |
60 | 61 | :traces (conj traces [])))) |
61 | 62 |
|
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 | | - |
76 | 63 | ;;; Fragments related stuff |
77 | 64 |
|
78 | 65 | (defn make-fragment |
|
93 | 80 | :radius player-radius}) |
94 | 81 |
|
95 | 82 | (defn add-random-player |
96 | | - [{[width, height] :size |
| 83 | + [{[x, y] :position |
| 84 | + [width, height] :size |
97 | 85 | players :players |
98 | 86 | :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))] |
101 | 89 | (assoc world |
102 | 90 | :players (conj players (make-player [x, y] [0, 3.0]))))) |
103 | 91 |
|
|
0 commit comments