Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - AdventWolf

Pages: [1]
1
Graphics / New coordinates based on view
« on: September 02, 2013, 04:18:39 am »
So the problem is that I am trying to click on the window to place an object on the screen. It works perfectly until I add views.

When I move the view to the right 100 pixels and click on the position of (300, 300), then the object is moved to the new view coordinates of (200, 300). I need the object to be drawn to the new view coordinates of (300, 300). I have experimented with the mapCoordsToPixel function but I can't get it working.

Here is the sample code:
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow window(sf::VideoMode(600, 400), "View");
window.setFramerateLimit(60);

sf::CircleShape circle;
circle.setFillColor(sf::Color::Black);
circle.setRadius(15);

sf::View view = window.getView();

while(window.isOpen())
{
sf::Event event;

while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
}

if( event.type == sf::Event::MouseButtonReleased && event.mouseButton.button == sf::Mouse::Left )
{
circle.setPosition(sf::Mouse::getPosition(window).x, sf::Mouse::getPosition(window).y);
}

if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left) || sf::Keyboard::isKeyPressed(sf::Keyboard::A))
view.move(-5.f, 0.f);

if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right) || sf::Keyboard::isKeyPressed(sf::Keyboard::D))
view.move(5.f, 0.f);

if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up) || sf::Keyboard::isKeyPressed(sf::Keyboard::W))
view.move(0.f, -5.f);

if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down) || sf::Keyboard::isKeyPressed(sf::Keyboard::S))
view.move(0.f, 5.f);

window.clear(sf::Color::White);
window.setView(view);
window.draw(circle);
window.display();
}

return 0;
}


2
Graphics / Problem using static image and sprite variables
« on: January 11, 2012, 06:26:43 am »
Okay it's been a while since I've been programming but I'm back and I'm suffering from the same error. The thing is, when I use a static image or sprite variable, the program crashes and the "Lock.cpp" file is shown in Visual studio and the debugger points to
Code: [Select]

Lock::Lock(Mutex& mutex) :
myMutex(mutex)
{
    myMutex.Lock();
}


The program does not crash under release mode, ONLY debug. I am linking statically. Here is the code:

Code: [Select]

//example.hpp
#ifndef EXAMPLE_HPP_
#define EXAMPLE_HPP_

#include <SFML\Graphics.hpp>

class Example
{
static sf::Image image;
static sf::Sprite sprite;
};

#endif


Code: [Select]

//example.cpp
#include "example.hpp"

sf::Image Example::image;
sf::Sprite Example::sprite;


Code: [Select]

//main.cpp
#include <iostream>

int main()
{
}



Any advice is appreciated.

3
Graphics / static class with sf::Image/sf::Sprite member causes crash
« on: October 19, 2011, 08:30:16 am »
In my coding I have had problems with using static classes with sf::Image and sf::Sprite members.
When I comment out the variable, the program runs perfectly, but when the variable is a member of the static class, i get the mutex error:

Code: [Select]

myMutex(mutex)
{
    myMutex.Lock();
}


Oh and it runs fine in Release mode, just not Debug mode. Which leads me to believe it may be related to that damn ATI bug :evil:

What could cause this? I should probably post the code, i tried to replicate it in a small sample code but I haven't so far.

Edit: blah it is late, the ati bug doesn't have anything to do with debug/release i dont think.

4
Graphics / About images/sprites and alpha and getting an image color
« on: October 15, 2011, 03:33:16 am »
It is kind of hard to get an accurate title for this question.

Okay what I am trying to do is display a picture and lets say it is an empty square. It is simply just the outline of a square and the inside is transparent.

The sprite needs to be used to test collision, so the character can move freely inside where the picture is transparent, but the character can not move passed the colored walls.

Is it possible to get a position inside an image and tell if that spot is transparent or a specific color?

5
General / (Solved) Need help with errors after updating SFML
« on: May 25, 2011, 10:10:44 pm »
I updated to SFML 2 in January. I hadn't updated SFML again until today.
When I try to code anything with SFML I get errors.

I've tried compiling in debug/release with static and non-static libs and using SFML_STATIC in the preprocessor commands.

I'm currently trying to compile in Debug with non-static libs.
I'm linking to sfml-main, system, graphics, and window.

Code: [Select]
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow WINDOW(sf::VideoMode(400,400),"Title");
return 0;
}


Code: [Select]
1>example.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::ContextSettings const &)" (__imp_??0RenderWindow@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUContextSettings@1@@Z) referenced in function _main
1>C:\User\Documents\Visual Studio 2008\Projects\example\Debug\example.exe : fatal error LNK1120: 1 unresolved externals

6
General / Program crashes when getting buffer for audio file
« on: January 11, 2011, 03:02:15 am »
I've been trying to work this out for a while but I keep getting errors or the program crashes. I have no idea why it is crashing, I'm using pretty much the same method as the sample from the tutorial here. http://sfml-dev.org/wiki/en/tutorials/formatdat

Code: [Select]
class AudioDAT
{
private :
    sAudioDATHeader m_header; /// file header
    std::vector<sAudioEntry> m_entries; /// vector of files entries
    char* m_buffer; /// Buffer pointing on a file in memory
public :
...
    long int GetAudioSize (std::string filename);
};


Code: [Select]
//In AudioDAT.cpp
char* AudioDAT::GetAudio (std::string filename)
{
    //The input file stream from which we want information
    std::ifstream datfile;
 
    //Cleaning properly an ancient file loaded
    if (m_buffer != NULL) //Program crashes here
    {
        delete (m_buffer);
        m_buffer = NULL;
    }

    //First, we have to find the file needed
    for (unsigned int i=0; i<m_header.nb_files;i++)
    {
        //If we found it
        if (m_entries[i].name == filename)
        {
            //We are allocating memory to the buffer
            m_buffer = new char[(m_entries[i].size)];
            //Simple error catch
            if (m_buffer==NULL)
                return (NULL);
            //Opening the DAT file ot read the file datas needed
            datfile.open (m_datfile.c_str(), std::ifstream::in | std::ifstream::binary);
            if (datfile.is_open())
            {
                //Going to the right position
                datfile.seekg (m_entries[i].offset, std::ios::beg);
                //Reading
                datfile.read (m_buffer, m_entries[i].size);
                //We can close the DAT file
                datfile.close();
                //Returning the buffer
                return (m_buffer);
            }
        }
    }
    //Finally, there is no such file in our DAT file
    return (NULL);
}
...
long int AudioDAT::GetAudioSize (std::string filename)
{
    //First, we have to find the file needed
    for (unsigned int i=0; i<m_header.nb_files;i++) //Also crashes here
    {
        //If we found it
        if (m_entries[i].name == filename)
        {
            //Returning the size of the file found
            return (m_entries[i].size);
        }
    }
    return (0);
}


Code: [Select]
class AudioManager
{
std::vector<std::string> audio_container;

public:
AudioManager();
        AudioDAT data;
char * GetBuffer(std::string name);
long int GetSize(std::string name);
}


Code: [Select]
//In AudioManager.cpp
char* AudioManager::GetBuffer(std::string name)
{
char* buffer = data.GetAudio(name); //Crashes here
if (buffer == NULL)
    {
        std::cout<<"Read error"<<std::endl;
    }
return buffer;
}

long AudioManager::GetSize(std::string name)
{
return data.GetAudioSize(name);
}


Code: [Select]
//In application of code
//AUDIO is AudioManager
char* buffer = AUDIO.GetBuffer("Data/Audio/x1.ogg");//crashes here
long int size = AUDIO.data.GetAudioSize("Data/Audio/x1.ogg");//crashes here
        MenuSong.OpenFromMemory(buffer,size);

7
General / SFML fps runs very low
« on: January 10, 2011, 09:20:38 pm »
My computer blue screened last week so I've been trying to get everything back to normal. When it first happened, I bought a new hard drive and installed SFML and Visual Studio and the game ran just fine. But I was able to get my old hard drive back in working condition and I installed SFML and Visual Studio back on it but the fps averages around 8.

Is there something in SFML or Visual Studio that might cause this?

8
General / Need help with an audio manager using a DAT file
« on: January 05, 2011, 02:43:07 am »
I'm using the tutorial on storing your files inside a .DAT file.
The problem is inside this function, the program just freezes.
char* AudioDAT::GetAudio (std::string filename)

If I comment out this part: if (m_buffer != NULL){}
then the debugger points to the next part of the function to be the problem.

Any tips are appreciated!

Code: [Select]

#ifndef ENGINE_HPP_
#define ENGINE_HPP_

class AudioManager;

#define SYSTEM Engine::SYSTEM
#define AUDIO  SYSTEM.GetAudio()

#include <SFML/Audio.hpp>

class Engine
{
AudioManager  * audio;

public:
Engine();
static Engine SYSTEM;
AudioManager  & GetAudio();
void SetSound(AudioManager  * audio);
};
#endif


Code: [Select]
#include "Headers/Engine.hpp"

Engine::Engine()
{}

AudioManager & Engine::GetAudio()
{
return *audio;
}

void Engine::SetSound(AudioManager * sound)
{
this->audio = audio;
}


Code: [Select]
#ifndef AUDIO_DAT_H
#define AUDIO_DAT_H

#include <iostream>
#include <vector>
#include <fstream>
#include <string>

struct sAudioDATHeader
{
    char uniqueID[5]; /// Unique ID used to know if this file is a DAT File from this class
    char version[3]; /// Version of the DAT file format
    unsigned int nb_files; /// Number of files in the DAT file
};

struct sAudioEntry
{
    char name[300]; /// Name of the data file
    long size; /// Size of the data file
    long offset; /// Offset, in the DAT file where the file is
};

class AudioDAT
{
private :
    std::string m_datfile; /// name of the DAT file
    sAudioDATHeader m_header; /// file header
    std::vector<sAudioEntry> m_entries; /// vector of files entries
    char* m_buffer; /// Buffer pointing on a file in memory
public :
    AudioDAT (void);
    ~AudioDAT (void);
    bool Create (std::vector<std::string> files, std::string destination);
    void Read (std::string source);
    char* GetAudio (std::string filename);
    long int GetAudioSize (std::string filename);
};

#endif


Code: [Select]
#include "Headers/AudioDAT.hpp"

AudioDAT::AudioDAT (void)
{
    m_buffer = NULL;
}
 
AudioDAT::~AudioDAT (void)
{
    if (m_buffer!=NULL)
        delete (m_buffer);
}

bool AudioDAT::Create (std::vector<std::string> files, std::string destination)
{
    //A file entry in order to push it in the object's std::vector
    sAudioEntry entry;
    //An input file stream to read each file included
    std::ifstream file;
    //An output file stream to write our DAT file
    std::ofstream datfile;
    //The buffer used to read/write the DAT file
    char buffer[1];
 
    //DATHeader
    //We start by filling it with 0
    memset (&m_header, 0, sizeof(m_header));
    //Then we copy the ID
    memcpy (m_header.uniqueID, "IMGDAT", 5);
    //Then the version
    memcpy (m_header.version, "0.1", 3);
    //Then the number of files to include
    m_header.nb_files = files.size();
 
    //Next, we open each file in orderto create the File Entries Table
    for (unsigned int i = 0; i<files.size(); i++)
    {
        file.open (files[i].c_str(), std::ifstream::in | std::ifstream::binary);
        if (file.is_open())
        {
            //Filling the FileEntry with 0
            memset (&entry, 0, sizeof(sAudioEntry) );
            //We keep the file name
            memcpy (entry.name, files[i].c_str(), strlen ( files[i].c_str() ) );
            //We calculate its size
            file.seekg (0, std::ios::end);
            entry.size = file.tellg();
            //Since we don't know exactly its final position in the DAT file, let's use 0
            entry.offset = 0;
            //We finished with this file
            file.close();
 
            //Finally, we add this File Entry in our std::vector
            m_entries.push_back(entry);
        }
        else
        {
            //Simple error track
            std::cout<<"File "<<files[i]<<" raise an error."<<std::endl;
            return (false);
        }
    }
 
    //Now, we know everything about our files, we can update offsets
    long actual_offset = 0;
    actual_offset += sizeof(sAudioDATHeader);
    actual_offset += m_header.nb_files * sizeof(sAudioEntry);
    for (unsigned int i=0;i<m_entries.size();i++)
    {
        m_entries[i].offset = actual_offset;
        actual_offset += m_entries[i].size;
    }
 
    //And finally, we are writing the DAT file
    datfile.open (destination.c_str(), std::ofstream::out | std::ofstream::binary);
 
    //First, we write the header
    datfile.write ((char*)&m_header, sizeof(sAudioDATHeader) );
 
    //Then, the File Entries Table
    for (unsigned int i=0;i<m_entries.size();i++)
    {
        datfile.write ((char*)&m_entries[i], sizeof(sAudioEntry) );
    }
 
    //Finally, we write each file
    for (unsigned int i = 0; i<m_entries.size(); i++)
    {
        file.open (m_entries[i].name, std::ifstream::in | std::ifstream::binary);
        if (file.is_open())
        {
            file.seekg (0, std::ios::beg);
            while (file.read (buffer, 1))
            {
                datfile.write (buffer, 1);
            }
            file.close();
        }
        file.clear();
    }
    //And it's finished
    datfile.close();
    return (true);
}

void AudioDAT::Read (std::string source)
{
    //The input file stream from which we want informations
    std::ifstream datfile;
    //A file entry in order to push it in the object's std::vector
    sAudioEntry entry;
 
    //Filling the header with 0
    memset (&m_header, 0, sizeof(m_header));
    //We open the DAT file to read it
    datfile.open (source.c_str(), std::ifstream::in | std::ifstream::binary);
    if (datfile.is_open())
    {
        //Getting to the Header position
        datfile.seekg (0, std::ios::beg);
        //Reading the DAT Header
        datfile.read ((char*)&m_header, sizeof(sAudioDATHeader));
        //Next we are reading each file entry
        for (unsigned int i=0;i<m_header.nb_files;i++)
        {
            //Reading a File Entry
            datfile.read ((char*)&entry, sizeof(sAudioEntry));
            //Pushing it in our std::vector
            m_entries.push_back(entry);
        }
        //Since all seems ok, we keep the DAT file name
        m_datfile = source;
    }
    //Closing the DAT file
    datfile.close();
}

char* AudioDAT::GetAudio (std::string filename) //The PROBLEM STARTS HERE
{
    //The input file stream from which we want information
    std::ifstream datfile;
 
    //Cleaning properly an ancient file loaded
    if (m_buffer != NULL) //The Program freezes here
    {
        delete (m_buffer);
        m_buffer = NULL;
    }
 
    //First, we have to find the file needed
    for (unsigned int i=0; i<m_header.nb_files;i++)
    {
        //If we found it
        if (m_entries[i].name == filename)
        {
            //We are allocating memory to the buffer
            m_buffer = new char[(m_entries[i].size)];
            //Simple error catch
            if (m_buffer==NULL)
                return (NULL);
            //Opening the DAT file ot read the file datas needed
            datfile.open (m_datfile.c_str(), std::ifstream::in | std::ifstream::binary);
            if (datfile.is_open())
            {
                //Going to the right position
                datfile.seekg (m_entries[i].offset, std::ios::beg);
                //Reading
                datfile.read (m_buffer, m_entries[i].size);
                //We can close the DAT file
                datfile.close();
                //Returning the buffer
                return (m_buffer);
            }
        }
    }
    //Finally, there is no such file in our DAT file
    return (NULL);
}

long int AudioDAT::GetAudioSize (std::string filename)
{
    //First, we have to find the file needed
    for (unsigned int i=0; i<m_header.nb_files;i++)
    {
        //If we found it
        if (m_entries[i].name == filename)
        {
            //Returning the size of the file found
            return (m_entries[i].size);
        }
    }
    return (0);
}


Code: [Select]
#ifndef AUDIO_MANAGER_H
#define AUDIO_MANAGER_H

#include <map>
#include <vector>
#include <string>
#include "Headers/Engine.hpp"
#include "Headers/AudioDAT.hpp"

class AudioManager
{
std::vector<std::string> audio_container;
std::map<std::string, sf::Music> static_audio_map;
AudioDAT data;

public:
AudioManager();
const sf::Music & GetAudio(sf::Music & temp, std::string audio_id);
};

#endif


Code: [Select]
#include "Headers/AudioManager.hpp"
#include <iostream>

AudioManager::AudioManager()
{
//Create DAT file and Load Audio
audio_container.push_back("Test.ogg");

if(!data.Create(audio_container,"AUD.dat"))
{
std::cout << "Could not create AUD.dat" << std::endl;
}

data.Read("AUD.dat");
}

const sf::Music & AudioManager::GetAudio(sf::Music & temp, std::string audio_id)
{
char * temp_data = data.GetAudio(audio_id);// The Program freezes inside this function
if(temp_data == NULL)
{
std::cout << "Error Loading Audio: " << audio_id << std::endl;
exit(EXIT_FAILURE);
}

temp.OpenFromMemory(temp_data, data.GetAudioSize(audio_id));
return temp;
}


Code: [Select]
#include "Headers/Engine.hpp"
#include "Headers/AudioManager.hpp"

Engine SYSTEM;

int main()
{
sf::Music test;
AudioManager audio;

AUDIO.GetAudio(test,"test.ogg");
        test.Play();

while(true)
{
}
return 0;
}

9
System / sf::Clock countdown timer (solved)
« on: December 23, 2010, 11:34:39 pm »
I created a timer just fine it my main menu state but I'm trying to create a countdown timer in different state but it isn't working. Though for some reason the Clock creates a huge number for ElapsedTime, so the countdown of 3 seconds only lasts a millisecond.

Here is what I have:
Code: [Select]

SwitchSong = 3.f;
DELAY_SONG = true;
...
ElapsedTime = Clock.GetElapsedTime();
Clock.Reset();

if( DELAY_SONG )
{
std::cout << "BEFORE: " << SwitchSong << std::endl;
SwitchSong -= ElapsedTime;
std::cout << "AFTER: " << SwitchSong << std::endl;
if( SwitchSong <= 0 )
{
BackGround.Stop();
BackGround2.Play();
BackGround2.SetLoop(true);
DELAY_SONG = false;
}
}


Thanks.

10
General / Questions about managing states
« on: November 07, 2010, 07:03:06 pm »
Alright it has been a while since I have programmed but I have found some free time. State managing has really held me back because I can't seem to grasp how to do it! I started trying to put together a very simple state manager by looking at different resources but I'm having problems.

Here's the basic jest of it:

Code: [Select]
#ifndef ENGINE_HPP_
#define ENGINE_HPP_

#include <iostream>
#include <vector>

#include <SFML/Graphics.hpp>

class CGameState;

class Engine
{
public:

void Init(const string& title, int width=1024, int height=768,
     int bpp=32, bool fullscreen=false);
void Cleanup();

void ChangeState(CGameState* state);
void PushState(CGameState* state);
void PopState();

void HandleEvents();
void Update();
void Draw();

bool Running() { return m_running; }
void Quit() { m_running = false; }

sf::RenderWindow screen;

private:

std::vector<CGameState*> states;
bool m_running;
bool m_fullscreen;
};
#endif


Code: [Select]
#include "Engine.hpp"
#include "gamestate.hpp"

void Engine::Init(const string& title, int width, int height,
int bpp, bool fullscreen)
{
mode = sf::VideoMode(width, height, bpp);
Window.Create(mode, title);

m_fullscreen = fullscreen;
m_running = true;

printf("CGameEngine Init\n");
}

void Engine::Cleanup()
{
// cleanup the all states
while ( !states.empty() )
{
states.back()->Cleanup();
states.pop_back();
}
printf("GameEngine Cleanup\n");
}

void Engine::ChangeState(CGameState* state)
{
// cleanup the current state
if ( !states.empty() ) {
states.back()->Cleanup();
states.pop_back();
}

// store and init the new state
states.push_back(state);
states.back()->Init();
}

void Engine::PushState(CGameState* state)
{
// pause current state
if ( !states.empty() ) {
states.back()->Pause();
}

// store and init the new state
states.push_back(state);
states.back()->Init();
}

void Engine::PopState()
{
// cleanup the current state
if ( !states.empty() ) {
states.back()->Cleanup();
states.pop_back();
}

// resume previous state
if ( !states.empty() ) {
states.back()->Resume();
}
}

void Engine::HandleEvents()
{
// let the state handle events
states.back()->HandleEvents(this);
}

void Engine::Update()
{
// let the state update the game
states.back()->Update(this);
}

void Engine::Draw()
{
// let the state draw the screen
states.back()->Draw(this);
}


Code: [Select]
#ifndef GAMESTATE_H
#define GAMESTATE_H

#include "Engine.hpp"

class CGameState
{
public:
virtual void Init() = 0;
virtual void Cleanup() = 0;

virtual void Pause() = 0;
virtual void Resume() = 0;

virtual void HandleEvents(Engine* game) = 0;
virtual void Update(Engine* game) = 0;
virtual void Draw(Engine* game) = 0;

void ChangeState(Engine* game, CGameState* state) {
game->ChangeState(state);
}

protected:
CGameState() { }
};

#endif


Code: [Select]
#ifndef INTROSTATE_HPP_
#define INTROSTATE_HPP_

#include <SFML/Graphics.hpp>
#include "gamestate.hpp"

class CIntroState : public CGameState
{
public:
    void Init();
    void Cleanup();

    void Pause();
    void Resume();

void HandleEvents(Engine* game);
void Update(Engine* game);
void Draw(Engine* game);

static CIntroState* Instance() {
return &m_IntroState;
}

protected:
CIntroState() { }

private:
static CIntroState m_IntroState;
sf::Sprite OpenMenu;

};

#endif


Code: [Select]
#include <iostream>
#include <SFML/Graphics.hpp>

#include "Engine.hpp"
#include "IntroState.hpp"

CIntroState CIntroState::m_IntroState;

void CIntroState::Init()
{
std::cout << "start" << std::endl;
sf::Image Open;
if( !Open.LoadFromFile("OpenGameMenu.png") )
std::cout << "ERROR" << std::endl;

OpenMenu.SetImage(Open);
}

void CIntroState::HandleEvents(Engine* game)
{
sf::Event event;
    while( game->screen.GetEvent(event) )
    {
        if( event.Type == sf::Event::Closed )
{
            game->Quit();
}
}
}

void CIntroState::Draw(Engine* game)
{
game->screen.Draw(OpenMenu);
}

void CIntroState::Update(Engine* game)
{
game->screen.Clear();
game->screen.Display();
}


Code: [Select]
#include <iostream>
#include "Engine.hpp"
#include "IntroState.hpp"

int main()
{
Engine game;

// initialize the engine
game.Init( "Engine" );

// load the intro
game.ChangeState( CIntroState::Instance() );

// main loop
while ( game.Running() )
{
game.HandleEvents();
game.Update();
game.Draw();
}

// cleanup the engine
game.Cleanup();
std::cout << "END OF MAIN" << std::endl;
std::cin.get();
return 0;
}


But my problem is I'm not sure how to manage the Window, when I try to draw a sprite to the window, I get nothing. In here, I create a window in the engine class, but how do I reach the window while I'm in the states to change the window? What would be a simple implementation of the IntroState to create an window output, while being able to switch to another state that uses the same window?

11
Window / Possibility of displaying Zoom/Rotate in increments
« on: September 08, 2010, 05:16:14 am »
I want to implement a function that gradually performs some functions and displays it in increments, instead of when I choose to zoom in, it instantaneously zooms to that setting.

I have tried using a for loop, that zooms and rotates on a certain degree each turn, but it is still instantaneous, and doesn't display in increments.

Is there a way I can implement this? To delay the loop each turn?

Thanks.

12
General / Need help used separate void functions
« on: September 07, 2010, 12:43:36 am »
I'm having problems with separating my programs into separate functions.

Such as having a function that display's text from a string stored earlier in the program:

Code: [Select]
#include <SFML/Graphics.hpp>
#include <iostream>

void DisplayText();

int main()
{
    // Create main window
    sf::RenderWindow App(sf::VideoMode(326, 600), "Title");

    // Create a graphical string
    sf::String Hello;
    Hello.SetText("Hello!");
    Hello.SetColor(sf::Color(0, 128, 128));
    Hello.SetPosition(100.f, 100.f);
    Hello.SetSize(30.f);

    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }
DisplayText();
        App.Display();
    }
std::cout << "DONE" << std::endl;
std::cin.get();
return 0;
}

void DisplayText()
{
App.Draw(Hello);
}


What would I need to include so that the function includes the variables that I need to read?

Thanks.

13
Graphics / Registering Single Mouse Click
« on: September 04, 2010, 09:33:46 pm »
Hello, I've lurked here for a while to help solve some problems here and there and I have searched for the answer to the problem I have now, but I haven't found much solid info.

I am trying to use the mouse to select buttons in a program, but holding the mouse down for longer than half a second will output the button multiple times.

How can I fix it so that the button won't be initiated until I release the mouse click on the button?

Thanks.

Pages: [1]
anything