aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-01-03 13:26:37 +0000
committerYann Herklotz <ymherklotz@gmail.com>2018-01-03 13:27:23 +0000
commit86e4aa6265ade205aba94494a7a31a83b5686387 (patch)
treed7f9998b55d3fcc2b083242086afd05c1d436b6e /examples
parent9038ee45f93b1ae07a28a516781676ebe3a67536 (diff)
downloadYAGE-86e4aa6265ade205aba94494a7a31a83b5686387.tar.gz
YAGE-86e4aa6265ade205aba94494a7a31a83b5686387.zip
[Engine] [Example] Reenabled vsync and working on example.
Diffstat (limited to 'examples')
-rw-r--r--examples/resources/bullet.pngbin0 -> 1383 bytes
-rw-r--r--examples/shooter/bullet.cpp8
-rw-r--r--examples/shooter/bullet.h15
-rw-r--r--examples/shooter/main.cpp3
4 files changed, 26 insertions, 0 deletions
diff --git a/examples/resources/bullet.png b/examples/resources/bullet.png
new file mode 100644
index 00000000..89e6289b
--- /dev/null
+++ b/examples/resources/bullet.png
Binary files differ
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 <yage/yage.h>
+
+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 <yage/yage.h>
#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();