Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Help with SFML GAME DEVELOPMENT CHAPTER 3. cant get code to work.  (Read 2987 times)

0 Members and 1 Guest are viewing this topic.

KyleTheCarpenter

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Hello i am refrencing Chapter 3 in the book Sfml Game Development.. ive been doing well until now. i cant get this to work i even copied and pasted all the git hub stuff to replace what i wrote and i still get the same errors..
https://github.com/SFML/SFML-Game-Development-Book/tree/master/03_World is the source i copy and pasted and still no work. my error messages are:

Build started...
1>------ Build started: Project: realBook, Configuration: Debug Win32 ------
1>Game.cpp
1>C:\SFML\realBook\SceneNode.h(11,17): error C2011: 'SceneNode': 'class' type redefinition
1>C:\SFML\realBook\SceneNode.h(11): message : see declaration of 'SceneNode'
1>C:\SFML\realBook\SpriteNode.h(7,1): error C2504: 'SceneNode': base class undefined
1>C:\SFML\realBook\Entity.h(6,1): error C2504: 'SceneNode': base class undefined
1>C:\SFML\realBook\ResourceIdentifier.hpp(10,2): error C2011: 'Textures::ID': 'enum' type redefinition
1>C:\SFML\realBook\ResourceIdentifier.hpp(9): message : see declaration of 'Textures::ID'
1>C:\SFML\realBook\World.h(46,18): error C2079: 'World::mSceneGraph' uses undefined class 'SceneNode'
1>C:\SFML\realBook\Game.cpp(89,27): error C3861: 'toString': identifier not found
1>C:\SFML\realBook\Game.cpp(90,25): error C3861: 'toString': identifier not found
1>Main.cpp
1>C:\SFML\realBook\SceneNode.h(11,17): error C2011: 'SceneNode': 'class' type redefinition
1>C:\SFML\realBook\SceneNode.h(11): message : see declaration of 'SceneNode'
1>C:\SFML\realBook\SpriteNode.h(7,1): error C2504: 'SceneNode': base class undefined
1>C:\SFML\realBook\Entity.h(6,1): error C2504: 'SceneNode': base class undefined
1>C:\SFML\realBook\ResourceIdentifier.hpp(10,2): error C2011: 'Textures::ID': 'enum' type redefinition
1>C:\SFML\realBook\ResourceIdentifier.hpp(9): message : see declaration of 'Textures::ID'
1>C:\SFML\realBook\World.h(46,18): error C2079: 'World::mSceneGraph' uses undefined class 'SceneNode'
1>World.cpp
1>C:\SFML\realBook\SceneNode.h(11,17): error C2011: 'SceneNode': 'class' type redefinition
1>C:\SFML\realBook\SceneNode.h(11): message : see declaration of 'SceneNode'
1>C:\SFML\realBook\SpriteNode.h(7,1): error C2504: 'SceneNode': base class undefined
1>C:\SFML\realBook\Entity.h(6,1): error C2504: 'SceneNode': base class undefined
1>C:\SFML\realBook\ResourceIdentifier.hpp(10,2): error C2011: 'Textures::ID': 'enum' type redefinition
1>C:\SFML\realBook\ResourceIdentifier.hpp(9): message : see declaration of 'Textures::ID'
1>C:\SFML\realBook\World.h(46,18): error C2079: 'World::mSceneGraph' uses undefined class 'SceneNode'
1>C:\SFML\realBook\World.cpp(30,43): error C2039: 'getPosition': is not a member of 'AirCraft'
1>C:\SFML\realBook\AirCraft.h(6): message : see declaration of 'AirCraft'
1>C:\SFML\realBook\World.cpp(48,26): error C2664: 'void sf::RenderTarget::draw(const sf::Drawable &,const sf::RenderStates &)': cannot convert argument 1 from 'int' to 'const sf::Drawable &'
1>C:\SFML\realBook\World.cpp(48,26): message : Reason: cannot convert from 'int' to 'const sf::Drawable'
1>C:\SFML\realBook\World.cpp(48,26): message : No constructor could take the source type, or constructor overload resolution was ambiguous
1>C:\SFML\sfml\include\SFML\Graphics\RenderTarget.hpp(237,10): message : see declaration of 'sf::RenderTarget::draw'
1>C:\SFML\realBook\World.cpp(53,31): error C2027: use of undefined type 'Textures::ID'
1>C:\SFML\realBook\ResourceIdentifier.hpp(9): message : see declaration of 'Textures::ID'
1>C:\SFML\realBook\World.cpp(53,36): error C2065: 'Eagle': undeclared identifier
1>C:\SFML\realBook\World.cpp(54,31): error C2027: use of undefined type 'Textures::ID'
1>C:\SFML\realBook\ResourceIdentifier.hpp(9): message : see declaration of 'Textures::ID'
1>C:\SFML\realBook\World.cpp(54,37): error C2065: 'Raptor': undeclared identifier
1>C:\SFML\realBook\World.cpp(55,31): error C2027: use of undefined type 'Textures::ID'
1>C:\SFML\realBook\ResourceIdentifier.hpp(9): message : see declaration of 'Textures::ID'
1>C:\SFML\realBook\World.cpp(55,37): error C2065: 'Desert': undeclared identifier
1>C:\SFML\realBook\World.cpp(63,14): error C2027: use of undefined type 'SceneNode'
1>C:\SFML\realBook\SceneNode.h(11): message : see declaration of 'SceneNode'
1>C:\SFML\realBook\World.cpp(63,18): error C2065: 'Ptr': undeclared identifier
1>C:\SFML\realBook\World.cpp(63,18): error C2146: syntax error: missing ';' before identifier 'layer'
1>C:\SFML\realBook\World.cpp(63,39): error C2027: use of undefined type 'SceneNode'
1>C:\SFML\realBook\SceneNode.h(11): message : see declaration of 'SceneNode'
1>C:\SFML\realBook\World.cpp(63,18): error C3861: 'layer': identifier not found
1>C:\SFML\realBook\World.cpp(64,21): error C2065: 'layer': undeclared identifier
1>C:\SFML\realBook\World.cpp(66,37): error C2065: 'layer': undeclared identifier
1>C:\SFML\realBook\World.cpp(70,53): error C2027: use of undefined type 'Textures::ID'
1>C:\SFML\realBook\ResourceIdentifier.hpp(9): message : see declaration of 'Textures::ID'
1>C:\SFML\realBook\World.cpp(70,59): error C2065: 'Desert': undeclared identifier
1>C:\SFML\realBook\World.cpp(70,23): error C2530: 'texture': references must be initialized
1>C:\SFML\realBook\World.cpp(76,20): error C2039: 'setPosition': is not a member of 'SpriteNode'
1>C:\SFML\realBook\SpriteNode.h(6): message : see declaration of 'SpriteNode'
1>C:\SFML\realBook\World.cpp(77,26): error C2027: use of undefined type 'SceneNode'
1>C:\SFML\realBook\SceneNode.h(11): message : see declaration of 'SceneNode'
1>C:\SFML\realBook\World.cpp(80,58): error C2039: 'Eagle': is not a member of 'AirCraft'
1>C:\SFML\realBook\AirCraft.h(6): message : see declaration of 'AirCraft'
1>C:\SFML\realBook\World.cpp(80,63): error C2065: 'Eagle': undeclared identifier
1>C:\SFML\realBook\World.cpp(82,19): error C2039: 'setPosition': is not a member of 'AirCraft'
1>C:\SFML\realBook\AirCraft.h(6): message : see declaration of 'AirCraft'
1>C:\SFML\realBook\World.cpp(84,19): error C2027: use of undefined type 'SceneNode'
1>C:\SFML\realBook\SceneNode.h(11): message : see declaration of 'SceneNode'
1>C:\SFML\realBook\World.cpp(87,62): error C2039: 'Raptor': is not a member of 'AirCraft'
1>C:\SFML\realBook\AirCraft.h(6): message : see declaration of 'AirCraft'
1>C:\SFML\realBook\World.cpp(87,68): error C2065: 'Raptor': undeclared identifier
1>C:\SFML\realBook\World.cpp(88,14): error C2039: 'setPosition': is not a member of 'AirCraft'
1>C:\SFML\realBook\AirCraft.h(6): message : see declaration of 'AirCraft'
1>C:\SFML\realBook\World.cpp(89,19): error C2039: 'attachChild': is not a member of 'AirCraft'
1>C:\SFML\realBook\AirCraft.h(6): message : see declaration of 'AirCraft'
1>C:\SFML\realBook\World.cpp(91,63): error C2039: 'Raptor': is not a member of 'AirCraft'
1>C:\SFML\realBook\AirCraft.h(6): message : see declaration of 'AirCraft'
1>C:\SFML\realBook\World.cpp(91,69): error C2065: 'Raptor': undeclared identifier
1>C:\SFML\realBook\World.cpp(92,15): error C2039: 'setPosition': is not a member of 'AirCraft'
1>C:\SFML\realBook\AirCraft.h(6): message : see declaration of 'AirCraft'
1>C:\SFML\realBook\World.cpp(93,19): error C2039: 'attachChild': is not a member of 'AirCraft'
1>C:\SFML\realBook\AirCraft.h(6): message : see declaration of 'AirCraft'
1>Generating Code...
1>Done building project "realBook.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
Severity        Code    Description     Project File    Line    Suppression State
Message         No constructor could take the source type, or constructor overload resolution was ambiguous     realBook        C:\SFML\realBook\World.cpp      48     
Error   C2039   'attachChild': is not a member of 'AirCraft'    realBook        C:\SFML\realBook\World.cpp      89     
Error   C2039   'attachChild': is not a member of 'AirCraft'    realBook        C:\SFML\realBook\World.cpp      93     
Error   C2065   'Desert': undeclared identifier realBook        C:\SFML\realBook\World.cpp      55     
Error   C2065   'Desert': undeclared identifier realBook        C:\SFML\realBook\World.cpp      70     
Error   C2065   'Eagle': undeclared identifier  realBook        C:\SFML\realBook\World.cpp      53     
Error   C2039   'getPosition': is not a member of 'AirCraft'    realBook        C:\SFML\realBook\World.cpp      30     
Error   C3861   'layer': identifier not found   realBook        C:\SFML\realBook\World.cpp      63     
Error   C2065   'layer': undeclared identifier  realBook        C:\SFML\realBook\World.cpp      64     
Error   C2065   'layer': undeclared identifier  realBook        C:\SFML\realBook\World.cpp      66     
Error   C2065   'Ptr': undeclared identifier    realBook        C:\SFML\realBook\World.cpp      63     
Error   C2065   'Raptor': undeclared identifier realBook        C:\SFML\realBook\World.cpp      54     
Error   C2011   'SceneNode': 'class' type redefinition  realBook        C:\SFML\realBook\SceneNode.h    11     
Error   C2504   'SceneNode': base class undefined       realBook        C:\SFML\realBook\SpriteNode.h   7      
Error   C2504   'SceneNode': base class undefined       realBook        C:\SFML\realBook\Entity.h       6      
Error   C2039   'setPosition': is not a member of 'AirCraft'    realBook        C:\SFML\realBook\World.cpp      82     
Error   C2039   'setPosition': is not a member of 'AirCraft'    realBook        C:\SFML\realBook\World.cpp      88     
Error   C2039   'setPosition': is not a member of 'AirCraft'    realBook        C:\SFML\realBook\World.cpp      92     
Error   C2039   'setPosition': is not a member of 'SpriteNode'  realBook        C:\SFML\realBook\World.cpp      76     
Error   C2530   'texture': references must be initialized       realBook        C:\SFML\realBook\World.cpp      70     
Error   C2011   'Textures::ID': 'enum' type redefinition        realBook        C:\SFML\realBook\ResourceIdentifier.hpp 10     
Error   C2664   'void sf::RenderTarget::draw(const sf::Drawable &,const sf::RenderStates &)': cannot convert argument 1 from 'int' to 'const sf::Drawable &'    realBook        C:\SFML\realBook\World.cpp      48     
Error   C2079   'World::mSceneGraph' uses undefined class 'SceneNode'   realBook        C:\SFML\realBook\World.h        46     
Message         Reason: cannot convert from 'int' to 'const sf::Drawable'       realBook        C:\SFML\realBook\World.cpp      48     
Message         see declaration of 'AirCraft'   realBook        C:\SFML\realBook\AirCraft.h     6      
Message         see declaration of 'AirCraft'   realBook        C:\SFML\realBook\AirCraft.h     6      
Message         see declaration of 'AirCraft'   realBook        C:\SFML\realBook\AirCraft.h     6      
Message         see declaration of 'AirCraft'   realBook        C:\SFML\realBook\AirCraft.h     6      
Message         see declaration of 'AirCraft'   realBook        C:\SFML\realBook\AirCraft.h     6      
Message         see declaration of 'AirCraft'   realBook        C:\SFML\realBook\AirCraft.h     6      
Message         see declaration of 'SceneNode'  realBook        C:\SFML\realBook\SceneNode.h    11     
Message         see declaration of 'SceneNode'  realBook        C:\SFML\realBook\SceneNode.h    11     
Message         see declaration of 'SceneNode'  realBook        C:\SFML\realBook\SceneNode.h    11     
Message         see declaration of 'SceneNode'  realBook        C:\SFML\realBook\SceneNode.h    11     
Message         see declaration of 'SceneNode'  realBook        C:\SFML\realBook\SceneNode.h    11     
Message         see declaration of 'sf::RenderTarget::draw'     realBook        C:\SFML\sfml\include\SFML\Graphics\RenderTarget.hpp     237    
Message         see declaration of 'SpriteNode' realBook        C:\SFML\realBook\SpriteNode.h   6      
Message         see declaration of 'Textures::ID'       realBook        C:\SFML\realBook\ResourceIdentifier.hpp 9      
Message         see declaration of 'Textures::ID'       realBook        C:\SFML\realBook\ResourceIdentifier.hpp 9      
Message         see declaration of 'Textures::ID'       realBook        C:\SFML\realBook\ResourceIdentifier.hpp 9      
Message         see declaration of 'Textures::ID'       realBook        C:\SFML\realBook\ResourceIdentifier.hpp 9      
Message         see declaration of 'Textures::ID'       realBook        C:\SFML\realBook\ResourceIdentifier.hpp 9      
Error   C2146   syntax error: missing ';' before identifier 'layer'     realBook        C:\SFML\realBook\World.cpp      63     
Error   C2027   use of undefined type 'SceneNode'       realBook        C:\SFML\realBook\World.cpp      63     
Error   C2027   use of undefined type 'SceneNode'       realBook        C:\SFML\realBook\World.cpp      63     
Error   C2027   use of undefined type 'SceneNode'       realBook        C:\SFML\realBook\World.cpp      77     
Error   C2027   use of undefined type 'SceneNode'       realBook        C:\SFML\realBook\World.cpp      84     
Error   C2027   use of undefined type 'Textures::ID'    realBook        C:\SFML\realBook\World.cpp      53     
Error   C2027   use of undefined type 'Textures::ID'    realBook        C:\SFML\realBook\World.cpp      54     
Error   C2027   use of undefined type 'Textures::ID'    realBook        C:\SFML\realBook\World.cpp      55     
Error   C2027   use of undefined type 'Textures::ID'    realBook        C:\SFML\realBook\World.cpp      70     
 


im in desperate need thanks so much

World.cpp
#include "World.h"

#include <SFML/Graphics/RenderWindow.hpp>


World::World(sf::RenderWindow& window)
        : mWindow(window)
        , mWorldView(window.getDefaultView())
        , mTextures()
        , mSceneGraph()
        , mSceneLayers()
        , mWorldBounds(0.f, 0.f, mWorldView.getSize().x, 2000.f)
        , mSpawnPosition(mWorldView.getSize().x / 2.f, mWorldBounds.height - mWorldView.getSize().y / 2.f)
        , mScrollSpeed(-50.f)
        , mPlayerAircraft(nullptr)
{
        loadTextures();
        buildScene();

        // Prepare the view
        mWorldView.setCenter(mSpawnPosition);
}

void World::update(sf::Time dt)
{
        // Scroll the world
        mWorldView.move(0.f, mScrollSpeed * dt.asSeconds());

        // Move the player sidewards (plane scouts follow the main aircraft)
        sf::Vector2f position = mPlayerAircraft->getPosition();
        sf::Vector2f velocity = mPlayerAircraft->getVelocity();

        // If player touches borders, flip its X velocity
        if (position.x <= mWorldBounds.left + 150.f
                || position.x >= mWorldBounds.left + mWorldBounds.width - 150.f)
        {
                velocity.x = -velocity.x;
                mPlayerAircraft->setVelocity(velocity);
        }

        // Apply movements
        mSceneGraph.update(dt);
}

void World::draw()
{
        mWindow.setView(mWorldView);
        mWindow.draw(mSceneGraph);
}

void World::loadTextures()
{
        mTextures.load(Textures::ID::Eagle, "files\\eagle.png");
        mTextures.load(Textures::ID::Raptor, "files\\raptor.png");
        mTextures.load(Textures::ID::Desert, "files\\desert.png");
}

void World::buildScene()
{
        // Initialize the different layers
        for (std::size_t i = 0; i < LayerCount; ++i)
        {
                SceneNode::Ptr layer(new SceneNode());
                mSceneLayers[i] = layer.get();

                mSceneGraph.attachChild(std::move(layer));
        }

        // Prepare the tiled background
        sf::Texture& texture = mTextures.get(Textures::ID::Desert);
        sf::IntRect textureRect(mWorldBounds);
        texture.setRepeated(true);

        // Add the background sprite to the scene
        std::unique_ptr<SpriteNode> backgroundSprite(new SpriteNode(texture, textureRect));
        backgroundSprite->setPosition(mWorldBounds.left, mWorldBounds.top);
        mSceneLayers[Background]->attachChild(std::move(backgroundSprite));

        // Add player's aircraft
        std::unique_ptr<AirCraft> leader(new AirCraft(AirCraft::Eagle, mTextures));
        mPlayerAircraft = leader.get();
        mPlayerAircraft->setPosition(mSpawnPosition);
        mPlayerAircraft->setVelocity(40.f, mScrollSpeed);
        mSceneLayers[Air]->attachChild(std::move(leader));

        // Add two escorting aircrafts, placed relatively to the main plane
        std::unique_ptr<AirCraft> leftEscort(new AirCraft(AirCraft::Raptor, mTextures));
        leftEscort->setPosition(-80.f, 50.f);
        mPlayerAircraft->attachChild(std::move(leftEscort));

        std::unique_ptr<AirCraft> rightEscort(new AirCraft(AirCraft::Raptor, mTextures));
        rightEscort->setPosition(80.f, 50.f);
        mPlayerAircraft->attachChild(std::move(rightEscort));
}

World.h
#include "ResourceHolder.hpp"
#include "SceneNode.h"
#include "SpriteNode.h"
#include "AirCraft.h"
#include "ResourceIdentifier.hpp"
#include <SFML/System/NonCopyable.hpp>
#include <SFML/Graphics/View.hpp>
#include <SFML/Graphics/Texture.hpp>

#include <array>


// Forward declaration
namespace sf
{
        class RenderWindow;
}

class World : private sf::NonCopyable
{
public:
        explicit                                                        World(sf::RenderWindow& window);
        void                                                            update(sf::Time dt);
        void                                                            draw();


private:
        void                                                            loadTextures();
        void                                                            buildScene();


private:
        enum Layer
        {
                Background,
                Air,
                LayerCount
        };


private:
        sf::RenderWindow& mWindow;
        sf::View                                                        mWorldView;
        TextureHolder                                           mTextures;

        SceneNode                                                       mSceneGraph;
        std::array<SceneNode*, LayerCount>      mSceneLayers;

        sf::FloatRect                                           mWorldBounds;
        sf::Vector2f                                            mSpawnPosition;
        float                                                           mScrollSpeed;
        AirCraft* mPlayerAircraft;
};
 

AirCraft h
#include "Entity.h"
#include "ResourceIdentifier.hpp"
#include <SFML/Graphics/Sprite.hpp>


class AirCraft : public Entity
{
public:
        enum Type
        {
                Eagle,
                Raptor,
        };


public:
        AirCraft(Type type, const TextureHolder& textures);


private:
        virtual void            drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const;


private:
        Type                            mType;
        sf::Sprite                      mSprite;
};
 

AirCraft cpp
#include "Aircraft.h"
#include "ResourceHolder.hpp"

#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/RenderStates.hpp>


Textures::ID toTextureID(AirCraft::Type type)
{
        switch (type)
        {
        case AirCraft::Eagle:
                return Textures::Eagle;

        case AirCraft::Raptor:
                return Textures::Raptor;
        }
        return Textures::Eagle;
}

AirCraft::AirCraft(Type type, const TextureHolder& textures)
        : mType(type)
        , mSprite(textures.get(toTextureID(type)))
{
        sf::FloatRect bounds = mSprite.getLocalBounds();
        mSprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);
}

void AirCraft::drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const
{
        target.draw(mSprite, states);
}

Scenenode cpp
#include "SceneNode.h"
#include "Foreach.hpp"

#include <algorithm>
#include <cassert>


SceneNode::SceneNode()
: mChildren()
, mParent(nullptr)
{
}

void SceneNode::attachChild(Ptr child)
{
        child->mParent = this;
        mChildren.push_back(std::move(child));
}

SceneNode::Ptr SceneNode::detachChild(const SceneNode& node)
{
        auto found = std::find_if(mChildren.begin(), mChildren.end(), [&] (Ptr& p) { return p.get() == &node; });
        assert(found != mChildren.end());

        Ptr result = std::move(*found);
        result->mParent = nullptr;
        mChildren.erase(found);
        return result;
}

void SceneNode::update(sf::Time dt)
{
        updateCurrent(dt);
        updateChildren(dt);
}

void SceneNode::updateCurrent(sf::Time)
{
        // Do nothing by default
}

void SceneNode::updateChildren(sf::Time dt)
{
        FOREACH(Ptr& child, mChildren)
                child->update(dt);
}

void SceneNode::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
        // Apply transform of current node
        states.transform *= getTransform();

        // Draw node and children with changed transform
        drawCurrent(target, states);
        drawChildren(target, states);
}

void SceneNode::drawCurrent(sf::RenderTarget&, sf::RenderStates) const
{
        // Do nothing by default
}

void SceneNode::drawChildren(sf::RenderTarget& target, sf::RenderStates states) const
{
        FOREACH(const Ptr& child, mChildren)
                child->draw(target, states);
}

sf::Vector2f SceneNode::getWorldPosition() const
{
        return getWorldTransform() * sf::Vector2f();
}

sf::Transform SceneNode::getWorldTransform() const
{
        sf::Transform transform = sf::Transform::Identity;

        for (const SceneNode* node = this; node != nullptr; node = node->mParent)
                transform = node->getTransform() * transform;

        return transform;
}

scenenode
#include <SFML/System/NonCopyable.hpp>
#include <SFML/System/Time.hpp>
#include <SFML/Graphics/Transformable.hpp>
#include <SFML/Graphics/Drawable.hpp>

#include <vector>
#include <memory>


class SceneNode : public sf::Transformable, public sf::Drawable, private sf::NonCopyable
{
public:
        typedef std::unique_ptr<SceneNode> Ptr;


public:
        SceneNode();

        void                                    attachChild(Ptr child);
        Ptr                                             detachChild(const SceneNode& node);

        void                                    update(sf::Time dt);

        sf::Vector2f                    getWorldPosition() const;
        sf::Transform                   getWorldTransform() const;


private:
        virtual void                    updateCurrent(sf::Time dt);
        void                                    updateChildren(sf::Time dt);

        virtual void                    draw(sf::RenderTarget& target, sf::RenderStates states) const;
        virtual void                    drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const;
        void                                    drawChildren(sf::RenderTarget& target, sf::RenderStates states) const;


private:
        std::vector<Ptr>                mChildren;
        SceneNode* mParent;
};
« Last Edit: July 02, 2021, 11:48:03 pm by KyleTheCarpenter »
<>< <>< <>< . Wishin i was fishin!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6272
  • Thor Developer
    • View Profile
    • Bromeon
Re: Help with SFML GAME DEVELOPMENT CHAPTER 3. cant get code to work.
« Reply #1 on: July 03, 2021, 12:45:59 pm »
Have you looked at the compiler error messages and tried to resolve them one-by-one?

If you copy-paste GitHub code partially into your own project, don't expect everything to magically work. And if it doesn't, don't just dump the code here and ask others to resolve it...

An alternative approach is to start from the official source, change things only slowly, and make sure things still work after every change. Git can be very helpful here: commit each change, and find out where stuff breaks.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

AnhBao

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: Help with SFML GAME DEVELOPMENT CHAPTER 3. cant get code to work.
« Reply #2 on: July 11, 2021, 08:31:42 am »
Try adding "#pragma once" too all header's beginning. It works like the block guards like "#inclide<Book/Source/World.hpp>".

P/s: As long as it compiles it may not run the right way. You should pay attention to World::World() initialisation. Well I got white screen once too. Be careful with mWorldView and mWorldBounds. They don't immediately work after initialisation for some reason. So in World(sf::RenderWindow& window) all you need to do is pass every arguments by window, not my World's members itself. One thing that works to me is to print out everything in the console. It will help you find out what is the problem.
« Last Edit: July 11, 2021, 08:34:13 am by AnhBao »

 

anything