Hot answers tagged

3

Your nodes in A* can be anything you want them to be. So you don't have to use either the circles or the triangles as your nodes. Each node can contain information about both: Node(C, T) = portion of {circle C} overlapping {triangle T} Now when you want to enumerate the neighbours of a given node, you search for... circles that overlap circle C in the same ...


2

(Assuming your borders are only 1-pixel wide. If they're thicker, do a pre-process to thin the borders/expand their regions until there's only a 1 pixel separation between regions) Prepare an array of region IDs as large as your image, initialized with a default "unassigned" value. Iterate over the pixels of your image in some order. If you come ...


2

I tried it out in the Online Encyclopedia of Integer Sequences and found this one for the top half of the diamond: i = floor((-1 + sqrt(1+4*number))/2) The bottom half just needs to be reversed, like you’ve already done when going the other way.


2

My suggestion would be to do both: Start by just following the tutorials and using the text file. This will give you a nice way of getting your head around what's going on in the code, and how you can easily play with the data Once you're comfortable with this, move on to using Tiled (or similar). This is a more advanced tool, which needs to be coded ...


2

To ensure all castles 1-100 are present, simply shuffle an array containing all the numbers 1-100. You can either do this once when you first generate the map and then hold onto it, or you can use a seeded random number generator to assist with the shuffle so that you get consistent results each time. Here is an example in Python. If you're using another ...


1

Start with an area of dimensions fib(i) by fib(i-1) units, then... Pick a starting "end" of the shape. Create a "room" square of size fib(i-1) Set the new working area to the original area minus the room. Decrease i and repeat. You can obviously reverse the process and start from the inside.


1

I couldn't figure out what Konrad's variables were supposed to mean in my game (map width? My map is infinite, so... that's the same as the screen width then maybe? It didn't work out), so I figured it out from scratch. The way I figured: (TL;DR: read only the bold parts.) When zooming, some pixels drop off the screen (zooming in) or newly become visible ...


Only top voted, non community-wiki answers of a minimum length are eligible