summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..d780ea0
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,41 @@
+#include <SFML/Window.hpp>
+#include <SFML/Graphics.hpp>
+#include <bits/stdc++.h>
+#include "player.h"
+#include "gun.h"
+#include "point.h"
+#include "velocity.h"
+
+float width = 1280;
+float height = 720;
+std::string window_name = "Toxy";
+
+int main()
+{
+ sf::RenderWindow window(sf::VideoMode(width, height), window_name);
+ window.setVerticalSyncEnabled(true); // V-Sync enabled
+ float angle;
+ int mouseX, mouseY;
+ sf::Color color(8, 105, 201);
+ sf::Texture gunTexture;
+ gunTexture.loadFromFile("sprites/gunRight.png");
+ Player player(Point(width / 2, height / 2), Velocity(0,0), color, Gun(player.getPoint(), gunTexture, 150, 45));
+
+ while (window.isOpen())
+ {
+ sf::Event event;
+ while (window.pollEvent(event))
+ {
+ if (event.type == sf::Event::Closed)
+ window.close();
+ }
+ window.clear(sf::Color(184, 184, 184));
+ mouseX = sf::Mouse::getPosition(window).x - width / 2;
+ mouseY = sf::Mouse::getPosition(window).y - height / 2;
+ player.setAngle(atan2(mouseY,mouseX));
+ player.draw(window);
+ window.display();
+ }
+
+ return 0;
+}