X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp.cpp;h=10a72b8e89e698f2abf52164df4bc91a6b164c96;hb=1a7bbd64b1fef1f4e2f9303f820d6f3ce76cebf1;hp=539858f58df74ba0adc865adda884169bcbd94f9;hpb=bea14b67ae4e5705965f3cc6422410a25f38ef9e;p=blank.git diff --git a/src/app.cpp b/src/app.cpp index 539858f..10a72b8 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -19,6 +19,7 @@ Application::Application() , cam() , hud() , world() +, controller(world.Player()) , outline() , outline_visible(false) , outline_transform(1.0f) @@ -68,7 +69,7 @@ void Application::HandleEvents() { switch (event.type) { case SDL_KEYDOWN: case SDL_KEYUP: - world.Controller().HandleKeyboard(event.key); + controller.HandleKeyboard(event.key); break; case SDL_MOUSEBUTTONDOWN: if (event.button.button == 1) { @@ -83,7 +84,7 @@ void Application::HandleEvents() { } break; case SDL_MOUSEMOTION: - world.Controller().HandleMouse(event.motion); + controller.HandleMouse(event.motion); break; case SDL_QUIT: running = false; @@ -105,9 +106,10 @@ void Application::HandleEvents() { } void Application::Update(int dt) { + controller.Update(dt); world.Update(dt); - Ray aim = world.Controller().Aim(); + Ray aim = controller.Aim(); Chunk *chunk; int blkid; float dist; @@ -117,7 +119,7 @@ void Application::Update(int dt) { outline_visible = true; outline.Clear(); chunk->BlockAt(blkid).type->FillOutlineModel(outline); - outline_transform = glm::translate(chunk->Transform(), pos); + outline_transform = glm::translate(chunk->Transform(world.Player().ChunkCoords()), pos); outline_transform = glm::scale(outline_transform, glm::vec3(1.0001f)); } else { outline_visible = false; @@ -143,7 +145,7 @@ void Application::Update(int dt) { glm::vec3 next_pos = Chunk::ToCoords(blkid) + normal; if (!Chunk::InBounds(next_pos)) { mod_chunk = &world.Next(*chunk, normal); - next_pos -= normal * Chunk::Extent(); + next_pos -= normal * glm::vec3(Chunk::Extent()); } mod_chunk->BlockAt(next_pos).type = world.BlockTypes()[place_id]; mod_chunk->Invalidate();