DEV Community

Adam Crockett πŸŒ€
Adam Crockett πŸŒ€

Posted on

Do you know the board game risk? 🌍

I have been wondering lately about the potential of making a fun little game inspired by risk.

How would I go about procedurally generate continents and countries with wobbly lined borders? I'm leaning towards SVGs btw.

Top comments (8)

Collapse
Β 
ben profile image
Collapse
Β 
mateiadrielrafael profile image
Matei Adriel β€’

P5 has pretty bad performance and it encourafges bad practices - coming from a guy who used to love p5

Collapse
Β 
ben profile image
Ben Halpern β€’

Yeah I've never used it, it just came to mind as a possible fit for the solution based on what I've read about it. Do you have any alternative ideas?

Thread Thread
Β 
mateiadrielrafael profile image
Matei Adriel β€’

Pixi looks cool, but I havent tried it

Collapse
Β 
adam_cyclones profile image
Adam Crockett πŸŒ€ β€’

Yeah, I watched the coding train videos, and I saw some strangeness with P5, It treats canvas as something a bit different to normal webdev.

I was asking more about the algorithm used to generate 2d terrain that looks like a map.

Collapse
Β 
joshgrib profile image
Josh Gribbon β€’

I'd try something along the lines of:

  • Pick some points to be the centers of continents
  • Place some random points clustered around each continent center
  • Use something like a Voronoi diagram to create the borders for the counts
  • Make the borders a little more wavy
Collapse
Β 
adam_cyclones profile image
Adam Crockett πŸŒ€ β€’

Welcome Josh!

I think this sounds about right yes.

Architecturally I'm going to use this:

The actor model with the, and maybe challenge myself with pick.js

I will use typescript and xstate as per the video.

Collapse
Β 
adam_cyclones profile image
Adam Crockett πŸŒ€ β€’

So more on the algorithm side, voronoi or centroids.