Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
fornwall committed Jun 22, 2023
1 parent f5148fb commit e43d488
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions site/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const generationsPerSecondDisplay = document.getElementById("generations-per-sec

canvas.focus();

globalThis.setNewState = function (ruleIdx, size, seed, density, paused, generationsPerSecond) {
globalThis.setNewState = function (ruleIdx, size, seed, density, paused, generationsPerSecond, frame) {
document.title = ruleSelect.options[ruleIdx].textContent;
sizeElement.textContent = size + 'x' + size;
ruleSelect.value = ruleIdx;
const queryString = `?rule=${ruleIdx}&size=${size}&seed=${seed}&density=${density}&paused=${paused}&gps=${generationsPerSecond}`;
const queryString = `?rule=${ruleIdx}&size=${size}&seed=${seed}&density=${density}&gps=${generationsPerSecond}&paused=${paused}` + (paused ? `&frame=${frame}` : '');
window.history.replaceState({}, '', queryString);
overlayElement.style.display = 'block';

Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ extern "C" {
density: u8,
paused: bool,
generations_per_second: u8,
frame: u64,
);

#[wasm_bindgen(js_name = toggleFullscreen)]
Expand Down Expand Up @@ -881,6 +882,7 @@ impl State {
self.initial_density,
self.paused,
self.generations_per_second,
if self.paused { self.frame_count } else { 0 },
);
}

Expand Down Expand Up @@ -952,9 +954,9 @@ impl State {
false
} else {
self.elapsed_time += self.last_time.elapsed().as_secs_f32();
self.last_time = instant::Instant::now();
self.elapsed_time > frequency
};
self.last_time = instant::Instant::now();

if advance_state {
self.elapsed_time -= frequency;
Expand Down

0 comments on commit e43d488

Please sign in to comment.