Created
January 14, 2017 16:24
-
-
Save moccy/493dd1b5ca501524867c51aa69ff4d42 to your computer and use it in GitHub Desktop.
Window reference not drawing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Game.h" | |
Game::Game(const sf::RenderWindow& window) : mwindow(window) | |
{ | |
if (!mapTexture.loadFromFile("Images/Map.png")) | |
{ | |
std::cerr << "Error loading map" << std::endl; | |
std::cin.get(); | |
} | |
else { | |
map.setTexture(mapTexture); | |
} | |
} | |
Game::~Game() | |
{ | |
} | |
void Game::Update() { | |
mwindow.draw(map); | |
testMiner.Update(); | |
mwindow.draw(testMiner.sprite); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <SFML/Graphics.hpp> | |
#include "Miner.h" | |
class Game | |
{ | |
public: | |
Game(const sf::RenderWindow& window); | |
~Game(); | |
void Update(); | |
Miner testMiner; | |
private: | |
const sf::RenderWindow& mwindow; | |
sf::Texture mapTexture; | |
sf::Sprite map; | |
}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <thread> | |
#include <SFML/Graphics.hpp> | |
#include "Game.h" | |
#include "Miner.h" | |
int main(int argc, char * argv) | |
{ | |
int width = 1024; | |
int height = 1024; | |
sf::RenderWindow window(sf::VideoMode(width, height), "AI"); | |
Game game(window); | |
while(window.isOpen()) | |
{ | |
sf::Event event; | |
while (window.pollEvent(event)) | |
{ | |
if (event.type == sf::Event::Closed) | |
{ | |
window.close(); | |
} | |
} | |
window.clear(sf::Color::Black); | |
game.Update(); | |
window.display(); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment