2026rltutorial

r/roguelikedev Roguelike Tutorial 2026

Native Javascript, no third party libraries

Part-5

Part-5 of the tutorial is about “Placing Enemies and kicking them (harmlessly)” but, I am feeling a bit non-violent at the moment, so I call it “Placing and bumping actors”.

Steps

How it went

The initial refactor is moving entities[] from the engine to the gameMap, including the function that renders them. Simple enough.

To patch up one of the many problems I left from Part-4, I moved Field of View creation into the movement action processing so that it does not update every frame. I also added a one-time FOV creation main.js so that the player can see things at the game start, before they first move. This small patch is here.

Some interesting bits from the next step:

The tutorial has us using a deep copy (Python copy.deepcopy() which I replace with JS structuredClone() and Object.setPrototypeOf()) of instantiated “plain objects” or “literals”. I don’t like the idea of defining data outside of my primary entrypoint in main() but, in the spirit of following the tutorial, I do it anyway. This updated method of creating actors can be seen here.

Letting us bump other entities seems straight forward, but first I need to fix a problem with entity placement that allowed entities to be placed on overlapping tiles, and the total placed entities to exceed the max per room. Then implementing the check for blocking entities is simple.

I am a little confused by the next steps in the tutorial where we enable interaction with other entities (attack actions, in the tutorial.) It has “bump actions” as a child of “direction actions”, and these “bump actions” then decide if the correct action is a move or attack. I’m not sure why the tutorial goes through the extra step; should the decision not be made in the “direction action”?

I really don’t see what value the intermediary “bump action” adds, but I implement it here. I did have a bit of trouble getting my #handleEvents() loop to recognize second-level actions instanced by BumpAction, and the updated version of the game loop is based on a suggestion from a chatbot.

Demo

GitPages