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

Pages: [1]
1
SFML projects / Re: Screenshot Thread
« on: May 19, 2016, 06:45:44 am »
Been working on this RPG/Robotron-esque hybrid.






2
Graphics / Re: Issues displaying sprites after Xcode 5.1 update
« on: April 01, 2014, 12:06:54 am »
A major detail I was unaware of. Thanks! i'll definitely keep that in mind.

3
Graphics / Re: Issues displaying sprites after Xcode 5.1 update
« on: March 30, 2014, 01:16:57 am »
Gotcha ... I assumed it was automatically initialized to '0' when declaring without initializing. I was using GCC before the update so that makes sense. Thanks!

4
Graphics / Re: Issues displaying sprites after Xcode 5.1 update
« on: March 29, 2014, 11:30:33 pm »
After creating a small example I couldn't recreate the problem, so I knew it had to be something in my code – after a while I figured it out. Xcode didn't like me creating the variable for the frame uninitialized (I had 'int frame' as opposed to 'int frame = 0'); it was setting it to some crazy numbers sometimes, thus displaying frames that didn't exist. This was never a problem before so I guess i'll just have to keep this in mind from now on. If anyone has any insight on this, that be great. Otherwise, thanks for reading guys.

5
Graphics / Re: Issues displaying sprites after Xcode 5.1 update
« on: March 27, 2014, 02:27:01 pm »
Sure thing, sorry about that – i will post an example later as I'm at work now.

Yeah, my object container uses smart pointers, been meaning to change the textures. Thanks for the reminder/heads up.

6
Graphics / Re: Issues displaying sprites after Xcode 5.1 update
« on: March 27, 2014, 04:31:28 am »
Just so happened to comment out the code which animates the bullets and the texture doesn't fail as long as it doesn't change frame? This is sort of weird since the player and enemy are animated the same way ... Here is the projectile update() function which animates the bullet (all objects are in a container, which calls their update function to move, animate, etc). I blocked out the animation portion:

void Projectile::Update(Level::LevelContainer& Lvl, Textures::TextureContainer& tbox, Container& PC)
    {
       
        sf::Time time = clock.getElapsedTime();
        sf::Time frameChange = sf::milliseconds(30);
       
       
Animating------------------------  
     
        if(time >= frameChange)
        {
           
           
            Object::objectSprite.setTextureRect(sf::IntRect(frame * 25, 0, 25, 8));
            frame++;
            time = clock.restart();
           
            if(frame == 3)
            {
               
                frame = 0;
               
            }
           
        }

------------------------

       
        if(velX < 0)
        {
           
            objectSprite.setTextureRect(sf::IntRect(25, 0, -25, 8));
           
           
        }
       
        objectSprite.move(velX,0);
       
       
        if(objectSprite.getPosition().x >= 400 || objectSprite.getPosition().x <= 100)
        {
           
            for(int i = 0; i < 15; i++)
            {
               
                itemQueue particles;
                particles.iposX = objectSprite.getPosition().x;
                particles.iposY = objectSprite.getPosition().y;
                particles.itemType = "Particle";
                PC.Queue.push_back(particles);
               
            }
           
            itemQueue bomb;
            bomb.iposX = objectSprite.getPosition().x;
            bomb.iposY = objectSprite.getPosition().y;
            bomb.itemType = "Cluster";
            PC.Queue.push_back(bomb);
           
            Object::misDestroyed = true;
           
        }
       
    }
 

7
Graphics / Issues displaying sprites after Xcode 5.1 update
« on: March 27, 2014, 04:25:12 am »
I can't figure this out for the life of me – my project was 100% fine until after installing the new templates (w/ clang). My project wouldn't build after the Xcode 5.1 update released a few weeks ago – through research I found that I had to recreate my project and through frustration I simply did that by recreating the files and pasting the code into a command line template project. Now I am having an issue with (some) sprites displaying.

Example: My player fires a bullet. Sometimes the texture is loaded to the bullet, sometimes it is not (white square), sometimes it is a gray line (?).

Here is a gif to show you exactly what I'm referring to:



the blinking spike is the texture that should be loaded ... as you can see, the texture is sometimes failing to load. I have other sprites, such as the player and enemy which don't fail at all:



I'm using a Textures class which holds a container for all the sprites to retrieve as reference:

Textures.h
namespace Textures
{
   
    struct TextureObject
    {
        std::string t_name;
        sf::Texture t_texture;
       
    };
   
    class TextureContainer
    {
       
    public:
        void AddTexture(std::string textureFile);
        void TextureList();
        TextureContainer();
        sf::Texture& SetTexture(std::string temp_name);
        std::vector<TextureObject*> textureVector;
       
    };
   
    typedef std::vector<TextureObject*> ::iterator textureIter;
   
   
}

 

Textures.cpp
#include "Textures.h"
#include "ResourcePath.hpp"


namespace Textures{
   
    void TextureContainer::AddTexture(std::string textureFile)
    {
        TextureObject* newTexture;
        newTexture = new TextureObject;
        newTexture->t_texture.loadFromFile("/Users/darionmccoy/Desktop/Dooberry/Platformer/Platformer/" + (textureFile));
        newTexture->t_texture.setSmooth(false);
        newTexture->t_name = textureFile;
        textureVector.push_back(newTexture);
       
    }
   
    void TextureContainer::TextureList()
    {
        std::cout << "Loaded textures ..." << std::endl;
       
        for (textureIter it = textureVector.begin(); it != textureVector.end(); it++)
        {
            std::cout << (*it)->t_name << std::endl;
           
        }
       
       
    }
   
    TextureContainer::TextureContainer()
    {
       
        AddTexture("block.png");
        AddTexture("spike.png");
        AddTexture("icon.png");
        AddTexture("blip.png");
        AddTexture("blip_2.png");
        AddTexture("blip_3.png");
        AddTexture("bomb.png");
        AddTexture("bomb_2.png");
        AddTexture("smoke.png");
        AddTexture("Pplayer.png");
        AddTexture("cluster.png");
        AddTexture("polygon.png");
        AddTexture("circle.png");
        AddTexture("grunt.png");
        TextureList();
       
    }
   
   
    sf::Texture& TextureContainer::SetTexture(std::string temp_name)
    {
        for (textureIter it = textureVector.begin(); it != textureVector.end(); it++)
        {
            if((*it)->t_name == temp_name)
            {
                return (*it)->t_texture;
            }
           
            else if(it == textureVector.end() && (*it)->t_name != temp_name)
            {
                std::cout << "Texture not found" << std::endl;
            }
        }
       
       
    }
   
   
   
}
 

Example of how the texture is set (the bullet):
Projectile::Projectile(Textures::TextureContainer& t_container) : Object (t_container)
    {
       
        Object::objectSprite.setTexture((t_container.SetTexture("spike.png")));
        Object::objectSprite.setTextureRect(sf::IntRect(0, 0, 25, 8));
       
    }
 

And the enemy:
Grunt::Grunt(Textures::TextureContainer& t_container) : Object (t_container)
    {
       
        objectSprite.setTexture((t_container.SetTexture("grunt.png")));
        objectSprite.setTextureRect(sf::IntRect (0,0,20,30));
        objectSprite.setPosition((rand() % 300 + 100),0);
    }
 

I would think it is a constructor issue, but I am at a loss what to change since they are all  initialized the same way (polymorphism).

I have 0 errors or warnings. Also, I'm on Osx 10.9.2 and Xcode 5.1. Thanks in advanced guys ... in the meantime, I'll try to get some clues.

8
Graphics / Re: SFML Book – An interacting world chapter
« on: January 29, 2014, 10:45:37 pm »
Got it, now I understand. Thanks a lot.

9
Graphics / SFML Book – An interacting world chapter
« on: January 29, 2014, 06:08:33 pm »
I am reading the SFML development book and have a question regarding the "An interacting world" chapter and the section which focuses on cleanup.

Quote
The removal is performed by the following method. In the first part, std::remove_if() rearranges the children container, so that all active nodes are at the beginning and the ones to remove at the end. The call to erase() actually destroys these SceneNode::Ptr objects ...

Why is remove_if() used to rearrange the children container, separating active nodes and ones to be removed? What benefit or security (if there is one) comes with reorganizing the container? This isn't exactly explained why this is done versus another method (i.e. why wouldn't we just mark and remove each object in its original position, rather than organizing the container? ), but seems very specific. Is the method used in the book a standard or is this the only possible solution to managing your objects with a container?

10
Graphics / Re: Undefined symbols error when calling functions
« on: December 27, 2013, 04:12:43 am »
Egghh ... hated to be that guy. Thank you, Laurent.

11
Graphics / Undefined symbols error when calling functions
« on: December 26, 2013, 09:40:10 am »
I'm a beginner testing out manipulating sprites by testing the code from http://sfml-dev.org/tutorials/1.6/graphics-sprite.php Besides the use of texture instead of image, it is a direct copy/paste.

class Missile
{
    public :
   
    static bool Init(const std::string& ImageFile)
    {
        return Texture.loadFromFile(ImageFile);
    }
   
    Missile()
    {
        Sprite.setTexture(Texture); // every sprite uses the same unique image
    }
   
    private :
   
    static sf::Texture Texture; // shared by every instance
   
    sf::Sprite Sprite; // one per instance
};
 

And calling if through a statement in the game loop ...

if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Space)
            {
                Missile Bullet;
                Bullet.Init("spike.png");
               
            }
 

The class definition is fine, but once I call it, I receive this error:

Undefined symbols for architecture x86_64:
  "Missile::Texture", referenced from:
      Missile::Init(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in main.o
      Missile::Missile() in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

 

Searching around for solutions, I attempted to add the class name before the function prototypes/definitions (static bool Missile::Init(const std::string& ImageFile)) even though it is inside the class already .... of course I get an extra qualification error. Is this a linker issue? I am using mac OSX 10.8, Xcode 5.

Thanks in advance for the help, it is very much appreciated.

12
Window / Re: Window won't launch
« on: December 22, 2013, 04:31:45 am »
Ehh, he is using Visual Studio on windows os is what I meant to say ... I am using Xcode on a mac.

Yeah, looks like the code just works differently on mac, because his program ran until it received user input. Thanks.

13
Window / Re: Window won't launch
« on: December 19, 2013, 06:55:48 pm »
I see. The code from the template does work. I am following a lecture online and the programmer is using visual basic c++ on windows  ... hes using that exact code and his window opens up and closes until a key is pressed; will it function differently on windows vs. mac/xcode?

Thank you!

14
Window / Window won't launch
« on: December 17, 2013, 07:41:03 am »
Beginner testing out RenderWindow. When I run the build, the app icon continues to jump up and down but never actually launches. I assume from the code that a blank window should be shown until it recieves user input? I'm using Xcode 5.0.1 ... the Xcode 5 template runs just fine, even when pasting that same code into my project.

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


int main()
{
    sf::RenderWindow window(sf::VideoMode(800,600),"SFML Game");
    std::cin.get();
    return 0;
   
}

Pages: [1]
anything