Day 9: React & Map generating algorithms…

Well I guess this is my 10th day, as I did start on day 0. I’m not sure why but it now makes my 100th day of coding end up on day 99. Oh well I guess I will just have to do one more day and I will get to 101 days of coding… I’m a 10th of the way there! Woooop, 9 more sections of the same size to go! I’m buzzing to get started on the backend section of FreeCodeCamp, I’m not sure why but I think I will enjoy that part, a lot more than just front-end development/data visualisation. Although I do find React particularly fun… Moreover I have been planning to write my own blog for eons, and I guess with all that backend knowledge and hopefully some MongoDB I will be able to store my posts somewhere, but we will see. That is still someway in the future…

So after a while of developing this map generation algorithm. I think I’m quite happy with it. So lets walk through it.
First what I did was design a boundary for the random point generation. Essentially in the long term these points will be developing into ‘nodes’, i.e. the point but with some radius docked onto it, so it looks more like a circle. Therefore we want these nodes to be somewhat more centralised, to ensure that we have a boundary of walls around the side of the map. Then after this step, I added the radius to each node, such that I was generating five to six points on this map. Then after this was working quite well, I added a function to connect each node to its closest two neighbours. I mean I could have chosen more, but the more you add the more complex it gets, and the less walled off space you have. Given a certain area of map and such like. So I thought it would be best if I kept it to just the nearest two. This difference was calculated using “Pythagoras’ theorem”. After I did that the map was basically done, I just had to figure out how best to render the map using React. I then added all the various other parts of the game onto the map, albeit randomly generated. These parts included things like extra weapons, more health-points and monsters…

Now I have to add the functionality to each of these extra parts and then I am basically done with this game. Which I guess will the last of the React projects, but I will definitely be coming back to React and front-end development.

Peace.

post.close();

Leave a Reply

Your email address will not be published. Required fields are marked *