From 86e4aa6265ade205aba94494a7a31a83b5686387 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Wed, 3 Jan 2018 13:26:37 +0000 Subject: [Engine] [Example] Reenabled vsync and working on example. --- examples/shooter/bullet.cpp | 8 ++++++++ examples/shooter/bullet.h | 15 +++++++++++++++ examples/shooter/main.cpp | 3 +++ 3 files changed, 26 insertions(+) create mode 100644 examples/shooter/bullet.cpp create mode 100644 examples/shooter/bullet.h (limited to 'examples/shooter') diff --git a/examples/shooter/bullet.cpp b/examples/shooter/bullet.cpp new file mode 100644 index 00000000..55ce3f6e --- /dev/null +++ b/examples/shooter/bullet.cpp @@ -0,0 +1,8 @@ +#include "bullet.h" + +Bullet::Bullet(const glm::vec4 &bound) : bound_(bound) {} + +void Bullet::draw(yage::SpriteBatch &sp) const +{ + sp.draw(bound_, {0, 0, 1, 1}, yage::ResourceManager::getTexture("examples/resources/bullet.png").id, yage::Colour(255, 255, 255, 255), 0); +} diff --git a/examples/shooter/bullet.h b/examples/shooter/bullet.h new file mode 100644 index 00000000..37ea52ca --- /dev/null +++ b/examples/shooter/bullet.h @@ -0,0 +1,15 @@ +#ifndef EXAMPLES_SHOOTER_BULLET_H +#define EXAMPLES_SHOOTER_BULLET_H + +#include + +class Bullet { +public: + Bullet(const glm::vec4 &bound); + + void draw(yage::SpriteBatch &sp) const; +private: + glm::vec4 bound_; +}; + +#endif diff --git a/examples/shooter/main.cpp b/examples/shooter/main.cpp index d2727877..9a8d22d0 100644 --- a/examples/shooter/main.cpp +++ b/examples/shooter/main.cpp @@ -1,6 +1,7 @@ #include #include "player.h" +#include "bullet.h" using std::cout; @@ -63,6 +64,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}); while (!window.shouldClose()) { window.pollEvents(); @@ -120,6 +122,7 @@ int main(int argc, char **argv) window.clearBuffer(); player.draw(sp); + bullet.draw(sp); sp.render(); window.swapBuffer(); -- cgit