X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp.cpp;h=0d7e7dbb8fb511c40dbff366394699c99b1753e7;hb=addf4eb6485a36d40096d87196ed786e6e16ab6d;hp=21eb85c309830eca5f332d6f5cdd719d1b8da04a;hpb=753be639d7d04f9f7415db9fc2721485c531f0a1;p=blank.git diff --git a/src/app.cpp b/src/app.cpp index 21eb85c..0d7e7db 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) @@ -34,7 +35,7 @@ Application::Application() glGenVertexArrays(1, &VertexArrayID); glBindVertexArray(VertexArrayID); - world.Generate(); + world.Generate({ -4, -4, -4 }, { 5, 5, 5}); hud.Viewport(960, 600); hud.Display(*world.BlockTypes()[place_id]); @@ -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;