diff --git a/src/main.cpp b/src/main.cpp index c715447..c43eaa9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,12 +27,14 @@ struct Tiles { }; int main() { - int screenWidth = 1200; - int screenHeight = 800; + int screenWidth = 1980; + int screenHeight = 1080; raylib::Window window(screenWidth, screenHeight, "raylib-cpp - basic window"); + window.SetFullscreen(true); + SetTargetFPS(60); GenDefaultTexture(); @@ -46,6 +48,8 @@ int main() { player.spriteid = 0; entityTextures.LoadImage("./src/assets/playersprite.png"); + std::cout << "kms\n"; + tileTextures.LoadImage("./src/assets/transparent.png"); tileTextures.LoadImage("./src/assets/BasicTile.png"); tileTextures.LoadImage("./src/assets/rock1.png"); @@ -62,7 +66,8 @@ int main() { int chunkx = 0; int chunky = 0; - + std::cout << "textures and includes loaded, window stuff now\n"; + while (!window.ShouldClose()) { float deltatime = GetFrameTime(); @@ -93,8 +98,8 @@ int main() { storedPosition.x += camera.target.x - screenWidth / 2.0f; storedPosition.y += camera.target.y - screenHeight / 2.0f; - chunkx = storedPosition.x / 8 / 64; - chunky = storedPosition.y / 8 / 64; + chunkx = storedPosition.x / 8 / 64 - 1; + chunky = storedPosition.y / 8 / 64 - 1; int tileindex = (int)storedPosition.x % (8*64) / 64 + 8 * ((int)storedPosition.y % (8*64) / 64); @@ -102,9 +107,16 @@ int main() { std::cout << "placed at: " << chunkx << ", " << chunky << ". index: " << tileindex << "\n"; + Coordinate chunk; + chunk.x = chunkx; + chunk.y = chunky; - gamemap.layers[1].chunks[Coordinate{chunkx, chunky}].tiles[tileindex].spriteid = 1; + for (auto it = gamemap.layers[0].chunks.begin(); it != gamemap.layers[0].chunks.end(); ++it) { + std::cout << it->first.x << ", " << it->first.y << "\n"; + } + gamemap.layers[1].chunks[chunk].tiles[tileindex].spriteid = 1; + } diff --git a/src/tiles/tilebase.cpp b/src/tiles/tilebase.cpp index a8f358d..8c15b03 100644 --- a/src/tiles/tilebase.cpp +++ b/src/tiles/tilebase.cpp @@ -1,7 +1,6 @@ #include "tilebase.hpp" #include "iostream" -#include Coordinate::Coordinate() { x = 0; @@ -43,7 +42,8 @@ Chunk::Chunk() : position(0, 0), owner(nullptr) { tiles.reserve(64); for (int i = 0; i < 64; i++) { - tiles.emplace_back(i, 0, this); + int spriteid = owner->id > 0; + tiles.emplace_back(i, spriteid, this); } } @@ -110,13 +110,15 @@ void Map::Draw(raylib::Rectangle aera) { } void Map::Init() { - for (int x = -1; x < 2; x++) { - for (int y = -1; y < 2; y++) { - layers[0].chunks.emplace( - std::piecewise_construct, - std::forward_as_tuple(Coordinate{x, y}), // key - std::forward_as_tuple(Coordinate{x, y}, &layers[0]) // value: construct Chunk here - ); + for (int i = 0; i < 4; i++) { + for (int x = -1; x < 2; x++) { + for (int y = -1; y < 2; y++) { + layers[i].chunks.emplace( + std::piecewise_construct, + std::forward_as_tuple(Coordinate{x, y}), // key + std::forward_as_tuple(Coordinate{x, y}, &layers[i]) + );// value: construct Chunk here + } } } }