1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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;
}
|