methusalah / OpenRTS

Real-Time Strategy game 3D engine coded in pure java
MIT License
1.29k stars 151 forks source link

Hauteur maximale dans la classe HeightTool #65

Closed ghost closed 9 years ago

ghost commented 9 years ago

N'ayant vu aucune sécurité sur la hauteur maximale du terrain avec l'outil height, j'en ai rajouté une. Ma méthode est de définir une constante nommée MAX_HEIGHT et de tester si la hauteur est supérieure a cette constante, si oui, alors elle y est égale. EDIT : personnellement, j'ai mis MAX_HEIGHT a 50

methusalah commented 9 years ago

Pas faux, il faudra faire de même pour le min_height ^^

Attention, le projet est cosmopolite et l'anglais est de mise !

methusalah commented 9 years ago

Terrain height can definitly be under 0.

ghost commented 9 years ago

I've seen it just after posting and made the changes

methusalah commented 9 years ago

Great ☺you may create a pull request, or paste the code change here and I'll do the commit.

Thanks for the contribution!

Le ven. 15 mai 2015 14:10, Code Campus notifications@github.com a écrit :

I've seen it just after posting and made the changes

— Reply to this email directly or view it on GitHub https://github.com/methusalah/OpenRTS/issues/65#issuecomment-102382832.

ghost commented 9 years ago

here is the code

private static final int MAX_HEIGHT = 30, MIN_HEIGHT = -10;
private void raise(List<Tile> tiles){
    for(Tile t : tiles) {
        t.elevation += amplitude*pencil.strength*pencil.getApplicationRatio(t.getCoord());

        if(t.elevation > MAX_HEIGHT)
            t.elevation = MAX_HEIGHT;
    }
}

private void low(List<Tile> tiles){
    for(Tile t : tiles) {
        t.elevation -= amplitude*pencil.strength*pencil.getApplicationRatio(t.getCoord());

        if(t.elevation < MIN_HEIGHT)
            t.elevation = MIN_HEIGHT;
    }
}