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

Pages: [1]
1
General / Re: Help, new to SFML, compile errors in simple project
« on: March 05, 2015, 08:57:55 pm »
Quote
the command prompt just shows a load of scrambled chars

If I were a betting man.... you mixed up debug and release libs.

WE HAVE A WINNER!!!!!  ;D ;D ;D ;D ;D

2
General / Re: Help, new to SFML, compile errors in simple project
« on: March 05, 2015, 08:44:45 pm »
@Arcade - it shouldn't overly matter but I've tried either way

@zsbzsb - I suppose its possible, I can take a look

3
General / Re: Help, new to SFML, compile errors in simple project
« on: March 05, 2015, 07:59:58 pm »
@StormWingDelta - thats all the code there is....if you cant see it, it doesnt exist.

@Arcade - Nope nothing prints to the console, if the picture exists or not it fails, the command prompt just shows a load of scrambled chars before it bombs out...I also agree its likely a runtime error in the C++ redist but I've removed it and reinstalled with no luck, tried official and nightly builds of SFML and I've tried both VS2013CE and VC++2010

The only thing I havent done is try another computer which I'll do in a few minutes

4
General / Help, new to SFML, compile errors in simple project
« on: March 05, 2015, 10:56:31 am »
Hi everybody,
This is driving me up the wall, I cannot get this thing to run and I've tried everything, I'm trying to follow the book example from http://www.amazon.com/SFML-Game-Development-Jan-Haller/dp/1849696845 Chapter 1 and I'm getting an error at compile

**EDIT**
If I remove the call to loadFromFile it seems fine, although it does nothing....
**ENDEDIT**

**EDIT**
Oh and I'm using VS2013 community ed, but I've also tried this on VC++E2010 too and I get the same issue
**ENDEDIT**

Error:
First-chance exception at 0x6D96F20C (msvcr120.dll) in SFML-tuts.exe: 0xC0000005: Access violation reading location 0x00ACF000.

Stack:
6D96F20C  rep movs    byte ptr es:[edi],byte ptr [esi]

All the code:

Game.h:
#include <SFML/Graphics.hpp>
#include <SFML/Window/Event.hpp>

class Game
{
public:
        Game();
        void run();
private:
        void handlePlayerInput(sf::Keyboard::Key key, bool isPressed);
        void processEvents();
        void update();
        void update(sf::Time deltaTime);
        void render();
        bool mIsMovingUp;
        bool mIsMovingDown;
        bool mIsMovingLeft;
        bool mIsMovingRight;
        static const float              PlayerSpeed;
        sf::RenderWindow mWindow;
        sf::Texture mTexture;
        sf::Sprite mPlayer;

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

Game.cpp
#include "Game.h"
#include <iostream>

const float Game::PlayerSpeed = 100.f;

Game::Game()
        : mWindow(sf::VideoMode(640, 480), "SFML Application")
        , mTexture()
        , mPlayer()
{
        if (!mTexture.loadFromFile("/Media/Textures/Eagle.png"))
        {
                std::cout << "Error canny load file";
        }
        mPlayer.setTexture(mTexture);
        mPlayer.setPosition(100.f, 100.f);
}
void Game::run()
{
        sf::Clock clock;
        sf::Time timeSinceLastUpdate = sf::Time::Zero;
        sf::Time TimePerFrame = sf::seconds(1.f / 60.f);
        while (mWindow.isOpen())
        {
                processEvents();
                timeSinceLastUpdate += clock.restart();
                while (timeSinceLastUpdate > TimePerFrame)
                {
                        timeSinceLastUpdate -= TimePerFrame;
                        processEvents();
                        update(TimePerFrame);
                }
                render();
        }
}
void Game::handlePlayerInput(sf::Keyboard::Key key, bool isPressed)
{
        if (key == sf::Keyboard::W)
                mIsMovingUp = isPressed;
        else if (key == sf::Keyboard::S)
                mIsMovingDown = isPressed;
        else if (key == sf::Keyboard::A)
                mIsMovingLeft = isPressed;
        else if (key == sf::Keyboard::D)
                mIsMovingRight = isPressed;
}
void Game::processEvents()
{
        sf::Event event;
        while (mWindow.pollEvent(event))
        {
                switch (event.type)
                {
                case sf::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(sf::Time deltaTime)
{
        sf::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();
}

Pages: [1]
anything