A 2D tile-based sandbox game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WGDefault.h 887B

1234567891011121314151617181920212223242526
  1. #pragma once
  2. #include <swan/swan.h>
  3. #include <PerlinNoise/PerlinNoise.hpp>
  4. class WGDefault: public Swan::WorldGen {
  5. public:
  6. class Factory: public Swan::WorldGen::Factory {
  7. public:
  8. WorldGen *create(Swan::World &world) override { return new WGDefault(world); }
  9. };
  10. WGDefault(Swan::World &world):
  11. tGrass_(world.getTileID("core::grass")), tDirt_(world.getTileID("core::dirt")),
  12. tStone_(world.getTileID("core::stone")), tAir_(world.getTileID("core::air")),
  13. tTreeTrunk_(world.getTileID("core::tree-trunk")), tLeaves_(world.getTileID("core::leaves")) {}
  14. void genChunk(Swan::WorldPlane &plane, Swan::Chunk &chunk) override;
  15. Swan::BodyTrait::HasBody *spawnPlayer(Swan::WorldPlane &plane) override;
  16. private:
  17. Swan::Tile::ID genTile(Swan::TilePos pos);
  18. Swan::Tile::ID tGrass_, tDirt_, tStone_, tAir_, tTreeTrunk_, tLeaves_;
  19. siv::PerlinNoise perlin_ = siv::PerlinNoise(100);
  20. };