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

Pages: 1 ... 3 4 [5]
61
Audio / Sounds stop suddenly
« on: August 22, 2010, 06:32:08 pm »
Im using SFML v1.5

I have the same problem... and i try delete instace but.. SFML fail.. :\ (me fail but... xDDD)

I have this:
Code: [Select]

        std::deque<sf::Sound*>::iterator it = sounds.begin();
        while(it != sounds.end())
        {
            const sf::SoundBuffer *sbuffer = (*it)->GetBuffer();
            float duration = sbuffer->GetDuration();
            float pos = (*it)->GetPlayingOffset();

            if (pos == duration)
            {
                delete((*it));
                (*it) = 0x0;
                it = sounds.erase(it);
            }
            else
                ++it;
        }

In this code.... "pos" never is == to "duration" :S

Code: [Select]

        std::deque<sf::Sound*>::iterator it = sounds.begin();
        while(it != sounds.end())
        {
            if ((*it)->GetStatus() == sf::Sound::Stopped)
            {
                delete((*it));
                (*it) = 0x0;
                it = sounds.erase(it);
            }
            else
                ++it;
        }

This code delete the sound more fast... (NO LISTEN SOUND :S)

I add new sound with:
Code: [Select]

void CEngine::playSound(int sound_type)
{
    sf::Sound *sound;
    switch(sound_type)
    {
        case SOUND_FIRE:
        {
            sound = new sf::Sound(snd_fire01);
        } break;
        case SOUND_IMPACT:
        {
            sound = new sf::Sound(snd_impact01);
        } break;
        case SOUND_JUMP:
        {
            sound = new sf::Sound(snd_jump);
        } break;
        case SOUND_HURT:
        {
            sound = new sf::Sound(snd_hurt01);
        } break;
        case SOUND_FX1:
        {
            sound = new sf::Sound(snd_fx01);
        } break;

        default:
            return;
    }

    sound->Play();
    sounds.push_back(sound);
}



Help me pls!

62
General / Scrolling Enemy with map
« on: August 22, 2010, 05:08:51 pm »

63
General / KeyBoard Problem...
« on: August 22, 2010, 04:16:31 am »
Hi... i have this code:

Code: [Select]

...

            /************************
                EVENTOS DE TECLADO
             ************************/
            //TECLA PRESIONADA
            if (screen.GetInput().IsKeyDown(sf::Key::P) && key_pressed == false)
            {
                world.paused = world.paused?false:true;
            }
            if (last_event.Type == sf::Event::KeyPressed && key_pressed == false)
            {
                CPerson::STATE *char_state = &world.person->state;
                if(screen.GetInput().IsKeyDown(sf::Key::Space) && char_state->character != STATE_DOUBLEJUMP)
                {
                    world.person->body->SetLinearVelocity(b2Vec2(world.person->body->GetLinearVelocity().x, 0));

                    if (char_state->character == STATE_GROUND)
                    {
                        char_state->character = STATE_JUMP;
                        world.person->body->ApplyImpulse(b2Vec2(0,-50), world.person->pos);
                    }
                    else if (char_state->character == STATE_JUMP)
                    {
                        char_state->character = STATE_DOUBLEJUMP;
                        world.person->body->ApplyImpulse(b2Vec2(0,-30), world.person->pos);
                    }
                    //playSound(SOUND_JUMP);
                }

                if((screen.GetInput().IsKeyDown(sf::Key::A) && world.person->body->GetLinearVelocity().x > 0.0f) || (screen.GetInput().IsKeyDown(sf::Key::D) && world.person->body->GetLinearVelocity().x < 0.0f))
                    world.person->body->SetLinearVelocity(b2Vec2(world.person->body->GetLinearVelocity().x/2, world.person->body->GetLinearVelocity().y));

                key_pressed = true;
            }
            //TECLA SOLTADA
            if (last_event.Type == sf::Event::KeyReleased && key_pressed == true)
                key_pressed = false;
        }

        //Raton
        sf::Vector2f mousepos = screen.ConvertCoords(screen.GetInput().GetMouseX(), screen.GetInput().GetMouseY());
        mouse.x = mousepos.x;
        mouse.y = mousepos.y;
        resources.sprt_cursor.SetPosition(mouse.x, mouse.y);

        //Movimientos del Personaje (TODO: Se tiene que mejorar la jugabilidad!)
        if(screen.GetInput().IsKeyDown(sf::Key::A))
        {
            CPerson::STATE *char_state = &world.person->state;
            //Velocidad inicial Positiva
            if (world.person->body->GetLinearVelocity().x > -1.0f)
            {
                if (char_state->character == STATE_GROUND )
                    world.person->body->ApplyForce(b2Vec2(-70.0f, 0.0f), world.person->pos);
                else if (world.person->body->GetLinearVelocity().x > -6.0f)
                    world.person->body->ApplyForce(b2Vec2(-30.0f, 0.0f), world.person->pos);
            }
            else
            {
                //Impulso
                if (world.person->state.character == STATE_GROUND)
                    world.person->body->ApplyForce(b2Vec2(-150.0f, 0.0f), world.person->pos);
                else
                    world.person->body->ApplyForce(b2Vec2(-10.0f, 0.0f), world.person->pos);
            }
        }
        if(screen.GetInput().IsKeyDown(sf::Key::D))
        {
            CPerson::STATE *char_state = &world.person->state;

            //Velocidad inicial Positiva
            if (world.person->body->GetLinearVelocity().x < 1.0f)
            {
                if (char_state->character == STATE_GROUND)
                    world.person->body->ApplyForce(b2Vec2(70.0f, 0.0f), world.person->pos);
                else if (world.person->body->GetLinearVelocity().x < 6.0f)
                    world.person->body->ApplyForce(b2Vec2(30.0f, 0.0f), world.person->pos);
            }
            else
            {
                //Impulso
                if (world.person->state.character == STATE_GROUND)
                    world.person->body->ApplyForce(b2Vec2(150.0f, 0.0f), world.person->pos);
                else
                    world.person->body->ApplyForce(b2Vec2(10.0f, 0.0f), world.person->pos);
            }
        }

...


When holding a key down and press another ... need to give two times the key to respond ...


Try It: http://filebeam.com/1dc9cc3d18b390b50625d2f897b1ef11

You can't run and jump... (need press jump two times :S)

64
General / [Noob Question] FPS & TimeStep & box2D
« on: July 30, 2010, 05:16:12 pm »
Ok now i have this:

LIMIT FRAME RATE:
Code: [Select]
screen.SetFramerateLimit(60);

RATIO PIXELS:
Code: [Select]
const float RATIO = 30.0f;

GAMELOOP:
Code: [Select]

        if (!world.paused)
        {
            world.world->Step(screen.GetFrameTime(), 10);

            camera.move();

            draw_game();
            screen.Display();
        }

        sf::Sleep(0.01);


And now.. works very slow (Similar to play in the Moon).... ¿How Sync box2D???? :S

Download Demo Game Win x86: Triog v0.1.1.2a
Move with Keys: A-D-SPACE-MOUSE1

65
General / [Noob Question] FPS & TimeStep & box2D
« on: July 30, 2010, 01:49:53 pm »
Hi.... sorry for this very noob question but... i'm starting with "Game Programming" and  for me more algoritms are confuse...

Ok... i have problems when i try sync box2D World with the "Game Loop"... SFML works fine... but box2D update positions & forces very fast in Linux and ~fast in Windows.....


TIMESTEP DECLARATION:
Code: [Select]
const float TIMESTEP = 1.0f / 60.0f;

GAMELOOP:
Code: [Select]

        //Update Box2D
        if (time_step_box2D.GetElapsedTime() >= 0.001)
        {
            world.world->Step(TIMESTEP, 10);
            time_step_box2D.Reset();
        }
        //updatePhysics();

        //Update Camera Pos
        camera.move();

        if (!world.paused && time_step.GetElapsedTime() >= TIMESTEP) {
            //world.world->Step(TIMESTEP, 10);
            //screen.Clear();

            draw_game();
            draw_player_hud();

            screen.Display();
            time_step.Reset();
        }

        //CPU by happy :)
        #ifndef __WIN32
            usleep(1);
        #else
            Sleep(1);
        #endif




Sry for my bad english :\

66
SFML projects / Mappy tilemap engine playback library port for SFML
« on: July 04, 2010, 08:11:25 pm »
Ok..i fixed my problem ;)

67
SFML projects / Mappy tilemap engine playback library port for SFML
« on: July 03, 2010, 08:31:01 pm »
Hi! Thank you for responding :)

The problem I have it when I want things away....

With x2 Zoom:


With x0.5 Zoom:



Thx!


P.D: Sry for my bad english :\

68
SFML projects / Using Zoom
« on: July 02, 2010, 04:03:01 am »
Hi! first, great work!! ;)

Pls.. How can use sf::View zooming with SFMLMappy ???

Thx!

Pages: 1 ... 3 4 [5]
anything