Changeset cd1cb0f in opengl-game for vulkan-game.cpp


Ignore:
Timestamp:
Dec 24, 2019, 12:48:49 AM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
0fe8433
Parents:
a79be34
git-author:
Dmitry Portnoy <dmitry.portnoy@…> (12/22/19 03:45:12)
git-committer:
Dmitry Portnoy <dmitry.portnoy@…> (12/24/19 00:48:49)
Message:

In VulkanGame, make the ship move when the player holds down the right or left arrow keys

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    ra79be34 rcd1cb0f  
    508508
    509509   createSyncObjects();
     510
     511   shipPipeline.getObjects()[0].model_base =
     512      translate(mat4(1.0f), vec3(0.0f, -1.2f, 1.65f)) *
     513      scale(mat4(1.0f), vec3(0.1f, 0.1f, 0.1f));
    510514}
    511515
     
    608612      }
    609613
     614      // Check which keys are held down
     615
     616      if (gui->keyPressed(SDL_SCANCODE_LEFT)) {
     617         transformObject(shipPipeline.getObjects()[0], translate(mat4(1.0f), vec3(-0.01f, 0.0f, 0.0f)));
     618      } else if (gui->keyPressed(SDL_SCANCODE_RIGHT)) {
     619         transformObject(shipPipeline.getObjects()[0], translate(mat4(1.0f), vec3(0.01f, 0.0f, 0.0f)));
     620      }
     621
    610622      renderUI();
    611623      renderScene();
     
    623635   float time = chrono::duration<float, chrono::seconds::period>(currentTime - startTime).count();
    624636
     637   // TODO: Will need to change this to go through all objects of all pipelines and update their model mats
     638
    625639   so_Object.model =
    626640      translate(mat4(1.0f), vec3(0.0f, -2.0f, -0.0f)) *
    627641      rotate(mat4(1.0f), time * radians(90.0f), vec3(0.0f, 0.0f, 1.0f));
    628642
    629    so_Ship.model =
    630       translate(mat4(1.0f), vec3(0.0f, -1.2f, 1.65f)) *
    631       scale(mat4(1.0f), vec3(0.1f, 0.1f, 0.1f));
     643   so_Ship.model = shipPipeline.getObjects()[0].model_transform * shipPipeline.getObjects()[0].model_base;
    632644
    633645   VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_scenePipeline[currentImage], object_VP_mats);
Note: See TracChangeset for help on using the changeset viewer.