Skip to main content

Pits and Prisms

·314 words·2 mins

I added a new obstacle. A pit. It’s an area where blocks can’t be placed but lasers can pass.

I’ll also need steam or fog or something: an area where blocks can be placed but lasers cannot. I already have an idea for a puzzle using that. (-:

I also tried making convex and concave lenses. I was a little scared I’d have to handle the maths for that manually (may still do) but I was hopeful that Godot would handle it when I learned about CSG, Constructive Solid Geometry.

I can create lenses using circles, rectangles, and the operations intersection and subtraction. I think union is already sort of a thing if you have a scene that has two collision objects in it.

Godot has CSG for 3D but not yet for 2D. “Yet” because there’s a pull request open for 2D CSG.

So I have three paths:

  • Do my own collision maths for lenses. This would deter me from experimenting with other shapes.
  • Wait for 2D CSG or perhaps build my own Godot and use the existing branch.
  • Wrangle the 3D CSG… either change my whole project to 3D for this or maybe there’s another way..?

Doing my own collision maths might not be too bad. I can model the collision shape for the lens with a polygon. When a laser collision occurs then I can calculate the normal using a circle.

For now I’ll work on the rectangular or triangular prism. I’ll have to play around with them to get a feel for them before I’ll know what kinda level to make.

Ah. So exciting.

Hmm. Getting performance problems with only 10 lasers. I wonder which bits of code are taking so much CPU time. One thing I can do is to recalculate the laser collisions only when pieces are moved around but I’m kinda surprised it’s an issue at all.