Building a labyrinth-game, controlling the mouse to get to the cheese while avoiding the cat.

I thought simple block graphics would do nicely for the most part, and maybe leave out textures as well, just use nice colors…?

I´ve made a few sketches, but I´ll try to make new ones with iDraw. I also tried to compose something up-tempo music for it. I´ll put it here in some form when I got more time.

Hey pirke, I made something that may be helpful for your cat and mouse maze game :slight_smile:
It’s a bit incomplete, and will require a lot of work on your end, but it’s a good start and has easy map-making and uses tile-based graphics(with customizable colours! It even has collisions already done for you and a lights-out mode. Tell me what you think!

@Luatee : Lighting! Yeah, will be important. :slight_smile:
@Monkeyman32123 : looks nice, I´ll skim through the code. ;D Made me think about how we should conceal areas that you wouldn´t want to show. Might be done with the perspective of the mouse though.
Also, should normally be pretty dark inside walls… maybe the atmosphere of this game will be a dark one. A scary game.

@Pirke colours can be nice, but you would want to use lighting to your advantage here to make the blocks stand out and not look too bland.

Sounds interesting! Keep me updated! :smiley:

Here’s a 3D tip: use as few meshes as possible. If you have a map of tiles, I’ve found it’s incredibly inefficient and slow to make something like a Block class, and draw a cube, with all its sides, a ton of times. It’s easy, just not very optimized. What you could do instead would probably take a lot of maths and logic, but it would be best if you could take all the blocks and create the mesh vertices one time that only has the visible faces.

I’ve found that I could run a very small world using Block classes and a lot of different cube meshes at 30 FPS, with the amount rendered being limited to just the edge of the screen for better performance. Later, I figured out I could generate one mesh, one time, and it would be much faster. I had a Map class that simply stored a 2D table of values, and a World class that would take the Map’s table and generate a mesh based on the values. I could run an utterly massive (2048x2048) world at 60 FPS, with beautiful rolling hills. This also was good for lighting. I found if I used a simple perlin noise texture for grass (128x128 image), I could generate color tints for individual vertices based on the slope, giving a lighting effect without having to do any fancy calculations.

Edit: Screenshots!

The block class game:


The single mesh game:


You may be seeing more of the latter game in the future. :wink:

@skythecoder are you sure you use only the slope in above image to generate shadows? i think i can see casted shadows…?

@Jmv38 Yep, no shader for that, it’s only a solid 128x128 generated grass texture with mesh.colors tints. I can send the code if you want. The part to generate the shadow effects is kind of messy and I’ll probably clean it up later, but it does work, and looks pretty nice.

@skythecoder actually i’ll be inerested to test your code if you want to pm it to me. Thanks.

@SkyTheCoder : Excellent tip! :smiley:
That single mesh-game-thing looks amazing, but yeah, it´s always a good trick to not render what you can´t see. I remember Morrowind was really heavy on my monster computer (at that time) but then some dud made the simplest mod to make it stop rendering invisible parts of the game. I think it was the smallest mod ever, with the greatest effect. Went from 30 something fps to past 100, only a few lines of code. And I could set viewing distance to full, since it only rendered my line of view.

@SkyTheCoder, @Pirke - if you want the terrain to be less spiky, what professionals seem to do is to average the height of neighbouring vertices to achieve greater smoothness.

@Ignatz I could apply any effects I want to the terrain with the way I handled it. But it’d have to be done while starting up. It takes a while to generate the mesh, but could probably be optimized. The spikes in there are on purpose though, it’s amplified perlin noise.

If I made the map a lot smaller and optimized some functions or Lua tweaks, I could probably make it possible for realtime editing of the terrain.

The map is actually 2D, not blocks or anything, so it only works with hills. It would probably be a lot bit harder to make a mesh for a 3D map, but possible. It wouldn’t be very easy for something like Minecraft, which would require recalculating the mesh very frequently.

What about the cat? Wouldn’t it be hard to create an ‘artificial intelligence’ system for the cat to go around the labyrinth? Also, wouldn’t generating a moving cat in 3d be difficult? I’m not that great at Lua, so I’m not sure.

@Saturn031000 AI doesn’t have to be that hard. With a simple set of rules you can make a decent AI. Since this cat and mouse game kind of resembles Pac-Man, you can take a look at this article, which explains the algorithms behind the four different ghosts:

@Kjell I guess that makes sense. Cool article.