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.


Messages - pinkahd

Pages: [1]
1
System / Re: Thread running in a class stops when pressing a key
« on: October 24, 2013, 11:06:29 pm »
Thanks for all the help i fixed it the problem was the getch() function in the main. Now everything work perfect exept for the debug part. Thanks for all the help. And i apologize that you lose time with me for a simple problem it was my fault sorry. Have a nice day.

2
System / Re: Thread running in a class stops when pressing a key
« on: October 24, 2013, 10:44:49 pm »
Believe me i have put all the lib files. And this problem is affecting also my friend how is using visual studio 2010 and he configure it himself and we still didn't manage how to configure it properly or anything we both started from an empty project and then we fallow the instructions and the only thing that works is release.
look at the screenshot.
Debug

Release

Sorry if i'm not allowed to post images links from my site.

I fallow the tutorial from the sfml, and another one from youtube and still the same thing ...
I'm running windows 7 ultimate using visual studio 2012 i tried with 2010 still the same thing ...

Edit: If someone have the time to view my project i will upload it and post it... i really don't know what i did wrong.

3
System / Re: Thread running in a class stops when pressing a key
« on: October 24, 2013, 10:19:16 pm »
Well about the debug thing i tried all the thing i can think but i don't know how to make it work ... i try to put SFML_STATIC with and without release works but debug don't i put all the dependencies -d files but i don't know who to make it work.

Here is the debug output:
1>------ Build started: Project: Nagix V1.1, Configuration: Debug Win32 ------
1>Build started 10/24/2013 11:12:58 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\Nagix V1.1.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>  SoundEngine.cpp
1>  RenderEngine.cpp
1>  Player.cpp
1>  main.cpp
1>d:\programs\programare\game\nagix v1.1\nagix v1.1\main.cpp(49): warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details.
1>          d:\programs\visual studio 2012\vc\include\conio.h(131) : see declaration of 'getch'
1>  Generating Code...
1>sfml-audio-s.lib(SoundStream.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-audio-s.lib(SoundStream.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
1>sfml-audio-s.lib(Music.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-audio-s.lib(Music.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
1>sfml-audio-s.lib(SoundSource.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-audio-s.lib(SoundSource.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
1>sfml-audio-s.lib(AudioDevice.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-audio-s.lib(AudioDevice.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
1>sfml-audio-s.lib(SoundFile.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-audio-s.lib(SoundFile.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
1>sfml-audio-s.lib(ALCheck.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>sfml-audio-s.lib(ALCheck.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>RenderEngine.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>sfml-audio-s.lib(SoundStream.cpp.obj) : error LNK2019: unresolved external symbol "public: static class sf::Time const sf::Time::Zero" (?Zero@Time@sf@@2V12@B) referenced in function "private: bool __thiscall sf::SoundStream::fillAndPushBuffer(unsigned int)" (?fillAndPushBuffer@SoundStream@sf@@AAE_NI@Z)
1>D:\Programs\Programare\Game\Nagix V1.1\Debug\Nagix V1.1.exe : fatal error LNK1120: 2 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:06.31
 

And i tried to simplified my code but it still don't work i tried to run it off the main.


void x()
{
        while (1==1)
        {
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
                {
                        std::cout << "Player moved Up" << std::endl;
                }
        }
}

int main()
{
        sf::Thread a(&x);
        a.launch();
        std::cout << "ok" << std::endl;
getch();
return 0;
}

 

It's still crashes when i press a key ... maybe this is not the right way to do it ... i don't know.

4
System / Re: Thread running in a class stops when pressing a key
« on: October 24, 2013, 09:30:24 pm »
I get rid of the void in the constructor and destructor and i try to run it in debug mode but i can't figure out how to get it to work properly i get link errors but i did all the things to configure it even check it twice. I fallow http://sfml-dev.org/tutorials/2.1/start-vc.php tutorial for how to set it up but i can only run in realise and not debug.
The only error message that gives me is this:
Unhandled exception at 0x70441BBE (libsndfile-1.dll) in Nagix V1.1.exe: 0xC0000005: Access violation reading location 0xFEEFE50E.
And i can't figure it out what it means.

EDIT:
I get rid of all the if conditions in the while loop and it is only the while and cout functions and it still crashes don't know why.

5
System / Re: Thread running in a class stops when pressing a key
« on: October 24, 2013, 08:58:02 pm »
It prints out running all the time this is why i put cout the to see if it really works but stops when i press a key. Thanks for a quick replay. Can you tell me what i did wrong?

6
System / Thread running in a class stops when pressing a key
« on: October 24, 2013, 08:33:42 pm »
Hi there, i'm new to SFML and a novice to c++ so i came into a problem today when i try to build my own player class. The bug occurs when i press a key in a running thread, everything runs ok until i press a key any key, The function in the class have a while loop when it checks is a key is pressed and if it is then is displays a message in the console.

Here is the code with the problem if anyone knows what i did wrong can you explain it to me.

The player.h

#include "GlobalVariabiles.h"

class Player
{

public:

        Player(void);
        virtual ~Player(void);

        void setPlayerName(const std::string& name);
        void player_move();
       
        std::string getPlayerName();
        sf::Sprite renderPlayer();

private:       

        void setPlayerTexture(const std::string& path);

        sf::Texture player_texture;
        sf::Sprite player_sprite;
        sf::Thread move_thread;
       
};

 

And the player.cpp


#include "Player.h"

bool playerexist;
std::string Player_Name;

Player::Player(void)
        :move_thread(&Player::player_move, this)
{
        playerexist = true;
        std::cout << "A new Player have bean created !" << std::endl;
        this->move_thread.launch();
}

Player::~Player(void)
{
        playerexist = false;
        this->move_thread.terminate();
        //this->move_thread.~Thread();
}

void Player::player_move()
{

        while (playerexist){
                std::cout << "Runing";
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
                        {
                                std::cout << "Player moved Up" << std::endl;
                        }
                else if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
                        {
                                std::cout << "Player moved Right" << std::endl;
                        }
                else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
                        {
                                std::cout << "Player moved Down" << std::endl;
                        }
                else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
                        {
                                std::cout << "Player moved Left" << std::endl;                 
                        }      
        }

}

 

Thanks in advance.

Pages: [1]
anything