New answers tagged

1

You could use a hashtable with a key which consists of both the x-coordinate and y-coordinate. Finding the tile at a specific coordinate is then a constant-time operation. When you want to cache the "outline", you could store it in another hashtable. Whenever a node is added, follow this algorithm: the new node is removed from the "outline" hashtable for ...


1

A lot of great stuff covered in the other answers. Here's my take on (the perception of) win/loss probabilities. In the case of PvP, consider different ways to track & show win loss scores either directly or in some sort of cooked format (I.E. player rank). Specific examples: Puzzle Pirates ranks player performance relative to all of the other players ...


6

There are good points in DMGregory's answer. I especially like the one where a win/loss is split into multiple minor wins/losses, which is taken from slot machines - when in doubt copy slot machines, because they're the ultimate game where (almost) all players lose, yet so many continue to play. Let's add some more points: Use gamedesign to allow ...


0

The Phong model (diffuse + specular + ambient) is just an approximation of how light behaves. In reality, there's what's called a BRDF or bidirectional reflectance distribution function. It is a function which tell you, for a given point on the surface the probability of light bouncing in a given direction given an incident ray of light. The components ...


0

There's a trick you can use to numerically remove (or rather reduce as much as you want) any scaling from the upper 3x3 sub-matrix, assuming it's not singular. Let's call that 3x3 sub-matrix M. You can take the transpose of the inverse of M, and average it with M. That will be the new M for the next loop. while (...) { N = (transpose(inv(M)) + ...


3

I guess what you're looking for is what's called "Worley's Noise". https://aftbit.com/cell-noise-2/ It's very similar to what you're already doing. But instead of placing the points at the corners of the grid and moving them around, you place one (or more) points within each cell at random. When you want to find the closest point to a point P, you find ...


10

I see this question has a number of close votes for being too broad or opinion-based, but I think a reasonably sourced overview can be provided within the scope of a StackExchange answer - I'll take a stab at that here. Sid Meier talked about this problem in his 2010 GDC Talk "The Psychology of Game Design (Everything you know is wrong)" (this gave me an ...


2

I have solved this exact problem for my master's thesis over a year ago and have already talked about it here. Yesterday, I released an open source program with my multi-channel distance field construction algorithm, msdfgen, which you can try out right now. It is available on GitHub: https://github.com/Chlumsky/msdfgen If you are interested in how it ...


0

The usual way to animate 2d graphics is the good old method we use since the first days of animated cartoons: draw a separate graphic for each step of the animation and then display them in a loop. To get the animation phases right it often helps to look at the real thing and study how it moves.


2

Here is something that just popped into my mind: Have you seen the simulation of 3-body system? The two fighting ships can be two of the bodies, and a 3rd (invisible) body is there to create the chaos. Take a look at this video to get a feeling what it's going to look like in practice: https://www.youtube.com/watch?v=VX9IdCnNWJI Also since you are not ...


2

Is this what you want? As for finding the closest food stack, calculating the center of the swarm and using a simple A* algorithm to search all other food stack from the lowest minimum distance to the highest works, or even just a lookup table to map food stacks with their nearest neighbours (Only works if your food stacks are static and regrow). EDIT To ...


0

The easiest way to do this and find the literal "end" of a dead end is to count the walls. This is presuming that you cannot have loops and you define walls for your cells. Iterate through your cells and just find all with 3 walls as those are the only cells which are a dead end, as the can only have one exit it must have only 3 walls.


2

When i is 0 you copy the row 0 into the row 1, then i is 1 and you copy the row 1 into the row 2, etc. The problem is that when you copy the row 1, it has already been overriden. You probably also have a problem when i = HEIGHT because i+1 is out of bounds. The solution would be to iterate from the bottom row to the top row (from HEIGHT-1 to 1): for (i = ...


0

You can tag the tree in your group and then use FindGameObjectWithTag to get a list of all them. Next iterate over the list and destroy the game objects.


0

I fixed it: import SpriteKit func + (left: CGPoint, right: CGPoint) -> CGPoint { return CGPoint(x: left.x + right.x, y: left.y + right.y) } func - (left: CGPoint, right: CGPoint) -> CGPoint { return CGPoint(x: left.x - right.x, y: left.y - right.y) } func * (point: CGPoint, scalar: CGPoint) -> CGPoint { return CGPoint(x: point.x * ...


2

Assuming your matrix multiplication follows the convention... M * v = (T * R * S) * v (where M is your composed matrix, T is a Translation matrix, R rotation, S scale, and v is a vector you want to transform using the matrix) ...then you can normalize the first three columns of the matrix to get just the T * R part. If you use the opposite matrix ...


2

Create an isochrone map (https://en.wikipedia.org/wiki/Isochrone_map), get a polygon of all the points accessible within N units of time. An isochrone map basically looks like this (3 isochrones are represented in this example): Let's just focus on the red one, which takes a center point and a time (or a distance). Based on this time/distance limit, the ...



Top 50 recent answers are included