•      Sign In
• Create Account

# yahiko00

Member Since 25 Jun 2013
Online Last Active Today, 12:36 AM

### #5306388Distinct quadtrees for static and moving objects

Posted by on 17 August 2016 - 12:46 PM

I am currently implementing a quadtree (in TypeScript) for a game prototype.

In order to optimize performances, a little bit, instead of managing just one quadtree for all game objects, I am wondering if it would be speed-wise to separate static objects (like walls) from movings objects (like characters).

This way, the static layer shall never be updated (cleared and populated) each frame which may save some CPU cycles.

Obviously, in order to check collision, we will have to retrieve objects from both the static and the moving objects layers.

What do you think about this idea? Is it relevant?

### #5243988Land/Sea ratio from a Heightmap

Posted by on 01 August 2015 - 07:14 AM

Thank you for your reply. While you were writing your answer, I came up with another solution involving the histogram.
I define my ranges according to the average altitude of the map and its standard deviation.

First, I compute the cumulative histogram cumHisto:
```    var cumHisto = 0;

for (var i = 0; i < World.width; i++) {
for (var j = 0; j < World.height; j++) {
cumHisto += World.mapData[i][j];
} // for j
} // for i
```

Then, I compute the average altitude avgHeight:
```    var nbPoints = World.width * World.height;
var avgAltitude = cumHisto / nbPoints;
```

I need a loop to compute the standard deviation stdevAltitude, based on the variance varAltitude:
```    var varAltitude = 0;
for (var i = 0; i < World.width; i++) {
for (var j = 0; j < World.height; j++) {
var diff = World.mapData[i][j] - avgAltitude;
varAltitude += diff * diff;
} // for j
} // for i

var varAltitude = varAltitude / nbPoints;
var stdevAltitude = Math.sqrt(varAltitude);
```

Given the average altitude and its standard deviation, I can define four ranges which seem to give quite reliable results:
```    for (var i = 0; i < World.width; i++) {
for (var j = 0; j < World.height; j++) {
if (World.mapData[i][j] < avgAltitude) {
World.mapData[i][j] = Terrain.DEEP_OCEAN;
}
else if (World.mapData[i][j] < avgAltitude + 0.5 * stdevAltitude) {
World.mapData[i][j] = Terrain.COASTAL_OCEAN;
}
else if (World.mapData[i][j] < avgAltitude + 2 * stdevAltitude) {
World.mapData[i][j] = Terrain.FLAT;
}
else {
World.mapData[i][j] = Terrain.MOUNTAIN;
}
} // for j
} // for i
```

### #5080572Why companies still use C++ and what should I learn then

Posted by on 25 July 2013 - 03:30 PM

I think Javascript (yes you read it well!) is the future for game programming since web browsers are becoming the new OS.

So, nowadays, I would not recommend starting with C++ to a young guy wanting to become a game developper.

PARTNERS