]> git.localhorst.tv Git - blank.git/blobdiff - src/interface.cpp
begun block lighting implementation
[blank.git] / src / interface.cpp
index 03c059f7301dfb644b2ef7ddbebce72a91ad3eb5..f4b13b015d6d69fcbf6adbfc6e0a92d6c3d6454e 100644 (file)
@@ -73,6 +73,11 @@ void Interface::Handle(const SDL_KeyboardEvent &event) {
                                PrintBlockInfo();
                        }
                        break;
+               case SDLK_l:
+                       if (event.state == SDL_PRESSED) {
+                               PrintLightInfo();
+                       }
+                       break;
                case SDLK_p:
                        if (event.state == SDL_PRESSED) {
                                PrintSelectionInfo();
@@ -104,6 +109,13 @@ void Interface::PrintBlockInfo() {
        Print(aim_chunk->BlockAt(aim_block));
 }
 
+void Interface::PrintLightInfo() {
+       std::cout
+               << "light level " << world.PlayerChunk().GetLight(world.Player().Position())
+               << " at position " << world.Player().Position()
+               << std::endl;
+}
+
 void Interface::PrintSelectionInfo() {
        std::cout << std::endl;
        Print(selection);
@@ -148,13 +160,13 @@ void Interface::PlaceBlock() {
                mod_chunk = &world.Next(*aim_chunk, aim_normal);
                next_pos -= aim_normal * glm::vec3(Chunk::Extent());
        }
-       mod_chunk->BlockAt(next_pos) = selection;
+       mod_chunk->SetBlock(next_pos, selection);
        mod_chunk->Invalidate();
 }
 
 void Interface::RemoveBlock() {
        if (!aim_chunk) return;
-       aim_chunk->BlockAt(aim_block) = remove;
+       aim_chunk->SetBlock(aim_block, remove);
        aim_chunk->Invalidate();
 }