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

Pages: [1]
1
General / Re: Custom Properties
« on: June 06, 2014, 08:55:47 pm »
I need to get the parameter "Texture". For example:
const std::vector<tmx::MapLayer>& layers = ml.GetLayers();
        for (const auto& l : layers)
        {
                 if (l.name == "Din")
                {      
                        for (const auto& o : l.objects)
                        {                      
                            if(o.GetName() == "Block") //  
                                {
                                        std::string tex  = o.GetNameTexture();    Get parameter "Texture"
                                       dimen = tmx::BodyCreator::Add(o, world, false , b2BodyType::b2_dynamicBody);
                                        Block.Create(dimen);

                                    Blocks.push_back(Block);
                                }                      
                       
                        }
                }
        }
In the variable "tex" should be "Block.png"


2
General / Re: Custom Properties
« on: June 06, 2014, 08:10:56 pm »
Help please!

3
General / Custom Properties
« on: April 29, 2014, 10:00:24 pm »
Hey. I'm creating a game for SFML in VS 11 and connect Box2d.
Loading map using https://github.com/fallahn/sfml-tmxloader
Map created in the program Tiled Map Editor.
Tell me how you can consider the option "Custom Properties" object, for example variable "Te".


4
General / Re: Flickering
« on: April 23, 2014, 10:53:18 pm »
i see it but a bit.
are your character images all same size ?
No other character size.

world.Step(1.0f / 60.0f, 3, 3);

You use 1/60 as your hardcoded timestep.


So when your step doesn't need exactly 1/60 seconds you might get your flickering.

Try to fix your timesteps and see if the flickering is gone.

Change
world.Step(1.0f / 60.0f, 3, 3);
does not help.
I understand that the processing speed in Box2D and the problems SFML.
Here's what will happen if to do so
world.Step(0.5f / 60.0f, 3, 3);

5
General / Flickering
« on: April 17, 2014, 05:14:36 pm »
Hey. I'm creating a game for SFML in VS 11 and connect Box2d.
Loading map using https://github.com/fallahn/sfml-tmxloader

The problem is that when the character still image flickers.

int main()
{
        sf::Vector2i screenSize(800u, 600u);    //&#1088;&#1072;&#1079;&#1088;&#1077;&#1096;&#1077;&#1085;&#1080;&#1077; &#1101;&#1082;&#1088;&#1072;&#1085;&#1072;
        sf::RenderWindow renderWindow(sf::VideoMode(screenSize.x, screenSize.y), "TMX Loader - Box2D Body Creation Example"); //&#1057;&#1086;&#1079;&#1076;&#1072;&#1077;&#1084; &#1101;&#1082;&#1088;&#1072;&#1085;
        renderWindow.setVerticalSyncEnabled(true); // &#1042;&#1082;&#1083;&#1102;&#1095;&#1072;&#1077;&#1084; &#1074;&#1077;&#1088;&#1090;&#1080;&#1082;&#1072;&#1083;&#1100;&#1085;&#1091;&#1102; &#1089;&#1080;&#1085;&#1093;&#1088;&#1086;&#1085;&#1080;&#1079;&#1072;&#1094;&#1080;&#1102; (&#1076;&#1083;&#1103; &#1087;&#1083;&#1072;&#1074;&#1085;&#1086;&#1081; &#1072;&#1085;&#1080;&#1084;&#1072;&#1094;&#1080;&#1080;)

        sf::View view; // &#1050;&#1072;&#1084;&#1077;&#1088;&#1072;
        view.reset(sf::FloatRect(0.0f, 0.0f, screenSize.x, screenSize.y));
        view.setViewport(sf::FloatRect(0.0f, 0.0f, 2.0f, 2.0f)); // &#1059;&#1074;&#1077;&#1083;&#1080;&#1095;&#1080;&#1074;&#1072;&#1077;&#1084; &#1080;&#1079;&#1086;&#1073;&#1088;&#1072;&#1078;&#1077;&#1085;&#1080;&#1077; &#1085;&#1072; 2


        //&#1089;&#1086;&#1079;&#1076;&#1072;&#1090;&#1100; &#1082;&#1072;&#1088;&#1090;&#1091; &#1080; &#1079;&#1072;&#1075;&#1088;&#1091;&#1079;&#1082;&#1072; &#1082;&#1072;&#1088;&#1090;&#1091;
        tmx::MapLoader ml("maps/");
        ml.Load("platformer.tmx");

        //create a box2D world
        b2World world(tmx::SfToBoxVec(sf::Vector2f(0.f, 300.f))); // &#1043;&#1088;&#1072;&#1074;&#1080;&#1090;&#1072;&#1094;&#1080;&#1103;
       
        CHARACTER Player;
        Player.Create();

        AnimationManager anim;
        anim.loadAnimXML("animations/Anim1.xml",Player.texture);

        const std::vector<tmx::MapLayer>& layers = ml.GetLayers();
        for (const auto& l : layers) // &#1057;&#1084;&#1086;&#1090;&#1088;&#1080;&#1084; &#1074;&#1089;&#1077; &#1089;&#1083;&#1086;&#1080; &#1085;&#1072; &#1082;&#1072;&#1088;&#1090;&#1077;.......... l &#1090;&#1086;&#1078;&#1077; &#1089;&#1072;&#1084;&#1086;&#1077; &#1095;&#1090;&#1086; layers... & &#1091;&#1082;&#1072;&#1079;&#1072;&#1090;&#1077;&#1083;&#1100;
        {
                if (l.name == "Stat") //&#1057;&#1084;&#1086;&#1090;&#1088;&#1080;&#1084; &#1089;&#1083;&#1086;&#1081; &#1082;&#1086;&#1090;&#1086;&#1088;&#1099;&#1081; &#1085;&#1072;&#1079;&#1099;&#1074;&#1072;&#1077;&#1090;&#1089;&#1103; Static
                {
                        for (const auto& o : l.objects) // o &#1090;&#1086;&#1078;&#1077; &#1089;&#1072;&#1084;&#1086;&#1077; &#1095;&#1090;&#1086; l.objects
                        {
                                b2Body* b1 = tmx::BodyCreator::Add(o, world);
                        }
                }
                else if (l.name == "Din")
                {
                        for (const auto& o : l.objects)
                        {
                                Player.body = tmx::BodyCreator::Add(o, world, true , b2BodyType::b2_dynamicBody);
                        }
                }
        }
       
        //-----------------------------------//
        sf::Clock clock;

        while(renderWindow.isOpen())
        {
               
                //poll input
                sf::Event evt;
                while(renderWindow.pollEvent(evt))
                {
                        if (evt.type == sf::Event::Closed)      
                                renderWindow.close();
         
                }

                //update
               
                world.Step(1.0f / 60.0f, 3, 3);
                //-----------------update the keyboard--------------------------------
                        Key_Update(Player,anim);
               //----------------update the keyboard-------------------------------    
       
                sf::Vector2f pos = tmx::BoxToSfVec(Player.body->GetPosition());        
               
                //-----------------------draw-------------------------------------------
                view.setCenter(pos.x+screenSize.x/4,pos.y+screenSize.y/4);
                renderWindow.setView(view);

                renderWindow.clear(sf::Color(107,140,255));

                renderWindow.draw(ml);

                anim.draw(renderWindow,pos);                   
                renderWindow.display();
        }

        return 0;
}



6
General / Re: drawing and collision objects
« on: March 26, 2014, 02:08:36 pm »
Thank you! I did so!
dynamicCube.setRotation(tmx::BoxToSfAngle(b->GetAngle() , b->IsSleepingAllowed()));

float tmx::BoxToSfAngle(float rads , bool Sleep)
{
        float rotation = -rads * 57.295779513082320876f;

                if(Sleep) //only test the body when resting
{
    const float tolerance = 2.f;
    if(rotation > 270.f - tolerance && rotation < 270.f + tolerance)
        rotation = 270.f;
        else if(rotation > 180.f - tolerance && rotation < 180.f + tolerance)
        rotation = 180.f;
        else if(rotation > 90.f - tolerance && rotation < 90.f + tolerance)
        rotation = 90.f;
        else if(rotation > 0.f - tolerance && rotation < 0.f + tolerance)
        rotation = 0.f;
}
        return rotation;
}

7
General / Re: drawing and collision objects
« on: March 25, 2014, 11:09:08 am »
If comment
dynamicCube.setRotation(tmx::BoxToSfAngle(b->GetAngle()));
then everything works fine. But right turn Cuba!

That showed that the console when a block fell on a flat surface!
std::cout << "dynamicCube.setRotation = " << dynamicCube.getRotation() << " : b->GetAngle() =" << tmx::BoxToSfAngle(b->GetAngle()) << std::endl;

dynamicCube.setRotation = 271.065 : b->GetAngle() = 271.065

If you change the height of the fall of the cube, the changing angles in the console.


8
General / Re: drawing and collision objects
« on: March 25, 2014, 09:47:59 am »
I created object. But drawn with distortion. What's wrong?
int main()
{
        sf::View view;
        view.reset(sf::FloatRect(0.0f, 0.0f, 1280u, 640u));
        view.setViewport(sf::FloatRect(0.0f, 0.0f, 2.0f, 2.0f));
        renderWindow.setView(view);

        tmx::MapLoader ml("maps/");
        ml.Load("platformer.tmx");

        //create a box2D world
        b2World world(tmx::SfToBoxVec(sf::Vector2f(0.f, 200.f)));

        sf::Sprite dynamicCube;
        sf::Texture tileSet;
        tileSet.loadFromFile("maps/box.png");
        dynamicCube.setTexture(tileSet);

        sf::FloatRect rect1;
        rect1 = sf::FloatRect(0,0,32,32);
        dynamicCube.setTextureRect(sf::IntRect(rect1.left, rect1.top,rect1.height,rect1.width));
                dynamicCube.setOrigin(rect1.height/2,rect1.width/2);

        b2Body* b;
        const std::vector<tmx::MapLayer>& layers = ml.GetLayers();
        for (const auto& l : layers)  
        {
                if (l.name == "Stat")
                {
                        for (const auto& o : l.objects)
                        {
                                b2Body* b1 = tmx::BodyCreator::Add(o, world);
                        }
                }
                else if (l.name == "Din")
                {
                        for (const auto& o : l.objects)
                        {
                                b = tmx::BodyCreator::Add(o, world, b2BodyType::b2_dynamicBody);
                        }
                }
        }

        //-----------------------------------//
        while(renderWindow.isOpen())
        {
                //poll input
                sf::Event event;
                while(renderWindow.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                renderWindow.close();
        }
                //update
                world.Step(1.0f / 60.0f, 6, 3);
       
                sf::Vector2f pos = tmx::BoxToSfVec(b->GetPosition());
                                dynamicCube.setPosition(pos.x,pos.y);
                                dynamicCube.setRotation(tmx::BoxToSfAngle(b->GetAngle()));             
               
                renderWindow.clear();
                renderWindow.draw(ml);
                        renderWindow.draw(dynamicCube);

                renderWindow.display();
        }

        return 0;
}

9
General / Re: drawing and collision objects
« on: March 24, 2014, 04:42:48 pm »
Thank you. Examples are to work. But I don't understand how using the new version to create to get to work with a simple map. Need to fell cube (Name - Bl). I attached map. Help please.

10
General / Re: drawing and collision objects
« on: March 23, 2014, 11:00:44 am »
The new version is not working... To Install VS11. We used all library. When running a Benchmark example there are errors.
MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>MapLoaderPrivate.obj : error LNK2019: unresolved external symbol _inflate referenced in function "private: bool __thiscall tmx::MapLoader::m_Decompress(char const *,class std::vector<unsigned char,class std::allocator<unsigned char> > &,int,int)" (?m_Decompress@MapLoader@tmx@@AAE_NPBDAAV?$vector@EV?$allocator@E@std@@@std@@HH@Z)
1>MapLoaderPrivate.obj : error LNK2019: unresolved external symbol _inflateEnd referenced in function "private: bool __thiscall tmx::MapLoader::m_Decompress(char const *,class std::vector<unsigned char,class std::allocator<unsigned char> > &,int,int)" (?m_Decompress@MapLoader@tmx@@AAE_NPBDAAV?$vector@EV?$allocator@E@std@@@std@@HH@Z)
1>MapLoaderPrivate.obj : error LNK2019: unresolved external symbol _inflateInit2_ referenced in function "private: bool __thiscall tmx::MapLoader::m_Decompress(char const *,class std::vector<unsigned char,class std::allocator<unsigned char> > &,int,int)" (?m_Decompress@MapLoader@tmx@@AAE_NPBDAAV?$vector@EV?$allocator@E@std@@@std@@HH@Z)
1>D:\Game\SFML Game\DarkRed\Test\Debug\Test.exe : fatal error LNK1120: 3 unresolved externals


11
General / drawing and collision objects
« on: March 21, 2014, 03:55:12 pm »
Hey. Please help me solve the problem! 
 I'm using VS C++ 10 connect the library SFML and Box2D..
Where the red arrow character can not pass. Map was created in Tiled Map Editor.
Error visible on screen shotah...

Pages: [1]