forked from sonje51/HuskyHawksFirstGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
53 lines (46 loc) · 1.8 KB
/
main.cpp
File metadata and controls
53 lines (46 loc) · 1.8 KB
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
#include <SFML/Graphics.hpp>
#include <iostream>
#include <string>
#include <cmath>
#include "TitleScreen.h"
#include "Pad.h"
#include "GameManager.h"
#include "Block.h"
#include "InputManager.h"
#include "MainManager.h"
int main()
{
const unsigned int WIDTH = 1920;
const unsigned int HEIGHT = 1080;
sf::RenderWindow window = sf::RenderWindow(sf::VideoMode({1920u, 1080u}), "Breakout by HuskyHawks");
window.setFramerateLimit(60);
sf::Clock clock;
// Create the list of blocks to be in the game
// (in future, this should happen in some sort of level creator)
vector<Block> blocks;
blocks.push_back(Block(&window, 1250, 50, 150, 150, sf::Color(200, 0, 0), sf::Color(255, 0, 0)));
blocks.push_back(Block(&window, 1500, 50, 150, 150, sf::Color(0, 200, 0), sf::Color(0, 255, 0)));
blocks.push_back(Block(&window, 250, 50, 150, 150, sf::Color(0, 0, 200), sf::Color(0, 0, 255)));
blocks.push_back(Block(&window, 750, 50, 150, 150, sf::Color(200, 200, 0), sf::Color(255, 255, 0)));
for (int i = 0; i < 6; i++)
{
blocks.push_back(Block(&window, 250 * i - 200, 350, 150, 150, sf::Color(200, 200, 200), sf::Color(255, 255, 255)));
}
TitleScreen titleScreen(&window, WIDTH, HEIGHT);
GameManager gameManager(&window, WIDTH, HEIGHT, blocks);
MainManager mainManager(&window, &titleScreen, &gameManager);
InputManager inputManager(&mainManager, &titleScreen, &gameManager);
// Main loop
while (window.isOpen())
{
float timeSinceLastFrame = clock.restart().asSeconds();
mainManager.updateGame(timeSinceLastFrame);
while (const std::optional event = window.pollEvent())
{
inputManager.processEvent(event);
}
window.clear();
mainManager.updateWindow();
window.display();
}
}