aboutsummaryrefslogtreecommitdiffstats
path: root/examples/shooter/main.cpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-01-03 13:57:51 +0000
committerYann Herklotz <ymherklotz@gmail.com>2018-01-03 13:57:51 +0000
commita47649786fb94684c415b230669fbf5343cb7c5d (patch)
treeb35c5921bf90ed7b091f1bc2f08f370436abe834 /examples/shooter/main.cpp
parent86e4aa6265ade205aba94494a7a31a83b5686387 (diff)
downloadYAGE-a47649786fb94684c415b230669fbf5343cb7c5d.tar.gz
YAGE-a47649786fb94684c415b230669fbf5343cb7c5d.zip
[Engine] [Example] Added simple bullets that don't move
Diffstat (limited to 'examples/shooter/main.cpp')
-rw-r--r--examples/shooter/main.cpp23
1 files changed, 20 insertions, 3 deletions
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 <yage/yage.h>
-#include "player.h"
#include "bullet.h"
+#include "player.h"
+
+#include <vector>
+#include <memory>
using std::cout;
@@ -10,6 +13,8 @@ int main(int argc, char **argv)
yage::Window window;
window.create("Shooter example", 800, 600);
+ std::vector<std::unique_ptr<yage::Drawable>> 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<Bullet>(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<Bullet>(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();