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 - mantracker

Pages: [1]
1
General / Re: Reinstalling SFML2.0 won't work using VS2011
« on: July 24, 2013, 09:21:41 pm »
Well it's important to not only look at the images, but also to read what the images mean.

Quote from: Tutorial
If you want to get rid of these DLLs and have SFML directly integrated to your executable, you must link to the static version. Static SFML libraries have the "-s" suffix: "sfml-xxx-s-d.lib" for Debug, and "sfml-xxx-s.lib" for Release.
In this case, you'll also need to define the SFML_STATIC macro in the preprocessor options of your project.

If you want to link statically, you'll need to specify the libs with the -s suffix and define SFML_STATIC. If you want to link shared, you'll neeed to specify the libs with no -s suffix, but you're not allowed to define SFML_STATIC.


Alright so, this is now an updated version of what I have done:

1. When creating a project, I chose "Win32 project"
2. In project properties, I chose "All configurations"->"C/C++"->"General"->"Additional include directories" and added SFML-2.0\include
3. In "Linker"->"General" of "All configurations", I added SFML-2.0\lib
4. In "Release"->"Linker"->"Input", I added "sfml-graphics-s.lib;sfml-window-s.lib;sfml-system-s.lib;", in that order and EXACTLY as what was written on the official tutorial
5. In "Debug"-> "C/C++" -> "Preprocessor", I added SFML_STATIC; as shown on tutorial

I still got the exact same error, is there something else Im missing?

EDIT: So now I've also added the -s-d files in, this is what I've done:

1. When creating a project, I chose "Win32 project"
2. In project properties, I chose "All configurations"->"C/C++"->"General"->"Additional include directories" and added SFML-2.0\include
3. In "Linker"->"General" of "All configurations", I added SFML-2.0\lib
4. In "Release"->"Linker"->"Input", I added "sfml-graphics-s.lib;sfml-window-s.lib;sfml-system-s.lib;", in that order and EXACTLY as what was written on the official tutorial
4. In "Debug"->"Linker"->"Input", I added "sfml-graphics-s-d.lib;sfml-window-s-d.lib;sfml-system-s-d.lib;", in that order and EXACTLY as what was written on the official tutorial
5. In "Debug"-> "C/C++" -> "Preprocessor", I added SFML_STATIC; as shown on tutorial

This is the new error I got:



1>------ Build started: Project: adfasdfasdf, Configuration: Debug Win32 ------
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\Martin Liu\documents\visual studio 2012\Projects\adfasdfasdf\Debug\adfasdfasdf.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


EDIT 2: nevermind, thanks for your help. I resolved that error and now everything works just fine

2
General / Reinstalling SFML2.0 won't work using VS2011
« on: July 24, 2013, 10:55:19 am »
I am sure there are millions of threads on this already, and I must have read like 90% of them and tried all sorts of different solutions, but none of them works for me.

So basicly, I followed the official tutorial here: http://www.sfml-dev.org/tutorials/2.0/start-vc.php EXACTLY! To illustrate, I will again, repeat what I have done:

1. When creating a project, I chose "Win32 project"
2. In project properties, I chose "All configurations"->"C/C++"->"General"->"Additional include directories" and added SFML-2.0\include
3. In "Linker"->"General" of "All configurations", I added SFML-2.0\lib
4. In "Release"->"Linker"->"Input", I added "sfml-graphics.lib;sfml-window.lib;sfml-system.lib;", in that order and EXACTLY as what was written on the official tutorial
5. In "Debug"-> "C/C++" -> "Preprocessor", I added SFML_STATIC; as shown on tutorial
6. Then, I clicked apply and ok and wrote the code from the tutorial, this is the error I got:





1>------ Build started: Project: MyGames, Configuration: Debug Win32 ------
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::String::String(char const *,class std::locale const &)" (??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::close(void)" (?close@Window@sf@@QAEXXZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::isOpen(void)const " (?isOpen@Window@sf@@QBE_NXZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::display(void)" (?display@Window@sf@@QAEXXZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (??0Color@sf@@QAE@EEEE@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::RenderTarget::clear(class sf::Color const &)" (?clear@RenderTarget@sf@@QAEXABVColor@2@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::RenderTarget::draw(class sf::Drawable const &,class sf::RenderStates const &)" (?draw@RenderTarget@sf@@QAEXABVDrawable@2@ABVRenderStates@2@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (??0RenderWindow@sf@@QAE@VVideoMode@1@ABVString@1@IABUContextSettings@1@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (??1RenderWindow@sf@@UAE@XZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::Shape::~Shape(void)" (??1Shape@sf@@UAE@XZ) referenced in function "public: virtual __thiscall sf::CircleShape::~CircleShape(void)" (??1CircleShape@sf@@UAE@XZ)
1>Source.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Shape::setFillColor(class sf::Color const &)" (?setFillColor@Shape@sf@@QAEXABVColor@2@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::CircleShape::CircleShape(float,unsigned int)" (??0CircleShape@sf@@QAE@MI@Z) referenced in function _main
1>Source.obj : error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Green" (?Green@Color@sf@@2V12@B)
1>Source.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>c:\users\documents\visual studio 2012\Projects\MyGames\Debug\MyGames.exe : fatal error LNK1120: 17 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========





I have followed the exact 6 steps above as I wrote, nothing more nothing less. I don't understand dynamic and static parts of sfml whatsoever. I am at loss as to why it does not work for me.

As I have said already, I understand that this topic has been asked many times before and all the errors seem similar. However, after reading many threads I still can't seem to able to resolve this problem.

Thanks in advance for any one that can give me a hint as to what is wrong

3
General / Re: Controlling a window in multiple threads
« on: June 20, 2013, 09:58:12 am »
You should really look into some simple finite state machines. The way you're doing it is rather unconventional (and essentially wrong). You'll run into even more issues, e.g. lost events or unresponsive windows, even if you're able to solve the multithreading issues.

You should only have one main loop and then do things based on your state.

Simplified example:

while (window.isOpen()) {
    while (window.pollEvent(event)) {
        ...
    }

    switch (gamestate) {
    case GAME_LOAD:
        texture1.loadFromFile(...);
        texture2.loadFromFile(...);
        ...
        gamestate = GAME_MENU;
        break;
    case GAME_MENU:
        handleMenu();
        renderMenu();
        break;
    case GAME_GAMEOVER:
        handleGameOver();
        renderGameOver();
        break;
    }
}
 

The functions above would then handle things like updating or drawing the actual game or menu etc. but they'll all be called once per iteration.

Alright, always willing to learn. Do you happen to have any links to good tutorials on state machines? Also are they usable on SFML?

EDIT: nvm found it, all it takes is some googling, thanks anyways

4
General / Re: Controlling a window in multiple threads
« on: June 20, 2013, 05:55:26 am »
I'm not quite sure I understand you tbop, but to clarify, this is my code

void mymaze::runstuff()
{
       
        sf::RenderWindow window( sf::VideoMode(800,600), "Somegame", sf::Style::Close);
        window.setFramerateLimit(60);
        maze.setPosition(150,200);
        sprite.setPosition(346,205);
        myfont.loadFromFile("arial.ttf");
        sf::Text text("Welcome To Maze 101", myfont, 18 );
        sf::Text text2("Press up, down, left and right to move your red dot",myfont,18 );
        sf::Text text3("Maneover through the maze to the end to win", myfont, 18 );
        sf::Text text4("If you touch the maze walls, you lose instantly", myfont, 18 );
        sf::Text text5("Enjoy!!",myfont, 58 );
        sf::Text textWIN("YOU WIN!",myfont, 70 );
        textWIN.setStyle(sf::Text::Bold);
        textWIN.setColor(sf::Color::Cyan);
        text.setStyle(sf::Text::Bold);
        text5.setStyle(sf::Text::Underlined);
        text.setPosition(0,0);
        text2.setPosition(0,20);
        text3.setPosition(0,40);
        text4.setPosition(0,60);
        text5.setPosition(0,80);
        textWIN.setPosition(150,300);
       
        while(window.isOpen())
        {
                sf::Event event;
                while(window.pollEvent(event))
                {
                        if(event.type==sf::Event::Closed)
                        {
                                window.close();
                        }
                }
               
        //*Windows cleanup and input*//
                window.clear();
                window.draw(maze);
                window.draw(sprite);
                window.draw(text);
                window.draw(text2);
                window.draw(text3);
                window.draw(text4);
                window.draw(text5);

                controllogics();

        //*Check if user won *//
                if((sprite.getPosition().x >= 461 && sprite.getPosition().x<=467) && (sprite.getPosition().y >= 469 && sprite.getPosition().y <=475) )
                {
                        window.clear();
                        window.draw(textWIN);
                        window.display();
                        delay1sec();
                        window.clear();
                        while(!sf::Mouse::isButtonPressed(sf::Mouse::Left))
                        {
                                window.draw(tryagain);
                                window.display();
                        }
                        sprite.setPosition(346,205);
                }
               
                window.display();

        }
}

void mymaze::CheckIfLost2( void)
{
                sf::Text textLOSE("YOU LOSE!",myfont, 70 );
                        textLOSE.setStyle(sf::Text::Bold);
        textLOSE.setColor(sf::Color::Magenta);
                textLOSE.setPosition(100,300);
        sf::RenderWindow window( sf::VideoMode(800,600), "Somegame", sf::Style::Close);
        window.setFramerateLimit(60);
        while(window.isOpen())
        {
                sf::Event event;
                while(window.pollEvent(event))
                {
                        if(event.type==sf::Event::Closed)
                        {
                                window.close();
                        }
                }
        if(CheckIfLost()==TRUE)
                {
                                if( Lives == 0 )
                                {
                                        window.clear();
                                        window.draw(textLOSE);
                                        window.display();
                                        delay1sec();
                                        window.clear();
                                        while(!sf::Mouse::isButtonPressed(sf::Mouse::Left))
                                        {
                                                window.draw(tryagain);
                                                window.display();
                                        }
                                                sprite.setPosition(346,205);
                                                restoreLives();
                                        }
                                        else
                                        {
                                                Lives--;
                                                cout<<"YOU LOST A LIFE!!"<<endl;
                                        }
                }
        }
}

Basicly, what I'm trying to do is that in runstuff(), I'm doing the logic checking and all the usual game control stuff. In checkiflost2(), I'm using another method, checkiflost(), 's output to determine whether or not the user lost. If he did, checkiflost2() is supposed to print the "you lost" message on the window that runstuff() created.

Outside the two methods in the class header, I have got two threads that control each of those two methods.

The problem with this code right now is that each method opens its own window( obviously). What I'm trying to do is to allow the checkiflost2() method use the window that runstuff() has already created. I'm stuck on that part cuz I don't quite know how to do it. AND, at the same time, checkiflost2() has to be continously running independently of runstuff(), so that's why I thought of using threads.

For my program, it will not work if I just throw the code in checkiflost2() into runstuff(). I can't merge them together because of reasons I'd like to not get into(it's complicated).

Any help would be appreciated, thanks

5
General / Controlling a window in multiple threads
« on: June 17, 2013, 09:51:57 pm »
Hi, I am currently using SFML 2.0 and having trouble trying to access the same window in two different methods of the same class. So basicly, method A creates a window, and method B of that class is a "Checkifuserlost" method. What I'd like to do is to allow A to first create a window and run the game, and then let method B run in another thread and constantly check if user lost, if he did, then access the same window that A created and display "you lost" or something.

I've read the multithreading tutorials on SFML and googled this. I haven't found much answers that are relevant to mine. I'd appreciate it if I can get some helps on how exactly do we create two threads where each runs different methods, and allow one of the methods in one thread access the window created the method created in another thread.

Thanks

Pages: [1]
anything