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

Pages: 1 [2] 3 4 ... 10
16
Graphics / Re: Bug with texture rendering
« on: May 23, 2013, 04:24:09 am »
Today i post all the source in a temp github repository to share the problem. I think that it will help everyone:

https://github.com/prsolucoes/sfml-cmake-temp

Can anyone help me?

17
Graphics / Re: Bug with texture rendering
« on: May 22, 2013, 09:03:23 pm »
My simple engine code:

Quote
Engine::Engine()
{
    Util::log("Engine::Engine");
    resetRandom();
    setupScreen();
    setupBackgroundColor();

    showSampleContent = true;
}

Engine::~Engine()
{
    Util::log("Engine::~Engine");
}

void Engine::run()
{
    Util::log("Engine::run");

    GameObjects::gravity = new b2Vec2(0.f, 9.8f);
    GameObjects::world   = new b2World(*GameObjects::gravity);

    player = new Player();

    initializeGraphics();

    sf::Clock frameClock;

    while (GameObjects::window->isOpen())
    {
        sf::Time delta = frameClock.restart();

        GameObjects::world->Step(1/60.f, 8, 3);

        checkEvents();

        GameObjects::window->clear(backgroundColor);

        player->update(delta);
        player->draw();

        GameObjects::window->display();

        sf::sleep(sf::milliseconds(1));
    }
}

void Engine::initializeGraphics()
{
    Util::log("Engine::initializeGraphics");

    sf::ContextSettings settings;
    settings.depthBits = 0;
    settings.stencilBits = 0;
    settings.antialiasingLevel = 0;

    GameObjects::window = new sf::RenderWindow(sf::VideoMode(screenWidth, screenHeight, screenBitsPerPixel), screenTitle, sf::Style::Close, settings);
    GameObjects::window->setVerticalSyncEnabled(true);
}

void Engine::checkEvents()
{
    sf::Event Event;

    while (GameObjects::window->pollEvent(Event))
    {
        if (Event.type == sf::Event::Closed)
        {
            GameObjects::window->close();
            return;
        }

        player->updateEvents(Event);
    }

    player->updateEvents(Event);
}

void Engine::resetRandom()
{
    srand(time(NULL));
}

void Engine::setupScreen()
{
    screenWidth        = 800;
    screenHeight       = 600;
    screenBitsPerPixel = 32;
    screenTitle        = "Magic And Zombie";
}

void Engine::setupBackgroundColor()
{
    backgroundColor = sf::Color(0, 0, 0);
}

18
Graphics / Re: Bug with texture rendering
« on: May 22, 2013, 09:01:11 pm »
Based on that code, i think that everything is ok.

I read and re-read it, analyse and i dont find the problem.

19
Graphics / Re: Bug with texture rendering
« on: May 22, 2013, 08:50:23 pm »
Im using:

Quote
Player constructor:

width  = 40;
height = 56;

texture = new sf::Texture();
texture->loadFromFile(resourcePath() + "images/player1.png");

walkingAnimation = new Animation();
walkingAnimation->setSpriteSheet(*texture);
walkingAnimation->addFrame(sf::IntRect(0, 2*height, width, height));
walkingAnimation->addFrame(sf::IntRect(1*width, 2*height, width, height));
walkingAnimation->addFrame(sf::IntRect(2*width, 2*height, width, height));
walkingAnimation->addFrame(sf::IntRect(3*width, 2*height, width, height));

stoppedAnimation = new Animation();
stoppedAnimation->setSpriteSheet(*texture);
stoppedAnimation->addFrame(sf::IntRect(0, 2*height, width, height));

jumpingAnimation = new Animation();
jumpingAnimation->setSpriteSheet(*texture);
jumpingAnimation->addFrame(sf::IntRect(0, 2*height, width, height));

sprite = new AnimatedSprite(sf::seconds(0.2));
sprite->setAnimation(*stoppedAnimation);
//sprite->setColor(sf::Color::Red);
sprite->setOrigin(width/2.f,height/2.f);

createEntityPhysics(*GameObjects::world, 50, 50, width, height);


Engine:
$this->player = new Player();

20
Graphics / Bug with texture rendering
« on: May 22, 2013, 07:58:33 pm »
Hi,

Im building a game and when i create all in the same class, everything is working fine, and after it works, i separate it into classes and refactored the code.

After refactor, my player class have a texture attribute that store the texture and the engine draw the animated sprite.

So the pseudo-code is:

Quote
Player
  - AnimatedSprite *sprite
  - sf::Texture *texture

Engine
  - player->update(sf::Time delta)
  - player->draw() or window->draw(*player->sprite)   // both code i get the same problem

Can anyone try help me? I think that is a small problem, because it is moving correctly and everything is working, only the rendering problem while player draw.

Screenshot is attached with result.

Thanks.

[attachment deleted by admin]

21
General / Re: Shape with alpha effect
« on: May 21, 2013, 11:54:36 pm »
Hi Nexus.

It works.

The code for reference:
Quote
rectangle.setFillColor(sf::Color(255,0,0,100));  // reg, green, blue, alpha

Very thanks man.

22
General / Shape with alpha effect
« on: May 21, 2013, 11:47:23 pm »
Hi,

Im drying use shapes to debug box2d physics. But the problem is that shape dont have a method to make it alpha.

I see some examples that you can use opengl direct to do it.

SFML has a native method to make shapes with alpha?

23
General / Re: Box2D - The physic body is bigger
« on: May 21, 2013, 11:39:40 pm »
FRex very thanks. Is it.

Very nice observation.

Problem solved :)

24
General / Re: Box2D - The physic body is bigger
« on: May 21, 2013, 11:37:36 pm »
I made another test creating a rectangle with AnimatedSprite size and position and it looks ok, only the physic object is wrong.

Attached!

[attachment deleted by admin]

25
General / Re: Box2D - The physic body is bigger
« on: May 21, 2013, 11:28:51 pm »
I change it. But the problems still near the same. See the screenshot attached.

The code:

Quote

void Engine::createPlayerPhysics(b2World& World, int posX, int posY, int width, int height)
{
    b2BodyDef BodyDef;
    BodyDef.position = b2Vec2(posX/SCALE, posY/SCALE);
    BodyDef.type = b2_dynamicBody;
    BodyDef.userData = (void*)"mainPlayer";
    playerBody = World.CreateBody(&BodyDef);

    b2PolygonShape Shape;
    Shape.SetAsBox((width/2)/SCALE, (height/2)/SCALE);
    b2FixtureDef FixtureDef;
    FixtureDef.density = 10.f;
    FixtureDef.friction = 0.7f;
    FixtureDef.shape = &Shape;
    playerBody->CreateFixture(&FixtureDef);
}


My SCALE const is 30.0f;

thanks.

[attachment deleted by admin]

26
General / Box2D - The physic body is bigger
« on: May 21, 2013, 11:04:42 pm »
Hi,

Im using the box2d with sfml and animated sprite class.

You see the example in screenshot attached.

My player is 40/56 (width/height) and when i create the physic body, it is bigger than my sprite size.

If you see in screenshot, you will see that the boxes are one up other, and over the player it have a padding/blank space, the boxes collide with a space bigger than my sprite.

My code:

Quote
void Engine::createPlayerPhysics(b2World& World, int posX, int posY, int width, int height)
{
    b2BodyDef BodyDef;
    BodyDef.position = b2Vec2(posX/SCALE, posY/SCALE);
    BodyDef.type = b2_dynamicBody;
    BodyDef.userData = (void*)"mainPlayer";
    playerBody = World.CreateBody(&BodyDef);

    b2PolygonShape Shape;
    Shape.SetAsBox(width/SCALE, height/SCALE);
    b2FixtureDef FixtureDef;
    FixtureDef.density = 10.f;
    FixtureDef.friction = 0.7f;
    FixtureDef.shape = &Shape;
    playerBody->CreateFixture(&FixtureDef);
}

    ////////////// player ////////////////
    int width = 40;
    int height = 56;

    sf::Texture playerTexture;
    playerTexture.loadFromFile(resourcePath() + "images/player1.png");

    Animation walkingAnimation;
    walkingAnimation.setSpriteSheet(playerTexture);
    walkingAnimation.addFrame(sf::IntRect(0, 2*height, width, height));
    walkingAnimation.addFrame(sf::IntRect(1*width, 2*height, width, height));
    walkingAnimation.addFrame(sf::IntRect(2*width, 2*height, width, height));
    walkingAnimation.addFrame(sf::IntRect(3*width, 2*height, width, height));

    AnimatedSprite animatedSprite(sf::seconds(0.2));
    animatedSprite.setAnimation(walkingAnimation);
   
    createPlayerPhysics(*world, 50, 50, width, height);

What can be wrong?

[attachment deleted by admin]

27
General / Re: Mac deploy problems
« on: May 21, 2013, 09:23:43 pm »
But my compiler on 10.8 is clang. I can use gcc version 10.5+ with my clang?

I think that is incompatible, no?

28
General / Re: Mac deploy problems
« on: May 21, 2013, 09:16:58 pm »
You dont release a pre-compiled version for 10.7 (clang), only 10.8.


29
General / Mac deploy problems
« on: May 21, 2013, 07:35:09 pm »
Hi,

What libs i need link with my project to deploy my application on other Mac.

I currently link to:
- SFML
- Box2D
- sndfile (framework)
- freetype (framework)

I need link with these too?

- libGLEW
- libjpeg

I compile the project on my mac with osx 10.8, and on mac 10.7.5 i got error. I think that the problem can be this libs, but i need know if i need link my program with those libraries or the problem is the osx version that is different.

thanks.

30
General / Re: Link problem with SFML2
« on: May 17, 2013, 09:08:56 pm »
Hi,

Problem +/- solved.

I dont need link to sndfile and freetype, i only need copy the *.framework to correct path.

Now everything is ok in the main project.

https://github.com/prsolucoes/sfml-cmake

Pages: 1 [2] 3 4 ... 10