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

Pages: [1]
1
Graphics / Re: [SOLVED] Auto Movement
« on: July 27, 2013, 09:15:31 pm »
Just had to initialize all the booleans to false

2
Graphics / Re: Auto Movement
« on: July 27, 2013, 11:04:31 am »
So I have to downgrade my OS or use linux?

3
Graphics / [SOLVED] Auto Movement
« on: July 27, 2013, 01:38:56 am »
First of all, I'm currently reading the SFML Game Development book, in the first chapter, when movement is introduced, I encountered some problems, I spawn a white circle in the centre of the window, now If i press any directional arrow, the circle keeps going in the other direction till I press it, and then it gets back to normal, and horizontal and vertical ones are seperate.

Example: I start "Game", press up, the circle keeps going down, i hold up, the circle stands still, I release, it keeps going down, I press down, it stops, now it responds normally to both keys, it will happen again with the right and left, it gets fixed after the initial error, but I wish to know how I can remove it

#include <SFML/Graphics.hpp>
using namespace sf;

class Game
{
        public:Game();
                void run();

        private:
                void processEvents();
                void update(Time);
                void render();
                void handlePlayerInput(Keyboard::Key,bool);

                bool mIsMovingUp, mIsMovingRight, mIsMovingLeft, mIsMovingDown;
                float playerSpeed;
                Time TimePerFrame;
               

        private:
                RenderWindow mWindow;
                CircleShape mPlayer;
};

Game::Game():mWindow(VideoMode(640, 480), "SFML Application"),mPlayer(), playerSpeed(20.f), TimePerFrame(seconds(1.f / 60.f))
{
        mPlayer.setRadius(20.f);
        mPlayer.setPosition(220.f, 220.f);
        mPlayer.setFillColor(Color::White);
}

void Game::handlePlayerInput(Keyboard::Key key, bool isPressed)
{
        if (key == Keyboard::W || key == Keyboard::Up)
                mIsMovingUp = isPressed;
        else if (key == Keyboard::S || key == Keyboard::Down)
                mIsMovingDown = isPressed;
        else if (key == Keyboard::A || key == Keyboard::Left)
                mIsMovingLeft = isPressed;
        else if (key == Keyboard::D || key == Keyboard::Right)
                mIsMovingRight = isPressed;
}

void Game::run()
{
        Clock clock;
        Time timeSinceLastUpdate = Time::Zero;
        while (mWindow.isOpen())
        {
                processEvents();
                timeSinceLastUpdate += clock.restart();
                while (timeSinceLastUpdate > TimePerFrame)
                {
                        timeSinceLastUpdate -= TimePerFrame;
                        processEvents();
                        update(TimePerFrame);
                }
        render();
        }
}

void Game::processEvents()
{
        Event event;
        while (mWindow.pollEvent(event))
        {
                switch (event.type)
                {
                        case Event::KeyPressed:
                                handlePlayerInput(event.key.code, true);
                                break;
                        case sf::Event::KeyReleased:
                                handlePlayerInput(event.key.code, false);
                                break;
                        case sf::Event::Closed:
                                mWindow.close();
                                break;
                }
        }
}

void Game::update(Time deltaTime)
{
        Vector2f movement(0.f, 0.f);
        if (mIsMovingUp)
                movement.y -= playerSpeed;
        if (mIsMovingDown)
                movement.y += playerSpeed;
        if (mIsMovingLeft)
                movement.x -= playerSpeed;
        if (mIsMovingRight)
                movement.x += playerSpeed;

        mPlayer.move(movement * deltaTime.asSeconds());
}

void Game::render()
{
        mWindow.clear();
        mWindow.draw(mPlayer);
        mWindow.display();
}

int main()
{
        Game game;
        game.run();
}

4
General / [SOLVED] Configuration Problem
« on: July 06, 2013, 07:34:02 am »
I'm using VS 11 and was just following the SFML configuration tutorial, and at the end when I compile I get

"error lnk1112 module machine type 'x64' conflicts with target machine type 'x86' sfml"

 and I even tried go to linker > advanced > and change target machine, but that just changed their order, this is my linker input (just incase they are wrong, they look a bit wrong to me)

"sfml-system-s.lib;sfml-window-s.lib;sfml-graphics-s.lib;sfml-network-s.lib;sfml-audio-s.lib;sfml-system-s-d.lib;sfml-window-s-d.lib;sfml-graphics-s-d.lib;sfml-network-s-d.lib;sfml-audio-s-d.lib;%(AdditionalDependencies)"

and this is my c++ preprocessor

"SFML_STATIC;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)"

Can someone help?

Pages: [1]
anything