Changeset 4ece3bf in opengl-game for vulkan-game.cpp
- Timestamp:
- Jan 21, 2020, 6:14:09 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 5a1ace0
- Parents:
- 3e8cc8b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
r3e8cc8b r4ece3bf 98 98 SDL_VERSION(&sdlVersion); 99 99 100 cout << "SDL " << sdlVersion.major << "." << sdlVersion.minor << "." << sdlVersion.patch << endl; 100 cout << "SDL "<< 101 to_string(sdlVersion.major) << "." << 102 to_string(sdlVersion.minor) << "." << 103 to_string(sdlVersion.patch) << endl; 101 104 102 105 font = TTF_OpenFont("assets/fonts/lazy.ttf", 28); … … 600 603 scale(mat4(1.0f), vec3(0.1f, 0.1f, 0.1f)); 601 604 602 //vec3 pos = vec3(getRandomNum(-1.3f, 1.3f), -1.2f, getRandomNum(-5.5f, -4.5f)); 603 vec3 pos = vec3(getRandomNum(-1.3f, 1.3f), -1.2f, -2.0f); 605 // vec3 pos = vec3(getRandomNum(-1.3f, 1.3f), -1.2f, getRandomNum(-5.5f, -4.5f)); 606 // vec3 pos = vec3(getRandomNum(-1.3f, 1.3f), -1.2f, -2.0f); 607 // vec3 pos = vec3(1.0f, -1.2f, -1.0f); 608 vec3 pos = vec3(0.0504826f, -1.2f, 1.0f); 604 609 605 610 asteroidObjects[0].model_base = … … 608 613 scale(mat4(1.0f), vec3(0.1f, 0.1f, 0.1f)); 609 614 asteroidObjects[0].model_transform = mat4(1.0); // Might not be needed 615 616 so_Asteroid.hp = 10.0f; 617 so_Asteroid.deleted = 0; 610 618 } 611 619 … … 655 663 bool quit = false; 656 664 665 curTime = SDL_GetPerformanceCounter(); 666 657 667 while (!quit) { 668 669 prevTime = curTime; 670 curTime = SDL_GetPerformanceCounter(); 671 672 elapsedTime = (double)((curTime - prevTime) * 1000 / (double)SDL_GetPerformanceFrequency()); 673 658 674 gui->processEvents(); 659 675 … … 693 709 694 710 createCommandBuffers(); 711 } else if (e.key.keycode == SDL_SCANCODE_Z) { 712 cout << "Deleting asteroid..." << endl; 713 so_Asteroid.deleted = so_Asteroid.deleted == 0 ? 1 : 0; 695 714 } else { 696 715 cout << "Key event detected" << endl; … … 717 736 // Check which keys are held down 718 737 738 float shipSpeed = 0.0005f; 739 float asteroidSpeed = 0.002f; 740 719 741 if (gui->keyPressed(SDL_SCANCODE_LEFT)) { 720 transformObject(shipObjects[0], translate(mat4(1.0f), vec3(- 0.01f, 0.0f, 0.0f)));742 transformObject(shipObjects[0], translate(mat4(1.0f), vec3(-shipSpeed * elapsedTime, 0.0f, 0.0f))); 721 743 } else if (gui->keyPressed(SDL_SCANCODE_RIGHT)) { 722 transformObject(shipObjects[0], translate(mat4(1.0f), vec3( 0.01f, 0.0f, 0.0f)));744 transformObject(shipObjects[0], translate(mat4(1.0f), vec3(shipSpeed * elapsedTime, 0.0f, 0.0f))); 723 745 } 724 746 725 // this code moves the asteroids 726 transformObject(asteroidObjects[0], translate(mat4(1.0f), vec3(0.0f, 0.0f, 0.04f))); 747 if (gui->keyPressed(SDL_SCANCODE_DOWN)) { 748 transformObject(asteroidObjects[0], translate(mat4(1.0f), vec3(0.0f, 0.0f, asteroidSpeed * elapsedTime))); 749 } 727 750 728 751 renderUI(); … … 750 773 751 774 so_Asteroid.model = asteroidObjects[0].model_transform * asteroidObjects[0].model_base; 752 so_Asteroid.hp = 10.0;753 775 754 776 VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_scenePipeline[currentImage], object_VP_mats);
Note:
See TracChangeset
for help on using the changeset viewer.