Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "SFML/Graphics.hpp"
- #include "SFML/Audio.hpp"
- #include "SFML/Window.hpp"
- #include "SFML/System.hpp"
- #include <iostream>
- #define _USE_MATH_DEFINES
- #include <math.h>
- #include "Character.h"
- #include "UI.h"
- using namespace std;
- using namespace sf;
- void main()
- {
- //references
- Event event;
- UI ui;
- Character character;
- vector<Shuriken> shuriken;
- sf::RenderWindow window(VideoMode(ui.qualityX, ui.qualityY), "Game");
- sf::Texture cursorTexture;
- cursorTexture.loadFromFile("cursor.png");
- sf::Sprite cursor(cursorTexture);
- cursor.setScale(0.15, 0.15); cursor.setOrigin(cursorTexture.getSize().x / 2, cursorTexture.getSize().y / 2);
- window.setMouseCursorVisible(false);
- while (window.isOpen())
- {
- while (window.pollEvent(event))
- {
- if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
- window.close();
- }
- double dx = window.mapPixelToCoords(sf::Mouse::getPosition(window)).x - character.spriteCharacter.getPosition().x;
- double dy = window.mapPixelToCoords(sf::Mouse::getPosition(window)).y - character.spriteCharacter.getPosition().y;
- double angle = atan2(dx, dy) * 180 / M_PI;
- character.move(); character.cameraLookPose(window); character.look(angle); character.attack();
- cursor.setPosition(window.mapPixelToCoords(sf::Mouse::getPosition(window)));
- shuriken.resize(character.shurikenIndex+1);
- for (Shuriken& shuriken_VALUE : shuriken)
- {
- shuriken_VALUE.forward();
- window.draw(shuriken_VALUE.shurikenSprite);
- }
- window.draw(character.spriteCharacter);
- window.draw(cursor);
- window.setView(character.view);
- window.display();
- window.clear();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement