]> git.localhorst.tv Git - blank.git/blobdiff - src/interface.cpp
begun block lighting implementation
[blank.git] / src / interface.cpp
index 00c291df605e7b799c820947ed09d5ca58ff439b..f4b13b015d6d69fcbf6adbfc6e0a92d6c3d6454e 100644 (file)
@@ -72,10 +72,17 @@ void Interface::Handle(const SDL_KeyboardEvent &event) {
                        if (event.state == SDL_PRESSED) {
                                PrintBlockInfo();
                        }
+                       break;
+               case SDLK_l:
+                       if (event.state == SDL_PRESSED) {
+                               PrintLightInfo();
+                       }
+                       break;
                case SDLK_p:
                        if (event.state == SDL_PRESSED) {
                                PrintSelectionInfo();
                        }
+                       break;
        }
 }
 
@@ -102,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);
@@ -146,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();
 }