News for hackers. Stuff that matters.
Re:We put a distributed database in the browser and made a g... by captainhorst on Wednesday July 12, 2023 @03:32PM (#36700407)
Re:We put a distributed database in the browser and made a g... by cdchn on Wednesday July 12, 2023 @06:12PM (#36702386)
Nice! Looks pretty rad. I've never used Zig but it sure looks like an interesting language. Did NanoVG help with the animation stuff like the little text that pops out of the beetles and the lines that zip between them?
Re:We put a distributed database in the browser and made a g... by captainhorst on Monday July 17, 2023 @07:21AM (#36756627)
Sorry, totally missed your reply! At first we had normal text and then we switched them for hand-drawn sprites. The text animation consists of 2D transformations (translation, rotation, scale) interpolated over time. It's all animated in code. NanoVG helps by having a transformation stack like OpenGL. In Zig I can open a block like this:

{ vg.save(); defer vg.restore(); // undo all transformations at the end of the block

  vg.translate(...);
  vg.rotate(...);
  vg.scale(...);
  // draw sprite
} // continue to draw the rest of the scene