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.


Topics - traxys

Pages: [1]
1
Window / One action per isKeyPressed
« on: September 28, 2014, 05:43:09 pm »
Hello,

Here is the problem I have , I want to make something move from one lane to another , for that in a loop for window.isOpen() in the pollEvent loop I use this code , wich seemed pretty good to me :
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up)){
                player.moveLane(UP);
            }
            if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down)){
                player.moveLane(DOWN);
            }
 
But the problem here is that on the next occurence of the isOpen loop , it will try again to move , so the player moves twice , while pressing one key. So my idea was too make the player move one lane when pressing the key , how do you do that if this code doesn't work ?

And thhanks to anyone looking here :)

2
Graphics / Texture loaded , drawn , but not shown on the screen
« on: May 25, 2014, 06:33:20 pm »
I am coding a game , and just started some of the graphical part so I just started to try using SFML for it , but I had a bug where a sprite would not show on screen, so I tought that ther was bugs deep into my code , and so I made a fresh project with what could be considered like the most basic code to show a Sprite , but it is doing the same thing , and I can't understand why...

     Here is the basic code(even if you could guess it x) ):

#include <iostream>
#include <SFML/Graphics.hpp>

using namespace std;
using namespace sf;

int main(){
    RenderWindow window(VideoMode(500,500),"Test");

    Texture lavaFlow;
    lavaFlow.loadFromFile("lavaFlow.png");

    Sprite lavaFlowSprite;
    lavaFlowSprite.setTexture(lavaFlow);

    while(window.isOpen()){
        Event event;

        while(window.pollEvent(event)){
            if(event.type == Event::Closed){
                window.close();
            }
            window.clear();

            window.draw(lavaFlowSprite);

            window.display();
        }
    }
    return 0;
}

And few things to know , since I am compiling on Debug , some of the error shows , so I know that the Image has been loaded , and the image was firts in jpeg so I thank that it was maybe a type problem , so I converted it into png

Thanks to anyone who could help me !

Pages: [1]
anything