Skip to content

Commit

Permalink
Add more control options
Browse files Browse the repository at this point in the history
  • Loading branch information
MrEbbinghaus committed Nov 16, 2021
1 parent c909941 commit 450f6c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 9 additions & 2 deletions resources/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ <h1>Biosphere</h1>
<kbd>F11</kbd> for Fullscreen <br>
Use <code>?seed=1234</code> in the URL for seeded map.
</p>
<button onClick="biosphere.core.toggle_pause()">Pause / Unpause</button>
<button onClick="biosphere.core.restart()">Restart</button>
<button onclick="biosphere.core.toggle_pause_rendering()">Pause / Unpause Rendering</button>
<button onclick="biosphere.core.toggle_pause_simulation()">Pause / Unpause Simulation</button>
<button onclick="biosphere.core.restart()">Restart</button>
<form onsubmit="biosphere.core.set_tps(document.getElementById('tps-input').value);return false;">
<label for="tps-input">Set TPS</label>
<input id="tps-input" type="number"
min="1"
step="1"/>
</form>
</div>
<div id="biosphere"></div>
<script src="js/app.js"></script>
Expand Down
10 changes: 9 additions & 1 deletion src/biosphere/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@
(defn ^:export restart []
(swap! current-simulation sim/restart))

(defn ^:export toggle-pause []
(defn ^:export set-tps [tps]
(swap! current-simulation assoc :tps-goal tps))

(defn ^:export toggle-pause-rendering []
(when-let [sketch @current-sketch]
(if (draw/running? sketch)
(draw/stop! sketch)
(draw/start! sketch))))

(defn ^:export toggle-pause-simulation []
(if (:running? @current-simulation)
(sim/stop! current-simulation)
(sim/start! current-simulation)))

(comment

(require '[quil.core :as q])
Expand Down

0 comments on commit 450f6c4

Please sign in to comment.