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.cc 649B

123456789101112131415161718192021
  1. #include "WGDefault.h"
  2. void WGDefault::genChunk(Swan::WorldPlane &plane, Swan::Chunk &chunk) {
  3. for (int cx = 0; cx < Swan::CHUNK_WIDTH; ++cx) {
  4. for (int cy = 0; cy < Swan::CHUNK_HEIGHT; ++cy) {
  5. Swan::TilePos tpos = Swan::TilePos(cx, cy) + chunk.pos_ * Swan::TILE_SIZE;
  6. if (tpos.y_ == 3)
  7. chunk.tiles_[cx][cy] = tGrass_;
  8. else if (tpos.y_ > 3 && tpos.y_ <= 5)
  9. chunk.tiles_[cx][cy] = tDirt_;
  10. else if (tpos.y_ > 5)
  11. chunk.tiles_[cx][cy] = tStone_;
  12. else
  13. chunk.tiles_[cx][cy] = tAir_;
  14. }
  15. }
  16. }
  17. Swan::Entity &WGDefault::spawnPlayer(Swan::WorldPlane &plane) {
  18. return plane.spawnEntity("core::player", Swan::Vec2(0, 0));
  19. }