5
« on: February 26, 2010, 04:41:25 pm »
This is my "main.cpp"
//
// Headers
//
#include "GameManager.h"
//
// Main
//
int main(void)
{
GameManager gameManager;
gameManager.Run();
return EXIT_SUCCESS;
}
This is my "GameManager.h"
#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H
//------------------------------------------------------------------------
//
// Name: GameManager.h
//
// Desc: Machine that manages the game's states.
//
// Author: Nikko Bertoa 2010 (nicobertoa@gmail.com)
//
//------------------------------------------------------------------------
//
// Headers
//
#include <SFML/Graphics.hpp>
class GameManager
{
public:
GameManager();
virtual ~GameManager();
void Run();
private:
sf::RenderWindow m_screen;
sf::Font* m_font;
sf::String* m_fpsText;
};
#endif // GAMEMANAGER_H
And this is my "GameManager.cpp"
//------------------------------------------------------------------------
//
// Name: GameManager.cpp
//
// Desc: Machine that manages the game's states.
//
// Author: Nikko Bertoa 2010 (nicobertoa@gmail.com)
//
//------------------------------------------------------------------------
//
// Headers
//
#include "GameManager.h"
#include <cassert>
// Constructor
GameManager::GameManager()
: m_screen(sf::VideoMode::GetDesktopMode(),"CaperucitaPlusPlus",
sf::Style::Fullscreen | sf::Style::Close)
{
m_font = new sf::Font();
assert(m_font->LoadFromFile("resources/fonts/arial.ttf"));
m_fpsText = new sf::String("Test Text", *m_font);
m_fpsText->SetSize(30.0f);
float xCoord = 10.0f;
float yCoord = 10.0f;
m_fpsText->SetPosition(xCoord, yCoord);
m_fpsText->SetStyle(sf::String::Regular);
m_fpsText->SetColor(sf::Color::White);
}
// Destructor
GameManager::~GameManager()
{
if(m_font != 0)
{
delete m_font;
m_font = 0;
}
if(m_fpsText != 0)
{
delete m_fpsText;
m_fpsText = 0;
}
}
void GameManager::Run()
{
// Start game loop
while (m_screen.IsOpened())
{
// Process events
sf::Event Event;
while (m_screen.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
m_screen.Close();
}
// Clear the screen (fill it with black color)
m_screen.Clear();
m_screen.Draw(*m_fpsText);
// Display window contents on screen
m_screen.Display();
}
}
When I run the application in DEBUG MODE, I see the text. When I run the application in RELEASE MODE, I don't see the text. I'm using Visual Studio 2008.