Skip to content

Commit 8f91917

Browse files
committed
+ added JetBrains cool font
+ added ticks amount
1 parent b07de9f commit 8f91917

5 files changed

Lines changed: 27 additions & 10 deletions

File tree

src/cfg.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default {
22
WORLD: { // section, where the world config leaves
3-
width: 2048, // world width in pixels
3+
width: 2000, // world width in pixels
44
height: 2000, // world height in pixels
55
zoom: 0.1 // zoom speed coefficient
66
},
@@ -14,8 +14,8 @@ export default {
1414
percent: .5, // amount of VMs from amount of atoms. if atoms.length === 10 & percent === .2 => VMs === 2
1515
},
1616
ATOM: {
17-
seed: 3, // seed for all random numbers in a system
18-
stackBufSize: 128, // stack size for mov atom (amount of moved atoms)
17+
seed: 1, // seed for all random numbers in a system
18+
stackBufSize: 1024, // stack size for mov atom (amount of moved atoms)
1919
percent: .15, // affects to amount of atoms in the world
2020
moveTries: 5, // amount of near atoms "mov" atom will move per one call
2121
NRG: {

src/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
<html>
33
<head>
44
<title>irma5 - ALife digital organisms simulator</title>
5+
<style>
6+
@font-face {
7+
font-family: 'JetBrainsMono';
8+
src: url('/JetBrainsMono-Medium.woff2') format('woff2');
9+
}
10+
</style>
511
</head>
612
<body>
713
<canvas id="irma5"></canvas>

src/irma.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ function run() {
8989
// Create instances of the world, plugins, atoms & VMs
9090
//
9191
const w = World() // 2D world
92-
const plugins = [Title(w), Buttons(w)] // plugins of the world
9392
let atoms = createAtoms(w) // array of atoms [{x, y, a},...]
9493
let vmOffs = createVMs(w, atoms) // array of virtual machines by coordinates + energies
9594
//let atoms = [{x: 3, y: 3, a: 0x21bf}]
@@ -102,6 +101,7 @@ const vms = VMs(w) // VMs instance
102101
addAtoms(w, atoms)
103102
addVMs(vms, vmOffs)
104103
atoms = vmOffs = undefined // we have to remove global vars manually
104+
const plugins = [Title(w, vms), Buttons(w)] // plugins of the world
105105
//
106106
// Run infinite loop of the simulator
107107
//

src/plugins/title.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import CFG from '../cfg.js'
22

3-
export default function Title(w) {
3+
export default function Title(w, vms) {
44
const $ = document.querySelector.bind(document)
55
return {
66
w,
7+
vms,
78
title: '',
89
titleEl: $(CFG.HTML.titleQuery),
910
t: performance.now(),
11+
rps: 0,
1012
ticks: 0,
1113
update
1214
}
@@ -16,12 +18,21 @@ export function destroy(t) {
1618
t.w.title = null
1719
}
1820

21+
function format(n) {
22+
if (n >= 1_000_000_000_000) return (n / 1_000_000_000_000).toFixed(1) + 'T';
23+
if (n >= 1_000_000_000) return (n / 1_000_000_000).toFixed(1) + 'B';
24+
if (n >= 1_000_000) return (n / 1_000_000).toFixed(1) + 'M';
25+
if (n >= 1_000) return (n / 1_000).toFixed(1) + 'K';
26+
return n.toString();
27+
}
28+
1929
function update(t) {
2030
const now = performance.now()
21-
t.ticks++
31+
t.rps++
32+
t.ticks += CFG.rpi * t.vms.offs.i
2233
if (now - t.t > 1000) {
2334
t.t = now
24-
t.titleEl.textContent = t.ticks
25-
t.ticks = 0
35+
t.titleEl.textContent = `rps: ${t.rps}, tks: ${format(t.ticks)}`
36+
t.rps = 0
2637
}
2738
}

src/styles.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ body {
5252

5353
.title {
5454
position : absolute;
55-
top : 7px;
55+
top : 6px;
5656
left : 60px;
5757
color : #fff;
5858
font-size : 18px;
59-
font-family: Consolas;
59+
font-family: JetBrainsMono;
6060
}

0 commit comments

Comments
 (0)