Compare commits
2 Commits
de99d54ad6
...
4ce265e722
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ce265e722 | |||
| 572e02956c |
@@ -18,6 +18,7 @@ public class Element {
|
|||||||
protected int lastMove = 0;
|
protected int lastMove = 0;
|
||||||
|
|
||||||
private bool active = false;
|
private bool active = false;
|
||||||
|
private bool wasMovedThisTick = false;
|
||||||
private int lastUpdate = -1;
|
private int lastUpdate = -1;
|
||||||
private Color originalColor;
|
private Color originalColor;
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ public class Element {
|
|||||||
|
|
||||||
active = value;
|
active = value;
|
||||||
Chunk.SetElementActive(this, value);
|
Chunk.SetElementActive(this, value);
|
||||||
|
Moved();
|
||||||
// SetDebugColor(value, new Color(0.2f, 0.2f, 0.2f));
|
// SetDebugColor(value, new Color(0.2f, 0.2f, 0.2f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,6 +70,7 @@ public class Element {
|
|||||||
|
|
||||||
protected virtual void Tick() {
|
protected virtual void Tick() {
|
||||||
Vector2I randomDirection = RandomDirectionDown();
|
Vector2I randomDirection = RandomDirectionDown();
|
||||||
|
wasMovedThisTick = false;
|
||||||
|
|
||||||
if (Chunk.IsEmpty(Position + Vector2I.Down))
|
if (Chunk.IsEmpty(Position + Vector2I.Down))
|
||||||
Chunk.Swap(this, Position + Vector2I.Down);
|
Chunk.Swap(this, Position + Vector2I.Down);
|
||||||
@@ -109,9 +112,15 @@ public class Element {
|
|||||||
if (!Main.Instance.DebugVisualization) return;
|
if (!Main.Instance.DebugVisualization) return;
|
||||||
|
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
wasMovedThisTick = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Moved() {
|
public void Moved() {
|
||||||
lastMove = Engine.GetFramesDrawn();
|
lastMove = Engine.GetFramesDrawn();
|
||||||
|
wasMovedThisTick = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool WasMoved() {
|
||||||
|
return wasMovedThisTick;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class Level {
|
|||||||
GD.Print("benchmark");
|
GD.Print("benchmark");
|
||||||
for (int x = 0; x < chunksPerX; x++) {
|
for (int x = 0; x < chunksPerX; x++) {
|
||||||
for (int y = 0; y < chunksPerY; y++) {
|
for (int y = 0; y < chunksPerY; y++) {
|
||||||
WritePixel<Dirt>(x * chunkResX/2, y * chunkResY/2, 100);
|
WritePixel<Dirt>((x * chunkResX) + chunkResX/2, (y * chunkResY) + chunkResY/2, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,12 +148,16 @@ public class Level {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Image DrawLevel() {
|
public Image DrawLevel() {
|
||||||
|
// chunk
|
||||||
for (int cx = 0; cx < chunksPerX; cx++) {
|
for (int cx = 0; cx < chunksPerX; cx++) {
|
||||||
for (int cy = 0; cy < chunksPerY; cy++) {
|
for (int cy = 0; cy < chunksPerY; cy++) {
|
||||||
|
|
||||||
|
// pixel in chunk
|
||||||
for (int x = 0; x < chunkResX; x++) {
|
for (int x = 0; x < chunkResX; x++) {
|
||||||
for (int y = 0; y < chunkResY; y++) {
|
for (int y = 0; y < chunkResY; y++) {
|
||||||
// TODO: multithreading here! use Chunk.DrawLevel() and stitch images together
|
// TODO: multithreading here! use Chunk.DrawLevel() and stitch images together
|
||||||
|
|
||||||
|
if (chunks[cx, cy].Elements[x, y].WasMoved())
|
||||||
image.SetPixel(cx*chunkResX + x, cy*chunkResY + y, chunks[cx, cy].Elements[x, y].Color);
|
image.SetPixel(cx*chunkResX + x, cy*chunkResY + y, chunks[cx, cy].Elements[x, y].Color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user