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.


Topics - masskiller

Pages: 1 [2]
16
General / Combining SFML graphics and OpenGL
« on: September 16, 2012, 07:32:48 am »
From what I've read in the doc, the render window is mainly for SFML stuff, while window is for handling OpenGL. Is there a possible way to use both in the same window? From what I've understood I think not, but I'd like to know for sure. I'd also like to know if this mix (in case it's currently not possible) is planned for future SFML versions or is just something that just cannot be for "x" or "y" reasons.

In case it's currently not possible or not planned in the future is there a reasonable way to implement something that would allow it? My purpose is to have a minimal 3d background while using SFML for 2d management like I've been doing so far. Is it possible or planned?

17
General / [Solved] Consistent speed on trajectory given by a linear function
« on: September 14, 2012, 04:16:44 am »
The problem is not with SFML in general, but rather some logic that I don't know how to implement.
In my project I get an item to get a linear trajectory, and while the trajectory is perfect in mathematical sense, the speed of the sprite is not consistent. I am using an external struct that handles the movements through the main loop until the sprite is out of bounds.

The problem is that as it goes through the given line of movement, the closer the sprite's "x" is to the other point's "x" it's speed becomes less consistent, in other words it goes faster than as if the sprite's "x" was further from the given point's "x". I need a mathematical formula to correct this so that the speed I give my sprite becomes the same for any two points given.

At first I was using an unsigned int which is what was causing the problem, when the "x" difference was too small it just went and drew some few points.

I would give a minimal code example right away, but since for this I have need of many classes and not just a small dependency like with other problems it'll take a while. For now I'll attach two images showing what happens just as a small overview of the issue. 

The images show the output of the positions drawn.
Sample1 shows the furthest possible "x".
Sample2 shows the closest  possible "x".
Both coordinates start with an "x" from 0 to 800.

So the first sprite sample follows slowly through a line and the other just draws three positions and goes out of bounds.

As soon as I have the minimal sample code I'll add it to the post. For now if anyone has an idea of how to make a sprite follow a linear function in the same time and distance regardless of the points of the grid chosen I'm all ears, I have been thinking on alternate ways all day and haven't gotten to anything useful.

Thanks in advance for any help I may get.


[attachment deleted by admin]

18
SFML projects / [Bullet Hell-Game] Origin of Magic
« on: September 14, 2012, 01:55:03 am »
I am bad with names, as soon as I have a good one I'll modifiy it.

My project (and first serious game) is a bullet hell game/danmaku. It's a vertical scrolling shooter game like many others, with the difference that the focus of this genre is difficulty, since the enemy bullets will form patterns that are (most of the times) hard to dodge but tend to make a nice view.

Of course this wasn't entirely my idea, this is mainly based on an already existing game series called touhou.
Here's a video so you can know a bit what it's like in case you don't know touhou:
http://www.youtube.com/watch?v=tzvRI_sWLJs&feature=relmfu

My approach for this genre was to make something similar (in essence) to what the game genre and mainly touhou is, but to modify several gameplay issues, such as the power-up system and a tree-like storyline, in which your choices and score may modify what the story ends up being like and other twists that I will write once I have thought them up better.

The project is currently just starting, mainly on making the engine and learning all the possible math these kinds of games need. Once I finish with that I plan to make the art and the music, but it'll take a while until I start working with something other than the engine. I plan to make commercial games in the future and thought this kind of game would challenge my skills and give me enough experience as to make it as a preparation for a career and game making company in the future.

As I said earlier I have very little progress so currently there is nothing visible, but as I progress I will be uploading my progress. I am no expert programmer either (have around 6-7 months with c++, started with java, but just as a basic learning platform) so I'll be asking for help once my wits give in, but eventually this self-pleasure game will come through.

My current progress in the engine is mainly on math. Having programmed polar vectors and used many functions for spirals, circles and such. What I am working in right now is to make a consistent linear movement system, that is half finished, as I need a mathematical function that allows me to make the speed of all trajectory lines for bullets to be the same given any two points in the grid.

19
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?

20
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. 

21
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 [2]