2,938 reputation
616
bio website redblobgames.com
location California
age
visits member for 3 years, 9 months
seen 2 hours ago

I help people make games. On my new site ("Red Blob Games") I post interactive tutorials and guides to game algorithms. On my previous site (Amit's Game Programming Information) I collect links to useful pages about maps, grids, tiles, pathfinding, and AI. On my blog ("Blobs in Games") I post experiments and projects and ideas. Previously I was an advisor to Wild Shadow Studios (Realm of the Mad God) and Root 1 (educational games).


Jul
21
comment Fast, simple procedural 2d island generation
You might be able to use fewer octaves. The lower octaves are smoother than the higher ones. Or you might post-process in some way, to smooth out the corners with some sort of blur algorithm. For example, set a block to water if its eight neighbors include at least 3 water (you might need to try different numbers). This might remove some of the rough borders.
Jul
20
answered Fast, simple procedural 2d island generation
Jul
12
comment Set value in an array[3], that the sum of all three values is always 1.0
That looks like it should work. A unit test for this function should include cases where rates before and after are 0.0 and 1.0.
Jul
12
comment Set value in an array[3], that the sum of all three values is always 1.0
Note that this solution can still fail, if 1.0 - rate[index] is 0.0. That will happen when 100% of the resource is assigned to one value, and you try to take away from it. I guess you'd have to handle this special case, probably by evenly distributing the remainder to the other values. If you treat 0 values as epsilon instead of 0.0 then it will work out, I think.
Jul
12
answered Set value in an array[3], that the sum of all three values is always 1.0
Jul
12
comment Preventing diagonal movement
If you press A then velX gets set to non-zero, and then if you press S after that without letting go of A, velY gets set to non-zero, so you get diagonal movement. If you want to stop moving in Y when someone presses A or D, then you need to set velY to 0 when you set velX to non-0, and vice versa
Jul
12
comment Set value in an array[3], that the sum of all three values is always 1.0
You'll also need to handle upper and lower bounds. For example, if you start with {0.4, 0.6, 0.0} and want to increase the first to 0.5, then =change= will be -0.05. You'll end up with {0.5, 0.55, -0.05}.
Jul
8
answered Mouse follow precision in flash
Jul
8
comment Smoothing Pathfinding on Tile-Based Terrain but Free-Roaming Player
Notice that all the places where you turn, one of the four corners of the 2x2 box meets one of the corners of the walls. That suggests that you might be able to do pathfinding from point to point, if you can analyze your map ahead of time. And then you don't need to smooth the path because it's not a grid path in the first place.
Jul
3
comment AI / Pathfinding gets stuck
This can happen in games as old as Chess. What do you want the enemy to do in this situation?
Jun
11
comment Inconsistent movement / line-of-sight around obstacles on a hexagonal grid
Isn't this true on square grids too? I think this is both an advantage and disadvantage of using grids.
Jun
1
comment How to follow object on CatmullRomSplines at constant speed (e.g. train and train carriage)?
BTW railroads and roads mostly use circular arcs instead of catmull-rom or bezier splines. The math is simpler in some ways, especially the math for following the paths and determining lengths of sections.
May
30
comment 2D Boxes/Vertices merging
The "connected components labeling" algorithm can find everything connected together. You mark each "object" with a separate identifier (int or color), then you only keep the edges that are between two tiles from different objects. If you have only one object, or objects that don't touch, it's even simpler: keep only the edges between two tiles of different objects.
May
19
awarded  Custodian
May
19
reviewed Approve suggested edit on Is a game engine actually needed to make games?
May
18
comment Line of sight on a 2d grid
Sorry - I forgot to "save" the jsfiddle code. See jsfiddle.net/M9y6z/2
May
18
comment Line of sight on a 2d grid
I made an updated jsfiddle that shows how using manhattan length, as well as round instead of float, generates the same points as line_slope() but with much simpler code: jsfiddle.net/M9y6z (I also updated line_slope to use Math.round since the question is asking about tiles)
May
18
comment Line of sight on a 2d grid
BTW, use length = Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)) to match the interpolation code I posted. I believe it will not generate any duplicates, and then you don't need lastX and lastY.
May
17
answered Line of sight on a 2d grid
May
16
comment Dynamic thruster balancing of space ship
I went down a similar path and ended up writing a demo on this page. As you move the thrusters around (drag them on the ship to set position and power) it draws three shapes. The intuition is that you can think of all possible movements as a point in 3d space (x, y, rotation), and being limited to 0-1 is a constraint in that space. So you end up with a 3d shape containing all possible movements. If you want no linear velocity you're looking at the (x=0,y=0) line in that space (Q,W,E,S all 0 in my demo)