-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
84 lines (58 loc) · 1.43 KB
/
main.cpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <SFML/Graphics.hpp>
#include "settings.h"
#include "Player.h"
#include "Texture.h"
#include "map.h"
#include "view.h"
#include "FPS.h"
#include <iostream>
#include <sstream>
#include <cmath>
using namespace sf;
using namespace std;
int main()
{
RenderWindow window(VideoMode(WIDTH, HEIGHT), "Game");
view.reset(FloatRect(0, 0, WIDTH_MAP * TILE/2, HEIGHT_MAP * TILE/2));
//window.setMouseCursorVisible(false);
//window.setFramerateLimit(60);
Player p(250, 250, 32.0, 32.0);
Clock clock;
Clock gameTimeClock;
FPS fps;
Font font;
Text fpsNum;
font.loadFromFile("CyrilicOld.TTF");
fpsNum.setFont(font);
fpsNum.setCharacterSize(45);
fpsNum.setFillColor(Color::Red);
int gameTime = 0;
while (window.isOpen())
{
float time = clock.getElapsedTime().asMicroseconds();
clock.restart();
time = time / 800;
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
window.close();
}
fps.update();
ostringstream ss;
ss << fps.getFPS();
p.fps = fps.getFPS();
fpsNum.setString(ss.str());
p.sprite.setRotation(p.GetRotationDegress(window));
fpsNum.setPosition(645, 3);
p.update(time, window);
window.setView(view);
window.clear();
//RenderMap(window);
window.draw(p.sprite);
p.Raycast(window);
window.draw(fpsNum);
window.display();
}
return 0;
}