Skip to content

Commit

Permalink
tuneup - refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois-Esquire committed Jun 21, 2018
1 parent c11c88c commit ef103ad
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Library/
ProjectSettings/
Temp/
*.csproj
*.meta
Expand Down
6 changes: 4 additions & 2 deletions Assets/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public enum BlockType { GRASS, DIRT, STONE, BEDROCK, REDSTONE, DIAMOND, AIR };
{ /* DIAMOND */
new Vector2( 0.125f, 0.75f ), new Vector2( 0.1875f, 0.75f ),
new Vector2( 0.125f, 0.8125f ), new Vector2( 0.1875f, 0.8125f )
},
}
};

public enum Healthstate { NOCRACK, CRACK1, CRACK2, CRACK3, CRACK4 };
Expand All @@ -76,7 +76,7 @@ public enum Healthstate { NOCRACK, CRACK1, CRACK2, CRACK3, CRACK4 };
new Vector2( 0.1875f, 0.0625f ), new Vector2( 0.25f, 0.0625f )
}
};

public bool isSolid;
public int hitpoints;
public Healthstate health;
Expand Down Expand Up @@ -130,6 +130,8 @@ public bool HitBlock() {
public void Draw() {
if (isSolid) {
// TODO: could be optimized, no need to check for inner blocks.
// possibly set checks from within constructor - assign a var isEdge
// could be extended with edge types such as corner.

// Culling
if (!HasSolidNeighbour((int)position.x, (int)position.y, (int)position.z + 1))
Expand Down
1 change: 1 addition & 0 deletions Assets/Chunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ bool Load() {
}

public void Save() {
// Not Working properly.
string chunkFile = BuildChunkFileName(chunk.transform.position);

if (File.Exists(chunkFile) == false)
Expand Down
8 changes: 4 additions & 4 deletions Assets/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

public class Utils {

// to avoid any negative values & mirroring
static float offset = 32000;

static int maxHeight = 150;
static float smooth = 0.01f;
static int octaves = 4;
Expand All @@ -27,7 +30,7 @@ public static float FBM3D(float x, float y, float z, float sm, int oct) {
return (XY + YZ + XZ + YX + ZY + ZX)/6.0f;
}

static float Map(float newMin, float newMax, float origMin, float origMax,float value) {
static float Map(float newMin, float newMax, float origMin, float origMax, float value) {
float inverse = Mathf.InverseLerp(origMin, origMax, value);
return Mathf.Lerp(newMin, newMax, inverse);
}
Expand All @@ -39,9 +42,6 @@ static float FBM(float x, float z, int oct, float pers) {
float amplitude = 1;
float maxValue = 1;

// to avoid any negative values & mirroring
float offset = 32000;

for (int i = 0; i < oct; i++) {
total += Mathf.PerlinNoise((x + offset) * frequency, (z + offset) * frequency) * amplitude;

Expand Down
2 changes: 0 additions & 2 deletions README

This file was deleted.

0 comments on commit ef103ad

Please sign in to comment.