Lightning Fast 2D Games with Namakemono & Coni
Let’s face it: writing 2D browser games from scratch can be a total drag. Between managing Canvas contexts, handling asynchronous asset loading, and dealing with Javascript’s eccentricities, you often spend more time wrestling with boilerplate than actually designing your game.
Enter Namakemono—our incredibly cute and dangerously fast 2D game framework built natively in Coni targeting WebAssembly.

The Single State Philosophy
One of the biggest headaches in game development is state management. Do you keep your player, enemies, and projectiles in separate variables? What happens when an enemy needs to check the player’s position?
In Namakemono, we embrace the functional paradigm with a Single State Atom.
Instead of juggling a dozen different mutable references, your entire game universe lives inside one cohesive map:
(def *state*
(atom {:player {:x 160 :y 140 :hp 3}
:enemies []
:bullets []
:score 0
:phase :playing}))
This makes updating your game loop beautifully predictable. You take the old state, apply your physics and collisions, and return the new state. No side-effect spaghetti!
Less Code, More Game
With Coni’s elegant Clojure-like syntax, your game loop logic is incredibly dense and expressive. You can handle input, update positions, and render sprites in just a few lines of code.
Here is a complete drawing routine that renders the starry background, your player, and the enemies:
(defn draw [dt]
(clear COLOR-BLACK)
(let [st @*state*]
;; Draw parallax stars
(each! (:stars st) (fn [s]
(px (:x s) (:y s) COLOR-DARK-GRAY)))
;; Draw the player sprite from sprites.png
(let [p (:player st)]
(spr-ex :sprites 330 90 280 280 (:x p) (:y p) 16 16))
;; Iterate and draw all enemies
(each! (:enemies st) (fn [e]
(spr-ex :sprites 180 580 320 320 (:x e) (:y e) 16 16)))
;; Render the score UI
(text (str "SCORE: " (:score st)) 80 15 COLOR-WHITE)))
Notice how clean the data access is with (:player st) and how effortlessly we can iterate over collections using each!. You get the power of functional data transformations without the verbose boilerplate of traditional object-oriented game engines.
Auto-Loading Assets
Namakemono knows you just want to get straight to drawing sprites. Instead of writing complex fetch and Promise chains, the framework’s run! function automatically looks for an assets.json manifest.
If it finds one, it seamlessly loads your sprites.png directly into the engine before your first init function is even called.

The Result? Pure Fun.
By stripping away the boilerplate, Namakemono lets you focus on what actually matters: making your game fun. Whether you’re building a retro shoot-em-up or a cozy farming sim, the combination of Coni’s elegant Clojure-like syntax and WebAssembly’s native performance is a match made in heaven.

Want to see it in action? Check out the namakemono-apps directory in our Coni WASM repository and start building your own masterpiece today!