Skip to content

Instantly share code, notes, and snippets.

@moccy
Created January 14, 2017 16:24
Show Gist options
  • Save moccy/493dd1b5ca501524867c51aa69ff4d42 to your computer and use it in GitHub Desktop.
Save moccy/493dd1b5ca501524867c51aa69ff4d42 to your computer and use it in GitHub Desktop.
Window reference not drawing
#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);
}
#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;
};
#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