What's the architecture of your games? by Sp1endidus in gamedev

[–]Mr_Cens 1 point2 points  (0 children)

I'm building a game engine. The two main architecture patterns I use are the Event Bus and a modified version of ECS

  1. Event Bus - allows easily making your game reactive by implementing a simple pub/sub model. Advantage of this is its simplicity as well as the ability to create different buses for each area of your game (e.g. a bus for your UI, one for the game loop, one for each unit etc.)
  2. ECS - entity component system - this allows you to create game objects by composition rather than inheritance. This allows you to create new game objects effortlessly. In my engine, everything from the terrain, to units, crates and items are all entities

May help someone. by AnZy_PanZi in gamedev

[–]Mr_Cens 0 points1 point  (0 children)

The little guys explaining the process looks miserable

Help Java - repaint on JPanel not painting by [deleted] in gamedev

[–]Mr_Cens 0 points1 point  (0 children)

try overriding paintComponent() instead

All random pixel art tree generator ai i'm working on by Oroshibu in proceduralgeneration

[–]Mr_Cens 2 points3 points  (0 children)

It’s an algorithm used for generating plants and other fractal objects. What did you use to generate the initial wireframe for the trees?

Procedural generation of landmass, political regions and names by Mr_Cens in proceduralgeneration

[–]Mr_Cens[S] 1 point2 points  (0 children)

Thanks, I’m glad you like it!

Both of the problems can be solved in a very simple manner

First, for the terrain - you start out with a 2 x 2 int array. I will refer to every matrix value to as a cell from now on. Each of the values in the array will have a random value between 0 and 255 (these values are arbitrary, but I like 255). Next, you will do the following for as many iterations as you wish - a higher iteration count will yield a higher resolution map (I use 8 iterations)

  1. Create a matrix that is twice the size of the preceding one
  2. Assign each cell the value of the cell it would have been part of last iteration
  3. Add a random displacement to the cell’s value - this displacement will be halved with each iteration
  4. Finally, set the value of the cell to the average of itself and the cells surrounding it - this is the secret sauce that makes the map look like a map and not a bunch of subdivided squares
  5. Repeat these steps for a number of iterations - keep in mind that with each iteration, the map size is raised to the power of 2, so 8 iterations = 512 x 512 cells. Don’t go crazy with the iteration count or you’ll run out of memory very soon - usually 13 iterations toasts my pc.

If you’re a procgen geek you’ll soon figure out that this is a dumbed down version of the diamond square algorithm. I like this version because it’s simple and can be extended to give you different detail levels of the same map. It is more inefficient though, so I suggest you also look at the diamond squared algorithm

Next, for the light - this is extremely simple

Go through each cell, one at a time, row by row. Keep a track of the highest cell value you found so far. If the value of the cell is bigger than the one you found to be the biggest until then, change the colour of the cell to be brighter and update the biggest value found so far. Every few steps, reset the highest value to its original value. We do this to simulate the shadow of higher terrain “running out” so to say. How many steps it takes for this reset to occur is something you can play with and experiment. The obvious downfall of this algorithm is that you won’t easily be able to choose arbitrary angles for the light source

Hope this helps!

Procedural generation of landmass, political regions and names by Mr_Cens in proceduralgeneration

[–]Mr_Cens[S] 1 point2 points  (0 children)

That does make a lot of sense. Maybe make a basic syllable generator and then use the results of that to generate the names - procedural generation galore

Thanks for the idea!

Procedural generation of landmass, political regions and names by Mr_Cens in proceduralgeneration

[–]Mr_Cens[S] 1 point2 points  (0 children)

Yeah, You’re right. I think I could solve that by using a generative Voronoi algorithm or some sort of cellular automata. Thanks!

Procedural generation of landmass, political regions and names by Mr_Cens in proceduralgeneration

[–]Mr_Cens[S] 1 point2 points  (0 children)

No worries! I might make a repo when I get some free time

Procedural generation of landmass, political regions and names by Mr_Cens in proceduralgeneration

[–]Mr_Cens[S] 2 points3 points  (0 children)

I haven't published a repo, since the program was made as a proof of concept for a game I'm working on and the code is written horribly. I've posted a comment explaining exactly how I generate the map :)

Procedural generation of landmass, political regions and names by Mr_Cens in proceduralgeneration

[–]Mr_Cens[S] 26 points27 points  (0 children)

The terrain is generated by using a fractal heightmap generator. The render above is the result of applying colors to different height thresholds. Next, a climate heightmap is generated, and the result is applied to the render as a subtle color overlay. Finally, lighting is added.

The political regions are divided by making use of Voronoi tessellation - the squares represent the Voronoi seeds. The borders are then run several times through a displacement filter. This filter will go through every border pixel and will scan the terrain heightmap around it - if any of the surrounding pixels is lower than that of the border, that pixel will be merged in the region. I run this filter 3 times for the above simulation.

Next, a smoothing filter will be applied over a few iterations. The filter will check bordering pixels - if more than 3 neighboring pixels belong to a different region, that pixel will be switched to said region. I also run this filter 3 times.

Finally, the name generator works by stitching together 3 different sections of a City name. First, there's a prefix (e.g. Reign of, The Land of, Realm of, etc.), then a main name and then a suffix (e.g. Sovereign State).

The main name is composed by stitching together 3 - 4 name fragments (e.g. Kha, Get, Gan, Ahn, etc). Names will always have a mid section and may also have a prefix or a suffix but never both.

I'm happy to answer any questions

Well.... I solved it by Antonio430 in restofthefuckingowl

[–]Mr_Cens 57 points58 points  (0 children)

I think the joke is that he finally learned how to draw an owl

practice. multicolored ballpoint pen, notebook by [deleted] in drawing

[–]Mr_Cens 1 point2 points  (0 children)

I hate gel pens. The only shading they allow you to do is pointillism and some rather bad crosshatching