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

Pages: 1 [2] 3
16
SFML projects / Re: Thor 2.0
« on: March 04, 2015, 02:21:22 pm »
Well, it still has yet to work, so i think i will wait until i boot camp my macbook to begin using thor(the nightly builds make it SO much easiar)

17
SFML projects / Re: Thor 2.0
« on: March 03, 2015, 09:54:12 pm »
So i compiled the SFML 2.2, now i tried compiling the Thor files, however only debug was made and i cannot seem to  be able to use it on QT project, as that is my preferred IDE...

18
SFML projects / Re: Thor 2.0
« on: March 03, 2015, 07:17:27 pm »
Sorry for the spam...



But with the way the clang files for 2.2, there is no cmake lists so how would i install it...



There i removed my other comments

19
SFML projects / Re: Thor 2.0
« on: March 03, 2015, 07:09:25 pm »
So i got it to build with Xcode by changing in particle.cpp lines 60-68


float getElapsedRatio(const Particle& particle)
{
        return getElapsedLifetime(particle) / getTotalLifetime(particle);
}

float getRemainingRatio(const Particle& particle)
{
        return getRemainingLifetime(particle) / getTotalLifetime(particle);
}
 


to

float getElapsedRatio(const Particle& particle)
{
        return getElapsedLifetime(particle).asMilliseconds() / getTotalLifetime(particle).asMilliseconds();
}

float getRemainingRatio(const Particle& particle)
{
        return getRemainingLifetime(particle).asMilliseconds() / getTotalLifetime(particle).asMilliseconds();
}
 


So yeah, i don't know if this is an unknown bug (Downloaded straight from github). But something doesn't feel right about doing this


The important thing to know is your version of SFML. Most likely not SFML 2.2, which is the only version that has this operator.

It is 2.1, the issue is that by downloading the clang release of 2.2, there is no cmake file, which makes it impossible to install (at least as far as i know)

20
SFML projects / Re: Thor 2.0
« on: March 03, 2015, 06:53:00 pm »
1 this is Via mac terminal
2 Unix Makefiles
3 Clang is my compiler
4 The code is the build of THOR

21
SFML projects / Re: Thor 2.0
« on: March 03, 2015, 06:48:38 pm »
/Users/****/Downloads/Thor-master/src/Particle.cpp:62:38: error:
      invalid operands to binary expression ('sf::Time' and 'sf::Time')
        return getElapsedLifetime(particle) / getTotalLifetime(particle);
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Frameworks/SFML.framework/Headers/System/Time.hpp:364:22: note:
      candidate function not viable: no known conversion from 'sf::Time' to
      'float' for 2nd argument
SFML_SYSTEM_API Time operator /(Time left, float right);
                     ^
/Library/Frameworks/SFML.framework/Headers/System/Time.hpp:376:22: note:
      candidate function not viable: no known conversion from 'sf::Time' to
      'Int64' (aka 'long long') for 2nd argument
SFML_SYSTEM_API Time operator /(Time left, Int64 right);
                     ^
/Library/Frameworks/SFML.framework/Headers/System/Vector2.inl:131:19: note:
      candidate template ignored: could not match 'Vector2<type-parameter-0-0>'
      against 'sf::Time'
inline Vector2<T> operator /(const Vector2<T>& left, T right)
                  ^
/Users/****/Downloads/Thor-master/src/Particle.cpp:67:40: error:
      invalid operands to binary expression ('sf::Time' and 'sf::Time')
        return getRemainingLifetime(particle) / getTotalLifetime(particle);
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Frameworks/SFML.framework/Headers/System/Time.hpp:364:22: note:
      candidate function not viable: no known conversion from 'sf::Time' to
      'float' for 2nd argument
SFML_SYSTEM_API Time operator /(Time left, float right);
                     ^
/Library/Frameworks/SFML.framework/Headers/System/Time.hpp:376:22: note:
      candidate function not viable: no known conversion from 'sf::Time' to
      'Int64' (aka 'long long') for 2nd argument
SFML_SYSTEM_API Time operator /(Time left, Int64 right);
                     ^
/Library/Frameworks/SFML.framework/Headers/System/Vector2.inl:131:19: note:
      candidate template ignored: could not match 'Vector2<type-parameter-0-0>'
      against 'sf::Time'
inline Vector2<T> operator /(const Vector2<T>& left, T right)
                  ^
2 errors generated.
make[2]: *** [src/CMakeFiles/thor.dir/Particle.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/thor.dir/all] Error 2
make: *** [all] Error 2
****-MacBook-Pro-2:Build gabeorlanski$ cd
 

22
SFML projects / Re: Thor 2.0
« on: March 03, 2015, 06:26:40 pm »
Hello, Im on mac and i have SFML working but wen i try to make the build of thor, i get errors for the build, CMAKE can run fine but the issue comes with making it

23
General / Re: [SOLVED]Error with SFML game development book
« on: February 04, 2015, 03:37:07 pm »
It was weird, the solution i found was to clean and rebuild the thing...idk if there is something i missed

24
General / Re: Error with SFML game development book
« on: February 03, 2015, 05:16:18 pm »
Ah, ok yeah, i manually retyped everything just to understand the code better

Now i get a 2 duplicate symbols error with regards to category.o and command.o

25
General / Re: Error with SFML game development book
« on: February 03, 2015, 02:30:59 pm »
Can you explain in a bit more detail, i have literally just followed the source code + book so i don't know where it could be wrong.

Sorry if this answer/question appeared rude

26
General / [SOLVED]Error with SFML game development book
« on: February 02, 2015, 07:33:50 pm »
So at the end of chapter 4 i get this error when trying to compile. It is in command.hpp that the error is being reported, but it is being called in player.cpp.

Command.hpp
#ifndef COMMAND_HPP
#define COMMAND_HPP

#include "Category.hpp"

#include <SFML/System/Time.hpp>

#include <functional>
#include <cassert>



class SceneNode;

struct Command
{
                                                                                                Command();

        std::function<void(SceneNode&, sf::Time)>       action;
        unsigned int                                                            category;
};

template <typename GameObject, typename Function>
std::function<void(SceneNode&, sf::Time)> derivedAction(Function fn)
{
        return [=] (SceneNode& node, sf::Time dt)
        {
                // Check if cast is safe
                assert(dynamic_cast<GameObject*>(&node) != nullptr);

                // Downcast node and invoke function on it
                fn(static_cast<GameObject&>(node), dt);
        };
}
#endif // COMMAND_HPP

 

Command.cpp:

#include "Command.hpp"


Command::Command()
: action()
, category(Category::None)
{
}

 

Where it is linking in player.cpp
void Player::initializeActions()
{
        const float playerSpeed = 200.f;

        mActionBinding[MoveLeft].action  = derivedAction<Aircraft>(AircraftMover(-playerSpeed, 0.f));
        mActionBinding[MoveRight].action = derivedAction<Aircraft>(AircraftMover(+playerSpeed, 0.f));
        mActionBinding[MoveUp].action    = derivedAction<Aircraft>(AircraftMover(0.f, -playerSpeed));
        mActionBinding[MoveDown].action  = derivedAction<Aircraft>(AircraftMover(0.f, +playerSpeed));
}
 


Source Code for the book:
https://github.com/SFML/SFML-Game-Development-Book

This is from chapter 4


The exact error is:
Command.hpp:32: error: type 'const AircraftMover' does not provide a call operator
                fn(static_cast<GameObject&>(node), dt);
                ^

27
Hello, I was wondering why at certain points, when comparing the downloadable source code to the code i have written, i appear to be missing numerous things. Like in chapter 3:
  • When does the book say to make the resource identifier file?
  • Also, when does it say to make the string helper class?
  • Why does it seem that i am always missing includes and other things that are important?

28
General / Questions on the SFML game development book
« on: January 05, 2015, 08:37:38 pm »
Hello,
I was wondering if anyone could answer any of the following questions that i have about the content in the SFML game development book up until the tiling section in chapter 3:
  • What is the purpose of having SpriteNode class when it basically has the same source code as all other classes?
  • Why does it seem like there is numerous unnecessary explicits and virtual functions that could be avoided?
  • It may have been explained in the book, why is there numerous "Holder" classes that do what appears to be the same thing?

29
General / Re: [SFML 2.1] Sprite animation not playing
« on: December 10, 2014, 02:53:00 pm »
Sorry, i just assumed you had written it. that is my bad...

30
General / Re: [SFML 2.1] Sprite animation not playing
« on: December 10, 2014, 02:20:27 pm »
#include <iostream>
#include <iomanip>
#include <queue>
#include <string>
#include <math.h>
#include <ctime>
#include <SFML/Graphics.hpp>
#include <vector>
#include <memory>
#include <stdlib.h>
#include <stdio.h>
#include "Animation.hpp"
#include "AnimatedSprite.hpp"
#include <chrono>
#include <thread>
using namespace std;
class TileMap : public sf::Drawable, public sf::Transformable
{
public:
 
    bool load(const std::string& tileset, sf::Vector2u tileSize, const int* tiles, unsigned int width, unsigned int height)
    {
        // load the tileset texture
        if (!m_tileset.loadFromFile(tileset))
            return false;
     
        // resize the vertex array to fit the level size
        m_vertices.setPrimitiveType(sf::Quads);
        m_vertices.resize(width * height * 4);
     
        // populate the vertex array, with one quad per tile
        for (unsigned int i = 0; i < width; ++i)
            for (unsigned int j = 0; j < height; ++j)
            {
                // get the current tile number
                int tileNumber = tiles[i + j * width];
             
                // find its position in the tileset texture
                int tu = tileNumber % (m_tileset.getSize().x / tileSize.x);
                int tv = tileNumber / (m_tileset.getSize().x / tileSize.x);
             
                // get a pointer to the current tile's quad
                sf::Vertex* quad = &m_vertices[(i + j * width) * 4];
             
                // define its 4 corners
                quad[0].position = sf::Vector2f(i * tileSize.x, j * tileSize.y);
                quad[1].position = sf::Vector2f((i + 1) * tileSize.x, j * tileSize.y);
                quad[2].position = sf::Vector2f((i + 1) * tileSize.x, (j + 1) * tileSize.y);
                quad[3].position = sf::Vector2f(i * tileSize.x, (j + 1) * tileSize.y);
             
                // define its 4 texture coordinates
                quad[0].texCoords = sf::Vector2f(tu * tileSize.x, tv * tileSize.y);
                quad[1].texCoords = sf::Vector2f((tu + 1) * tileSize.x, tv * tileSize.y);
                quad[2].texCoords = sf::Vector2f((tu + 1) * tileSize.x, (tv + 1) * tileSize.y);
                quad[3].texCoords = sf::Vector2f(tu * tileSize.x, (tv + 1) * tileSize.y);
            }
     
        return true;
    }
 
private:
 
    virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
    {
        // apply the transform
        states.transform *= getTransform();
     
        // apply the tileset texture
        states.texture = &m_tileset;
     
        // draw the vertex array
        target.draw(m_vertices, states);
    }
 
    sf::VertexArray m_vertices;
    sf::Texture m_tileset;
};
int main()
{
    // create the window
    sf::Vector2i map_dim(512,256);
    sf::RenderWindow window(sf::VideoMode(map_dim.x, map_dim.y), "Tilemap");
    sf::Texture texture;
    // window.setFramerateLimit(60);
    if (!texture.loadFromFile("FFSPRITE.gif"))
    {
        std::cout << "Failed to load player spritesheet!" << std::endl;
        return 1;
    }
   
   
   
   
    bool has_clicked = false;
   
    // set up tshe animations for all four directions (set spritesheet and push frames)
    Animation walkingAnimationDown;
    walkingAnimationDown.setSpriteSheet(texture);
    walkingAnimationDown.addFrame(sf::IntRect(47,5, 16,16)    );
    walkingAnimationDown.addFrame(sf::IntRect(65,5,16, 16)     );
    walkingAnimationDown.addFrame(sf::IntRect(47,5, 16,16)    );
   
    Animation walkingAnimationLeft;
    walkingAnimationLeft.setSpriteSheet(texture);
    walkingAnimationLeft.addFrame(sf::IntRect(83,5, 13,16 ) );
    walkingAnimationLeft.addFrame(sf::IntRect(98,5,14,16));
    walkingAnimationLeft.addFrame(sf::IntRect(83,5,13,16));
   
   
    Animation walkingAnimationRight;
    walkingAnimationRight.setSpriteSheet(texture);
    walkingAnimationRight.addFrame(sf::IntRect(150,5, 13, 16) );
    walkingAnimationRight.addFrame(sf::IntRect(165,5,14, 16)  );
    walkingAnimationRight.addFrame(sf::IntRect(150,5,13,16)   );
   
    Animation walkingAnimationUp;
    walkingAnimationUp.setSpriteSheet(texture);
    walkingAnimationUp.addFrame(sf::IntRect(114, 5, 16, 16));
    walkingAnimationUp.addFrame(sf::IntRect(132, 5, 16, 16));
    walkingAnimationUp.addFrame(sf::IntRect(114, 5, 16, 16));
   
   
    Animation* currentAnimation = &walkingAnimationDown;
   
    // set up AnimatedSprite
    AnimatedSprite animatedSprite(sf::seconds(0.2), true, false);
   
    animatedSprite.setPosition(sf::Vector2f(4.0*32.0,7.0*32.0));
    sf::Clock frameClock;
    float currentx = 4;
float currenty = 4;
    float speed = 1.f;
    bool noKeyWasPressed = true;
    // define the level with an array of tile indices
    const int level[] =
    {
        0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
        0, 1, 1, 1, 3, 3, 3, 3, 0, 0, 0, 2, 0, 0, 0, 0,
        1, 1, 0, 0, 3, 0, 0, 3, 0, 3, 3, 3, 3, 3, 3, 3,
        0, 3, 3, 3, 3, 0, 3, 3, 0, 3, 1, 1, 1, 0, 0, 0,
        0, 3, 1, 0, 3, 2, 3, 0, 0, 3, 1, 1, 1, 2, 0, 0,
        0, 3, 1, 0, 3, 0, 3, 2, 0, 3, 1, 1, 1, 1, 2, 0,
        2, 3, 1, 0, 3, 0, 3, 2, 2, 3, 1, 1, 1, 1, 1, 1,
        0, 3, 3, 3, 3, 2, 3, 3, 3, 3, 0, 0, 1, 1, 1, 1,
    };
   
    float y_tileSize = 32.0;
float x_tileSize = 32.0;
int count = 0;
   string route = "445667077012322107666700000";
    // create the tilemap from the level definition
    TileMap map;
    if (!map.load("tileset.png", sf::Vector2u(32, 32), level, 16, 8))
        return -1;
   
    animatedSprite.play(*currentAnimation);
    sf::FloatRect as = animatedSprite.getGlobalBounds();
    // run the main loop
    while (window.isOpen())
    {
       
        sf::Event event;
        char ada;
        int qx;
        if(count < route.length())
        {
            ada = route.at(count);
            qx = atoi(&ada);
            count += 1;
        }
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
            if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
                window.close();
        }
       
        sf::Time frameTime = frameClock.restart();
       
        // if a key was pressed set the correct animation and move correctly
        sf::Vector2f movement(0.f, 0.f);
       
       
        if (qx == 6)
        {
            currentAnimation = &walkingAnimationUp;
            movement.y -= speed;
            noKeyWasPressed = false;
        }
       
        if (qx == 2)
        {
            currentAnimation = &walkingAnimationDown;
            movement.y += speed;
            noKeyWasPressed = false;
        }
       
       
        if(qx == 4)
        {
            currentAnimation = &walkingAnimationLeft;
            movement.x -= speed;
            noKeyWasPressed = false;
        }
       
       
        if (qx == 0)
        {
            currentAnimation = &walkingAnimationRight;
            movement.x += speed;
            noKeyWasPressed = false;
        }
        if (qx == 1)
        {
            currentAnimation = &walkingAnimationDown;
            movement.y += speed;
            movement.x += speed;
            noKeyWasPressed = false;
        }
        if(qx==3)
        {
            currentAnimation = &walkingAnimationDown;
            movement.y += speed;
            movement.x -= speed;
            noKeyWasPressed = false;
        }
        if(qx == 5)
        {
            currentAnimation = &walkingAnimationUp;
            movement.y -= speed;
            movement.x -= speed;
            noKeyWasPressed = false;
        }
        if(qx == 7)
        {
            currentAnimation = &walkingAnimationUp;
            movement.y -= speed;
            movement.x += speed;
            noKeyWasPressed = false;
        }
        animatedSprite.play(*currentAnimation);
       
          bool less_x = animatedSprite.getPosition().x >= currentx*32.0;
        bool great_x = animatedSprite.getPosition().x < (currentx*32.0)+32.0;
        bool less_y =animatedSprite.getPosition().y >= currenty*32.0;
        bool great_y =animatedSprite.getPosition().y < (currenty*32.0)+32.0;
       
        if(great_x == true && less_x == true && great_y == true && less_y == true)
        {
           
            animatedSprite.move(movement*frameTime.asSeconds());
            animatedSprite.update(frameTime);
           
        }
        else
        {
       
            cout << currentx << endl;
            cout << currenty << endl;
            count += 1;
            if(movement.x < 0)
                currentx += -1;
            else if(movement.x > 0)
                currentx += 1;
            else
                currentx += 0;
           
            if(movement.y < 0)
                currenty += -1;
            else if(movement.y > 0)
                currenty += 1;
            else
                currenty += 0;
           
            if(currenty > map_dim.y/y_tileSize)
                currenty = (map_dim.y/y_tileSize)-1;
            else if(currenty < 0)
                currenty = 1;
            if(currentx > map_dim.x/x_tileSize)
                currentx = (map_dim.x/x_tileSize)-1;
            else if (currentx < 0)
                currentx = 1;
           
        }
       
       
        // if no key was pressed stop the animation
        if (noKeyWasPressed)
        {
            animatedSprite.stop();
        }
        noKeyWasPressed = true;
        //animatedSprite.update(frameTime);
        window.clear();
        window.draw(map);
        window.draw(animatedSprite);
       
        window.display();
    }
   
    return 0;
}
Besides the Animated sprite by laurent gomila (https://github.com/SFML/SFML/wiki/Source:-AnimatedSprite) this Is all of the code NEEDED to reproduce the issue.

the point of the current x, currenty stuff is that it is supposed to be a check if they are in a certain tile...

I apologize if it sounds quite rude.

Pages: 1 [2] 3
anything