From a47649786fb94684c415b230669fbf5343cb7c5d Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Wed, 3 Jan 2018 13:57:51 +0000 Subject: [Engine] [Example] Added simple bullets that don't move --- examples/shooter/main.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'examples/shooter/main.cpp') diff --git a/examples/shooter/main.cpp b/examples/shooter/main.cpp index 9a8d22d0..c63c0cab 100644 --- a/examples/shooter/main.cpp +++ b/examples/shooter/main.cpp @@ -1,7 +1,10 @@ #include -#include "player.h" #include "bullet.h" +#include "player.h" + +#include +#include using std::cout; @@ -10,6 +13,8 @@ int main(int argc, char **argv) yage::Window window; window.create("Shooter example", 800, 600); + std::vector> objects; + yage::Shader shader("examples/resources/textureshader.vert", "examples/resources/textureshader.frag"); @@ -64,7 +69,7 @@ int main(int argc, char **argv) auto textures = male_l; Player player({400, 300, 48 * 2, 64 * 2}, textures.front()); - Bullet bullet({400, 300, 25, 25}); + objects.push_back(std::make_unique(glm::vec4(400, 300, 25, 25))); while (!window.shouldClose()) { window.pollEvents(); @@ -116,13 +121,25 @@ int main(int argc, char **argv) c_pressed = false; } + if (window.keyPressed(yage::key::RIGHT)) { + objects.push_back(std::make_unique(glm::vec4(player.position().x, player.position().y, 25, 25))); + } else if (window.keyPressed(yage::key::DOWN)) { + + } else if (window.keyPressed(yage::key::LEFT)) { + } else if (window.keyPressed(yage::key::UP)) { + } + player.setTexture(textures[i]); camera.update(shader); window.clearBuffer(); player.draw(sp); - bullet.draw(sp); + + for(auto &&object : objects) { + object->draw(sp); + } + sp.render(); window.swapBuffer(); -- cgit