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

Pages: 1 [2]
16
General discussions / sf::input for sfml2
« on: January 12, 2012, 02:32:08 am »
I have been following the Game From Scratch tutorial and it is coded in 1.6.
I think I have everything right except the code for sf::Input I looked at the documentation and cant seem to figure it out.Here is the code, if anyone can give some info i would greatly appreciate it.

 
Code: [Select]

const sf::Input& Game::GetInput()
{
return _mainWindow.GetInput();
}



I already know that it should be keyPressed and Keyboard

Code: [Select]

void PlayerPaddle::Update(float elapsedTime)
{

if(Game::GetInput().IsKeyDown(sf::Key::Left))
{
this->_velocity-= 5.0f;
}
if(Game::GetInput().IsKeyDown(sf::Key::Right))
{
this->_velocity+= 5.0f;
}

if(Game::GetInput().IsKeyDown(sf::Key::Down))
{
this->_velocity= 0.0f;
}

if(_velocity > _maxVelocity)
this->_velocity = _maxVelocity;

if(_velocity < -_maxVelocity)
this->_velocity = -_maxVelocity;


sf::Vector2f pos = this->GetPosition();

if(pos.x  < GetSprite().GetSize().x/2
|| pos.x > (Game::SCREEN_WIDTH - GetSprite().GetSize().x/2))
{
_velocity = -_velocity; // Bounce by current velocity in opposite direction
}

GetSprite().Move(_velocity * elapsedTime, 0);
}

17
General / Sprite movement
« on: November 14, 2011, 12:01:50 am »
Thank's I must have to use it in a if statement could not figure out how to use it in a switch.

18
General / Sprite movement
« on: November 13, 2011, 10:56:16 pm »
Thanks a lot for your help.It works now but I had to devide my GetFrameRate() / 200 to get it right. One more question if you don't mind. It pauses when I change directions is there something I can do about that?

19
General / Sprite movement
« on: November 13, 2011, 10:32:16 pm »
I am using sfml2

20
General / Sprite movement
« on: November 13, 2011, 10:25:01 pm »
Thanks that worked but the movement is choppy and then the spite dissapears is there a way to fix that?

21
General / Sprite movement
« on: November 13, 2011, 09:53:39 pm »
I am having a problem with sprite movement.If I run this code the only key that works is left.Nothing happens with the other keys.Another problems is the sprite moves right off the screen when I press left.Is there something simple I can do or do I need to write the code a different way?




Code: [Select]
float ElapsedTime = Window.GetFrameTime() ;
       
        // Move the sprite
        switch(Event.Type)
        {
        case sf::Event::KeyPressed:
            switch(Event.Key.Code)
            case sf::Keyboard::Left:
                Sprite.Move(-100 * ElapsedTime, 0);
                break;
            case sf::Keyboard::Right:
                Sprite.Move( 100 * ElapsedTime, 0);
                break;
            case sf::Keyboard::Up:
                Sprite.Move(0, -100 * ElapsedTime);
                break;
            case sf::Keyboard::Down:
                Sprite.Move(0,  100 * ElapsedTime);
                break;
            default:
                break;


        }

22
General / Key events on sfml2
« on: November 13, 2011, 04:38:41 pm »
Thanks alot that worked.

23
General / Key events on sfml2
« on: November 13, 2011, 04:24:35 pm »
in this switch statement it does not matter whitch key i press it says f was pressed what am i doing wrong?

 case sf::Event::KeyPressed:
                switch (Event.KeyPressed)
                {
                case sf::Keyboard::Back:
                    std::cout << "Backspace was pressed." << std:: endl;
                    break;
                case sf::Keyboard::F:
                    std::cout << "f was pressed." << std:: endl;
                    break;
                default:
                    break;
                }

24
General / sfml vs sfml 2.0 key events
« on: November 12, 2011, 09:54:01 pm »
I m following the tutorials on 1.6 .The one on opengl. When I try to compile it give me errors on the key events.

this is the line giving the errors:

if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();

I have read that you use keyboard instead of key but what would the line of code be?

Is there a code sheet showing the differences and how to write them?

25
General / opengl codeblocks
« on: November 12, 2011, 08:13:05 pm »
I am getting a error when trying to compile code with opengl

error: 'glClearDepth' was not declared in this scope|

I am using sfml2, do i need to link the opengl libraries and how?[/img][/code]

26
General / code completion code blocks
« on: November 12, 2011, 02:17:39 am »
Hey everyone I am new to SFML, I set up code blocks and can run a program fine but not all of my code completion works. Like when I type
sf::VideoMode it does not give me other options this would greatly help my learning. Any help with this will be appriciated.

Pages: 1 [2]
anything