Touhou Game Simulation Note

· Tech · Python / Game Development / Coordinate Systems

Original language · English · 中文译文

Touhou-style bullet hell simulation

After playing Touhou, I tried making a similar game in Python with some textures and music from the original. The basic game was straightforward; designing dense, attractive bullet patterns was the part that required layers of mathematical functions.

A coordinate bug from an older version

Two years earlier, when I had just started learning Java and GUI development, I made a Java version. Its bullets could not follow the player accurately at low speed.

The game updated at 60 FPS, and the rendering panel used exactly the same coordinates as the simulation. Because display positions were integers, bullet movement was forced into whole-pixel steps. The animation appeared to cross the screen normally, but slow bullets could only travel along a few quantized angles such as 0°, 45°, 90°, 135°, and 180°.

The fix

In the Python version, simulation coordinates are floating point and remain independent from display coordinates. Rendering rounds the calculated position to a pixel, but the rounded value never feeds back into the physics. This small separation restores smooth and precise guidance.