-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added main menu background that scrolls across a randomly generated l…
…evel at a random time of day (also regressed version back to 1.4.1)
- Loading branch information
Showing
11 changed files
with
240 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package miniventure.game.client; | ||
|
||
import java.util.HashMap; | ||
|
||
import miniventure.game.world.Chunk; | ||
import miniventure.game.world.ClientLevel; | ||
import miniventure.game.world.Level; | ||
import miniventure.game.world.Point; | ||
import miniventure.game.world.entity.Entity; | ||
import miniventure.game.world.levelgen.LevelGenerator; | ||
import miniventure.game.world.tile.Tile; | ||
import miniventure.game.world.tile.TileType; | ||
|
||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.badlogic.gdx.math.Rectangle; | ||
import com.badlogic.gdx.math.Vector2; | ||
import com.badlogic.gdx.utils.Array; | ||
|
||
public class DisplayLevel extends Level { | ||
|
||
private final LevelGenerator generator; | ||
//private final HashMap<Point, Chunk> chunks = new HashMap<>(); | ||
|
||
public DisplayLevel(LevelGenerator generator) { | ||
super(new DisplayWorld(), 0, generator.worldWidth, generator.worldHeight); | ||
|
||
this.generator = generator; | ||
int y = 0; | ||
while(y * Chunk.SIZE < generator.worldHeight) { | ||
int x = 0; | ||
while(x * Chunk.SIZE < generator.worldWidth) { | ||
loadChunk(new Point(x, y)); | ||
x++; | ||
} | ||
|
||
y++; | ||
} | ||
} | ||
|
||
@Override | ||
public void render(Rectangle renderSpace, SpriteBatch batch, float delta, Vector2 posOffset) { | ||
ClientLevel.render(getOverlappingTiles(renderSpace), new Array<>(Entity.class), batch, delta, posOffset); | ||
} | ||
|
||
@Override | ||
protected Tile createTile(int x, int y, TileType[] types, String[] data) { | ||
return new DisplayTile(this, x, y, types, data); | ||
} | ||
|
||
@Override | ||
protected void loadChunk(Point chunkCoord) { | ||
loadChunk(new Chunk(chunkCoord.x, chunkCoord.y, this, generator.generateChunk(chunkCoord.x, chunkCoord.y))); | ||
} | ||
|
||
@Override | ||
protected void unloadChunk(Point chunkCoord) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package miniventure.game.client; | ||
|
||
import miniventure.game.world.Level; | ||
import miniventure.game.world.tile.ClientTile; | ||
import miniventure.game.world.tile.Tile; | ||
import miniventure.game.world.tile.TileType; | ||
|
||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.badlogic.gdx.math.Vector2; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class DisplayTile extends Tile { | ||
|
||
protected DisplayTile(@NotNull DisplayLevel level, int x, int y, @NotNull TileType[] types, @NotNull String[] data) { | ||
super(level, x, y, types, data); | ||
} | ||
|
||
@Override | ||
public void render(SpriteBatch batch, float delta, Vector2 posOffset) { | ||
ClientTile.render(this, batch, delta, posOffset); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package miniventure.game.client; | ||
|
||
import miniventure.game.world.Level; | ||
import miniventure.game.world.WorldManager; | ||
import miniventure.game.world.WorldObject; | ||
import miniventure.game.world.tile.TilePropertyFetcher; | ||
|
||
import com.badlogic.gdx.utils.Array; | ||
|
||
public class DisplayWorld extends WorldManager { | ||
|
||
public DisplayWorld() { super(new TilePropertyFetcher(prop -> prop)); } | ||
|
||
@Override | ||
protected boolean doDaylightCycle() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean worldLoaded() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void createWorld(int width, int height) {} | ||
|
||
@Override | ||
public void exitWorld(boolean save) {} | ||
|
||
@Override | ||
public boolean isKeepAlive(WorldObject obj) { return true; } | ||
|
||
@Override | ||
public Array<WorldObject> getKeepAlives(Level level) { return new Array<>(); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.