<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Sagui · Devlog</title>
    <link rel="self" type="application/atom+xml" href="https://saguiengine.pages.dev/en/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://saguiengine.pages.dev/en/devlog/"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-10-15T00:00:00+00:00</updated>
    <id>https://saguiengine.pages.dev/en/atom.xml</id>
    <entry xml:lang="en">
        <title>Stage 0 devlog: prove the hard parts before building</title>
        <published>2026-10-15T00:00:00+00:00</published>
        <updated>2026-10-15T00:00:00+00:00</updated>
        <author><name>Guilherme</name></author>
        <link rel="alternate" type="text/html" href="https://saguiengine.pages.dev/en/devlog/etapa-0/"/>
        <id>https://saguiengine.pages.dev/en/devlog/etapa-0/</id>
        <content type="html" xml:base="https://saguiengine.pages.dev/en/devlog/etapa-0/">&lt;p&gt;&lt;em&gt;The numbers are provisional: I measured them on my PC, and the official ones
will come from a modest laptop that has not arrived yet.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Sagui is a 2D game engine, that is, a program for making games. It
comes with its own language, SaguiScript, which tells each thing in the
game how to behave. Before building the real engine, I did stage 0: five small
tests, which I call proofs, each one tackling one of the project&#39;s biggest
risks. The proofs&#39; code goes in the bin. What stays is what I learned: the
measured numbers, what worked and what changed in the plan.&lt;/p&gt;
&lt;p&gt;I make Sagui with the help of Claude, an artificial intelligence: it
writes the code and takes the measurements, and I review, play and decide what
goes in. The five proofs were done between October 11 and 12, 2026.&lt;/p&gt;
&lt;h2 id=&quot;why-provisional&quot;&gt;Why &quot;provisional&quot;&lt;/h2&gt;
&lt;p&gt;Sagui&#39;s targets are for a modest machine: a 2018 laptop with an i5
processor and no separate graphics card. If it runs well there, it runs well on
most computers. That laptop has not arrived yet, so I measured on my PC, which
is much faster. To make up for it, on the PC a proof only counts as &quot;probably
passes&quot; if it uses at most half of the time allowed.&lt;/p&gt;
&lt;p&gt;Two words show up a lot:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Step:&lt;/strong&gt; the game recomputes the world (who moved, who hit whom) 60 times
per second, always at the same pace. Each recomputation is a step.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Frame:&lt;/strong&gt; each picture drawn on the screen. The screen shows 60 pictures per
second, so each one must be ready in about 16 thousandths of a second (ms).
If a picture takes longer, the screen &quot;stutters&quot; for a moment.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;the-five-proofs&quot;&gt;The five proofs&lt;/h2&gt;
&lt;h3 id=&quot;1-the-jump&quot;&gt;1. The jump&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;The risk:&lt;/strong&gt; a platformer lives or dies by its jump. On top of that, I want
the same game, played by pressing the same buttons, to end exactly the same on
any computer. That makes it possible to record a match and watch it again, to
save halfway and, one day, to play online.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The result:&lt;/strong&gt; a recorded 60-second match ends the same on Windows, on Linux
(another system, like Windows) and in the browser, at 60 or 120 steps per
second. Saving halfway, closing the program and carrying on in another one
also gives the same ending. The three ways of jumping (Precise, Smooth and
Heavy) were tuned by playing. Computing the movement and the collisions of 200
objects takes 0.023 ms per step, and the limit on the PC was 1 ms.&lt;/p&gt;
&lt;h3 id=&quot;2-the-editor-with-5-000-pieces&quot;&gt;2. The editor with 5,000 pieces&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;The risk:&lt;/strong&gt; the editor, the program where people build their game, getting
slow when a level holds a lot.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The result:&lt;/strong&gt; I tested with 5,000 pieces, and every platform, enemy or coin
in a level is a piece. Scrolling the list, selecting, dragging values, typing
and opening groups, 99% of the frames were ready in under 2 ms, against the
16 ms allowed. None went over 33 ms, the time of two frames.&lt;/p&gt;
&lt;figure class=&quot;figure&quot;&gt;&lt;a href=&quot;editor-5000-pecas.png&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;img src=&quot;editor-5000-pecas.png&quot; alt=&quot;The proof 2 editor, with 5,000 pieces in the Assembly list (editor in Portuguese)&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt; (opens in a new tab)&lt;/span&gt;&lt;/a&gt;&lt;figcaption class=&quot;caption&quot;&gt;The proof 2 editor, with 5,000 pieces in the Assembly list (editor in Portuguese).&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3 id=&quot;3-the-language-s-speed&quot;&gt;3. The language&#39;s speed&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;The risk:&lt;/strong&gt; SaguiScript being too slow for games with a lot going on
at once.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The result:&lt;/strong&gt; 5,000 pieces, each with its own small program, take 0.29 ms
per step, and the target is 4 ms. A &quot;watchdog&quot; stops a program stuck in an
endless loop, like a &quot;repeat forever&quot; written by mistake, so the game does not
freeze. It made nothing slower, so it stays on all the time. In the browser,
the language takes 1.5 times as long as the program installed on the computer,
which is enough for the site where people will learn SaguiScript.&lt;/p&gt;
&lt;h3 id=&quot;4-graphics-on-modest-computers&quot;&gt;4. Graphics on modest computers&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;The risk:&lt;/strong&gt; compatibility mode being too slow. It is the way of drawing that
works on old graphics cards and in the browser.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The result:&lt;/strong&gt; 2,000 sprites, the pictures of characters and objects, are
drawn with a single request to the graphics card, which saves a lot of time.
In Chrome, over 3,600 frames in a row (one minute), none was late. The
measurement in the installed program waits for the laptop: on my PC, the
monitor is plugged into the other graphics card, and the picture takes a
detour the laptop does not have.&lt;/p&gt;
&lt;figure class=&quot;figure&quot;&gt;&lt;a href=&quot;cena-2000-sprites.png&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;img src=&quot;cena-2000-sprites.png&quot; alt=&quot;The proof 4 test scene, in the big-pixel style of old games, with 2,000 sprites&quot; data-no-text&gt;&lt;span class=&quot;visually-hidden&quot;&gt; (opens in a new tab)&lt;/span&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&quot;5-playing-without-bringing-the-editor-down&quot;&gt;5. Playing without bringing the editor down&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;The risk:&lt;/strong&gt; an error in the game closing the editor too and taking the
creator&#39;s work with it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The result:&lt;/strong&gt; when you press Play, the game opens as a separate program that
talks to the editor. All 13 targets were met:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Frozen game:&lt;/strong&gt; the editor notices within 1.5 seconds and closes only the
game.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Crashing game:&lt;/strong&gt; the editor notices in under a tenth of a second and shows
a message with the reason.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reopening:&lt;/strong&gt; the game is back in 10 ms.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Game messages:&lt;/strong&gt; 10,000 messages per second reach the editor&#39;s panel
without losing a single one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;20 crashes in a row:&lt;/strong&gt; no copy of the game was left running, and the editor
did not start using more memory.&lt;/li&gt;
&lt;/ul&gt;
&lt;figure class=&quot;figure&quot;&gt;&lt;a href=&quot;console-do-editor.png&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;img src=&quot;console-do-editor.png&quot; alt=&quot;The editor&#39;s message panel after freezing and crashing the game on purpose (messages in Portuguese)&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt; (opens in a new tab)&lt;/span&gt;&lt;/a&gt;&lt;figcaption class=&quot;caption&quot;&gt;The editor&#39;s message panel after freezing and crashing the game on purpose (messages in Portuguese).&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2 id=&quot;what-went-wrong-and-how-i-fixed-it&quot;&gt;What went wrong (and how I fixed it)&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The leak that wasn&#39;t there.&lt;/strong&gt; The editor seemed to use a little more
memory every time the game crashed, which over time would slow the computer
down. After a long search, the bug was in the sum that measures memory: it
counted one part twice. With the right sum, memory stayed flat.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The editor without letters.&lt;/strong&gt; In proof 5, the screenshot the test takes on
its own showed the editor with no text at all: the files with the letters&#39;
shapes were missing. The automated tests did not catch it, because they check
buttons and text through the screen&#39;s description, not through the picture.
The lesson: look at the pictures too, not only at the tests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The 50 ms stutter.&lt;/strong&gt; In the editor proof, one frame took 50 ms, three
times the normal time, and the screen stuttered for a moment. It happened
only once, always right after the window opened. I first suspected the
letters, which are prepared the first time they show up. After eleven test
runs, everything points to Windows&#39; window-opening animation, not the editor.
The fix was to wait 1 second with the window open before starting to measure.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Outside code rejected.&lt;/strong&gt; The editor used ready-made code, written by other
people, to arrange its panels in tabs. It depended on other code that nobody
maintains anymore, and it failed the automatic check I run on everything that
comes from outside. I swapped it for another one that does almost the same.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The test computer out of space.&lt;/strong&gt; On every change, the tests run on their
own on a GitHub computer, GitHub being the site where the code lives. That
computer ran out of disk space. I freed space by deleting programs the
project does not use, without making the tests slower. I also cut the time
they take, because the free plan gives 2,000 minutes of tests per month.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The freeze arithmetic.&lt;/strong&gt; The plan said the editor would notice a frozen
game between 1.5 and 1.75 seconds. The right answer is between 1.25 and 1.5
seconds, because the game says it is alive every quarter of a second, and its
last message may have gone out a little before it froze. That gave the engine
a rule: this message will come from a part of the program that does nothing
else, so that loading a big level of the game does not look like a freeze.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;what-is-left&quot;&gt;What is left&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The laptop:&lt;/strong&gt; the official numbers of every proof, proof 4 in the installed
program and my own manual check, in Chrome and in Firefox.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Targets that are too loose:&lt;/strong&gt; almost every target had more than 80% to
spare on the PC. I will review them after the laptop&#39;s numbers, so as not to
tighten or loosen them blindly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Since the evening of October 12, the automated tests also run on a Mac, on
every change that goes in.&lt;/p&gt;
&lt;p&gt;With that, stage 0 is closed until the laptop arrives. Stage 1 starts from
scratch, with the engine&#39;s overall design already decided and with what I
learned here: first I write down what each part must do, then comes the code,
and each delivery only ends with the tests passing.&lt;/p&gt;
</content>
    </entry>
</feed>
