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

Pages: 1 ... 17 18 [19]
271
Graphics / Re: Fading without artifacts
« on: September 14, 2012, 01:06:16 am »
I don't know well if what I will say applies since I am new to SFML myself and I don't know if you want to do more than just making it fade, but if you want the circle to fade wouldn't decreasing the circle's alpha in the loop be better? You would have no need for a rectangle shape texture the size of the window. You would just need to use a speed for the fading and the loop handles the rest.

272
Graphics / Re: [Solved] SetOrigin function makes the sprite disappear
« on: September 05, 2012, 11:15:52 pm »
I didn't read that last part well it appears, I just made the wrong assumption that the new origin was set in the given position and it didn't move the object in an offset, which is why I was so confused with what was happening. I did know that the origin was (and is) the center for all transformations, but I read other parts of the documentation and didn't touch the sf::Transformable part. In the end it was all too simple.

I tend to use solved threads to make small questions so I'll go ahead.

I've been reading about polar coordinates and they look pretty useful for what I am trying to do and many other things surely, so far I know SFML hasn't support for them, since it's something complementary and not strictly necessary. So my question is: Where can I find a library that has them or a way to implement them myself? I have read little and I am still investigating, but if you have a suggestion of where should I start it would be very good.

273
Graphics / Re: SetOrigin function makes the sprite disappear
« on: September 04, 2012, 10:25:24 pm »
I finally understand. I thought that the function worked entirely different and the documentation hadn't any details so I made myself an entirely different mind image of it. Thanks for the help.

274
Graphics / Re: SetOrigin function makes the sprite disappear
« on: September 04, 2012, 08:58:57 pm »
Do other sprites appear?
Also, what class/type is that:
index x = -25

I forgot to add that, it's just a typedef for short int, I use it for any number I may use as an index of some sort.
And other sprites do appear, the one that isn't shown is the one whose origin is set.
I'll attach the image and other than the image and the index variable there is nothing left out that you may need to run it.

I just noticed but I should have used:
index x = -r

instead of:

index x = -25

Since in order to make it a semi-circular function it has to have a domain from -r to r, where r is the radious. Just as a small side-note in case it is needed.

Edit: Here's the code:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(400, 400), "SFML works!");
    sf::CircleShape shape(10.f);
    shape.setOrigin(100 , 100);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

What happens is that with just using the function setOrigin (this time in a Circle Shape) the image is not shown, if I remove the line it is properly shown, else it's just a black screen. The same happens when I use an image, I may have made the explanation at first complicated, but that's the summary of what's happening.

[attachment deleted by admin]

275
Graphics / Re: SetOrigin function makes the sprite disappear
« on: September 04, 2012, 07:33:10 pm »
It doesn't, that's why I made the thread.

276
Graphics / Re: SetOrigin function makes the sprite disappear
« on: September 04, 2012, 07:16:04 pm »
So what I would need to do before setting it's position is to set the origin of the given sprite in the point I want it to be displayed, then do something like this:

Sprite.setOrigin(400, 300);
Sprite.setPosition(Sprite.getOrigin());
 

Which I already did, to get nothing. The sprite doesn't even appear if I do this. Everytime I set the origin to something the sprite doesn't appear, whether I move it afterwards or not.

I know what the origin is and that it's used to affect transformations done after being told that it had a new origin and I intend to do that, so that it moves my sprite in a circular fashion around the given origin. That is my intention. I know that it will not mantain it's position, so my problem is not that, but rather it is that it doesn't move according to the origin set. in fact it doesn't even appear at all if I use the setOrigin function.

I didn't quite get your post so I did what I thought you told me to and tried to re-explain.

And the reason I am also blaming my graphics card is because of this:
http://en.sfml-dev.org/forums/index.php?topic=6696.msg44048

277
Graphics / [Solved] SetOrigin function makes the sprite disappear
« on: September 04, 2012, 05:51:41 pm »
I searched in the forums and found someone with a similar problem, but I'd like to know the details. Everything is drawn properly and it even moves according to the semi-circle function I am using, but when I set origin to (400, 300) and run it, the sprite disappears, as if it had not even been drawn or displayed in the first place.

I've checked my code over and over, but found nothing wrong in it, it just goes mad when I set the origin, I'll post it just in case, but I doubt it's that.

int main()
{ ///Test to learn how to draw individual bullets
   sf::RenderWindow window(sf::VideoMode(800, 600), "Bullet Testing");
   sf::Event event;
   sf::IntRect d;
   sf::Image img; img.loadFromFile("Images\\Bullets\\HQtest.jpg");
   img.createMaskFromColor(sf::Color::Black, 0);
   sf::Texture Img;
   Img.loadFromImage(img, d);
   Img.setSmooth(true);
   sf::Sprite Sprite;
   sf::Sprite Sprite2;
   sf::Sprite Sprite3;
   Sprite.setTexture(Img, true); Sprite2.setTexture(Img, true); Sprite3.setTexture(Img, true);
   Sprite.setColor(sf::Color(255, 255, 0, 200));
   Sprite2.setColor(sf::Color(255, 0, 255, 200));
   Sprite3.setColor(sf::Color(0, 255, 255, 200));
   Sprite.setPosition(400, 300);
   Sprite2.setPosition(110, 0);
   Sprite3.setPosition(120, 0);

window.setFramerateLimit(60);
///For the circle function.
index x = -25; const short int r = 25;

    ///Game loop.
    while (window.isOpen())
    {   // check all the window's events that were triggered since the last iteration of the loop
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }
        window.clear();

        window.draw(Sprite); window.draw(Sprite2); window.draw(Sprite3);
        Sprite.setOrigin(400, 300);
        if (x <= r )
        { Sprite.setPosition(x, sqrt((r * r) - (x * x))); ++x; }
     
        window.display();
    }
    }
    return 0;

}

Edit: Just made some tests only to find myself even more baffled than before, if I remove the if that handles the sprite's movement it actually appears, but at position (0, 0), if I remove the setOrigin function it properly appears at the center of the renderwindow. Is this all due to my graphics card or is there actually something wrong with the code?

278
General discussions / Re: I forgot to introduce myself here
« on: September 03, 2012, 10:58:04 pm »
Pretty much like myself, excepting I don't expect to commercialize my first game. For now I am doing everything including art and music on my own and trying to make a bullet hell game with some RPG and puzzle characteristics.

Though I am quite new myself, welcome to the forums.

279
Graphics / Re: [Solved] Image not drawn on render window
« on: September 01, 2012, 04:26:09 pm »
Ok thanks, btw nice Iku avatar def8x.

280
Graphics / Re: Image not drawn on render window
« on: September 01, 2012, 12:18:40 am »
The output was a successful run. I used an 8-bit psd (which is the supported type of psd), I also tried with a png to have nothing change.

I'll attach both images in this post.

Edit: The forum apparently doesn't allow me to upload the psd, so I just uploaded the png I used to test wether it was the file type or something other than that.

Re-edit: Earlier I tried the png file and nothing happened. I just tried and it did appear the way it should have. I'll try saving the psd into another type and try again.

It did appear after I saved the psd as a jpg. I think I remember now why it didn't work at first. When I wrote it I didn't write the window.display(), I feel stupid now, but at least it's working. If I hadn't made this post I propably wouldn't have rechecked. Thanks and sorry for the inconvenience.

I know this post looks bad with so many edits, but I have another noob question that I think doesn't deserve a thread: How do I cut the extra background pixels from the image? What I want is a clean circle/bullet and the white background behind it is annoying. Would doing it with SFML be better than doing it with another software?

[attachment deleted by admin]

281
Graphics / [Solved] Image not drawn on render window
« on: August 31, 2012, 11:46:56 pm »
This is my code:

int main()
{ ///Test to learn how to draw individual bullets
   sf::RenderWindow window(sf::VideoMode(800, 600), "Bullet Testing"); ///Es necesario usar RenderWindow para dibujar algo.
   sf::Event event;
   sf::Texture Img;
   Img.loadFromFile("S_Circle.psd");
   sf::Sprite Sprite;
   Sprite.setTexture(Img, true);
   Sprite.setColor(sf::Color(255, 255, 255, 200));
   Sprite.setScale(2.f, 2.f);
   Sprite.setPosition(100, 25);

    while (window.isOpen())
    {  
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        window.clear();
        window.draw(Sprite);
        window.display();
    }
 return 0;
}
 

What I am trying to do is to call a 16x16 pixels photoshop file, the depth is 8 bits, therefore supported by SFML, but nothing is visible, the screen remains black as if I hadn't used the draw method. I've added more sets and even put them within the loop in the hope that it would change anything, but so far nothing has happened.

As there have been some changes between how you do things in 1.6 and 2.0rc, the 1.6 tutorial hasn't been much help in other than giving the base structure for the code and there aren't any graphics tutorials yet for 2.0rc, I've read the documentation over and over only to see if it was that I was omitting something, but haven't found anything noticeable so far.

I have drawn and made shapes visible, but this is my first time trying with a sprite and an external file. I use Code::Blocks. The image loads correctly, getting no compatibility problem message and the return is 0.

I'm not even trying to make the image move or anything for now, just make the image visible in the render window. But having read most of documentation of the classes I am using I still don't know what's wrong.

Thanks in advance for the help I may get. 

282
Window / Re: Window Tutorial on OpenGL Issues [Solved]
« on: August 28, 2012, 06:21:42 pm »
I should take your advice then. I have knowledge of linear algebra, but mainly on the 2d side and I just began chose between SFML and SDL because I've read SFML is easier to understand and it's as good as SDL is, and even better in some aspects. I have no experience programming games or anything beyond the beginner-intermediate university scope. In fact someone I asked already stopped me from inmediately delving into directX and adviced me to start with something of a higher level before trying to clash with it. I have good coding skills in general, but I am completely new to programming games and highly graphic applications so I think I'll be posting in the help forum pretty often.

283
Window / Re: Window Tutorial on OpenGL Issues
« on: August 28, 2012, 04:36:07 am »
Good to know, I just began with 1.6 since it's the stable version. Thanks for the answer.

284
Window / Window Tutorial on OpenGL Issues [Solved]
« on: August 28, 2012, 02:46:53 am »
As the title and my amount of posts should make clear I am very new to SFML. (started 4 days ago)
Currently using the C++ sdk. I have around 6-7 months of experience with C++ so I am still unaware of many things within the language, but have gotten used to it already.

When I try to use the OpenGL instructions I get undefined references to each method from the compiler.
I use Code::Blocks with the latest GCC compiler and followed and linked everything it said to be linked in the project's options.

This is my source code:

#include <SFML/System.hpp>
#include <SFML/Window.hpp>
//Window Hpp incluye a Event.hpp y a otras clases, si estas estan en el paquete no es necesario incluirlas.
#include <SFML/System/Randomizer.hpp>
#include <iostream>

int main ()
{   sf::WindowSettings Settings; /// Objeto WindowSettings, permite configurar las opciones graficas deseadas.
    ///Todas tienen valores default, por lo tanto no es necesario revalorizar dichas opciones.
    Settings.DepthBits         = 24; // Request a 24 bits depth buffer
    Settings.StencilBits       = 8;  // Request a 8 bits stencil buffer
    Settings.AntialiasingLevel = 2;  // Request 2 levels of antialiasing
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL", sf::Style::Close, Settings);
    ///Crea los datos de la ventana al final y usa las configuraciones dadas por el objeto settings.

/** Aqui empieza el codigo de OpenGL usando como plataforma a SFML*/
    // Set color and depth clear value
    glClearDepth(1.f);
    glClearColor(0.f, 0.f, 0.f, 0.f);

// Enable Z-buffer read and write
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);

// Setup a perspective projection
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90.f, 1.f, 1.f, 500.f);
}

Please ignore the extra comments I added. My native language is spanish and I tend to write lots of stuff when trying to understand how and what a library does what it does. Also it may seem odd that I have other includes that aren't used in the quoted source code, but it is because there are more implementations of the main function unseen by the compilator via precompilator #if's so as to put everything in the same project and not make many projects for small code examples.

From my understanding and what I have read including window.hpp should be enough to use those functions, but none is recognized. I am compiling in release mode and tried putting every single dll into the project's folder but it changed nothing (only had the window and the system dll's before that).

I think I've given enough info about my issue, however if anything else would be needed I'll gladly add anything I can. Thanks in advance for any possible help I could get.

P.S. I get undefined reference error for the gl functions only. I'll attach the cbp file in case the problem is within the project's settings (searched for such a mistake, but so far found none).

[attachment deleted by admin]

Pages: 1 ... 17 18 [19]
anything