Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //main.cpp
- #include "Core.h"
- Core core;
- int main()
- {
- core.run();
- }
- //Core.h
- #ifndef CORE_H
- #define CORE_H
- #include <SFML/Graphics.hpp>
- #include <iostream>
- #include "World.h"
- #include "WindowManager.h"
- class Core
- {
- public:
- Core();
- void run();
- void getInput();
- void render();
- private:
- WindowManager windowManager;
- World firstMap;
- };
- #endif // CORE_H
- //Core.cpp
- #include "Core.h"
- Core::Core()
- {
- std::cout << "Core constructor" << std::endl;
- firstMap.createWorld();
- windowManager.createWindow();
- }
- void Core::run()
- {
- while (windowManager.window.isOpen())
- {
- //This stuff here I cutted out because game loop things are working just perfectly.
- }
- }
- //World.h
- #ifndef WORLD_H
- #define WORLD_H
- #include <SFML/Graphics.hpp>
- #include <vector>
- #include "WindowManager.h"
- class World
- {
- public:
- World();
- void createWorld();
- std::vector<sf::RectangleShape> vecGrassTile;
- std::vector<sf::RectangleShape> vecDirtTile;
- private:
- WindowManager windowManager;
- int tileFullSize;
- sf::Vector2f tileSize;
- sf::RectangleShape grassTile;
- sf::RectangleShape dirtTile;
- };
- #endif // WORLD_H
- //World.cpp
- #include "World.h"
- World::World()
- {
- std::cout << "World constructor" << std::endl;
- //here i initialize tile stuff, no problem, i cutted it out.
- }
- void World::createWorld()
- {
- //here i create world, no problem with it, i cutted it out.
- }
- //WindowManager.h
- #ifndef WINDOWMANAGER_H
- #define WINDOWMANAGER_H
- #include <iostream>
- #include <SFML/Graphics.hpp>
- #include "WindowProperties.h"
- class WindowManager
- {
- public:
- WindowManager();
- void createWindow();
- sf::RenderWindow window;
- sf::Vector2i screenDimensions;
- std::string gameTitle;
- };
- #endif // WINDOWMANAGER_H
- //WindowManager.cpp
- #include "WindowManager.h"
- WindowManager::WindowManager()
- {
- std::cout << "WindowManager constructor" << std::endl;
- screenDimensions.x = 1286; screenDimensions.y = 720;
- gameTitle = "Platformer Game - Alpha v0.1 - Programmed by Hengad";
- std::cout << "Window options(WindowProperties class) initialized successfully" << std::endl;
- }
- void WindowManager::createWindow()
- {
- window.create(sf::VideoMode(screenDimensions.x, screenDimensions.y), gameTitle, sf::Style::Close | sf::Style::Titlebar | !sf::Style::Resize);
- std::cout << "Window created successfully" << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement