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

Pages: 1 [2] 3
16
Graphics / Re: Updating a sprite sheet animation
« on: June 24, 2014, 10:27:02 pm »
Ever considered Thor? :D Its animation modules already take care of all this for you, and it's built on top of SFML.

17
So far, it has happened to all Windows XP (and Windows 7 Starter) users to whom I have shared releases of my game: the .png files are opened, but SFML either isn't able to load it, or it is technically loaded (in that SFML doesn't complain of errors) but the Texture is left a blank.

Unfortunately, I haven't been able to trace the error further from "SFML is acting weird" because I don't have Windows XP myself, I use Windows 8. Running the .exe with Compatibility Mode here works just as fine for me as without, so I cannot even "pretend" that I have Windows XP. I compile my game with gcc 4.7 on CodeBlocks and from there I just share the .exe and data files with whomever it is needed through .rars.

I at first suspected that it's a problem of incompatibility between OS's, but there are times in which the Textures work as expected in their computers. I wish I could provide more information, but as I said, I don't have exactly the environment for debugging this. :-\ I just want to know, for now, if there have been developers with similar problems here. But maybe, later, I can provide excerpts of code demonstrating the problem. It's just that I can't just press F9 and check it it simulates the conditions, I have to send the program to a friend to truly check it!

And before anyone mentions that Windows XP has been discontinued... I'm afraid that these issues might manifest themselves when porting my games to other platforms, even if I put Windows XP aside.

18
SFML projects / Re: Feedback wanted - Simple Gravity Game.
« on: June 15, 2014, 10:29:50 am »
Ha, neat concept! Though I've seen it before, I'll still compliment on your originality, mainly in regards to the artistic style on how it's so simplistic and effective, reflects well the gameplay.

Did you think about making it so that the player can see what was his last move? Sort of like in Angry Birds, where your last shot is represented by an arc showing how it went. You could make a "hard mode" button that disables it. I just found the first demo kind of frustrating without it, but I eventually made it into the small square in both versions. ;D

19
SFML projects / Re: Thor 2.0
« on: June 02, 2014, 03:37:20 am »
Ever thought about adding "clamp" functions to the VectorAlgebra libraries, Nexus? :)

template <typename T>
void clamp(sf::Vector2<T>& vector, T maxLength)
{
        if (squaredLength(vector) > std::pow(maxLength, 2))
        {
                auto angle = polarAngle(vector);

                vector.x = maxLength;
                vector.y = 0;

                setPolarAngle(vector, angle);
        }
}

template <typename T>
sf::Vector2<T> clamped(const sf::Vector2<T>& vector, T maxLength)
{
        sf::Vector2<T> copy = vector;
        clamp(copy, maxLength);

        return copy;
}

This is the piece of code that I've added to the library to suit my needs. Just thought I'd comment. :y

20
SFML projects / Re: Eleutheromania - 2D RPG - Work in progress
« on: May 29, 2014, 03:01:23 am »
Hey, Sleepless! First, I would like to compliment on your game. Though I will admit that, as with others, the graphics don't really suit my tastes, I'd say that the general design, layout and flow of the game is very pleasing to the eye. Good job.  :D

But now, allow me to curiously ask: why are you writing your own level editor? I'm using Tiled for my project, which is free and powerful, and I'd say that it does the job flawlessly, it saved me a lot of time I would have spent writing my own editor. Is it because of the isometric view (which I think Tiled maybe does not have)? For scripting the entities? :0

21
You could pre-render your level with a sf::RenderTexture and sf::Sprite combo, Terminator.  :) Like so:

class Level : public sf::Drawable {
        public:
                std::vector<Tile> m_tiles;
               
                sf::RenderTexture m_renderer;
                sf::Sprite m_preRendered;
               
                // ---
               
                sf::Vector2u getSize() const;
               
                Level::Level() {
                        // insert tiles into m_tiles
                       
                        m_renderer.create(getSize());
                        m_preRendered.setTexture(m_renderer.getTexture());
                       
                        for (Tile& tile: m_tiles) {
                                m_renderer.draw(tile);
                        }
                }
               
                void draw (sf::RenderTarget& tar, sf::RenderStates states) const {
                        tar.draw(m_preRendered, states);
                }
};

If you want your level to have, for example, moving platforms, or tiles that fall upon being stepped on, make them separate entities. If you want something almost Worms-like and want any of your tiles to be destructible, you could make it so that fixed portions of your level (with the altered Tile) are re-rendered, or something else.

22
Graphics / Re: Screen starts flickering when on fullscreen
« on: April 05, 2014, 01:21:21 am »
Bumping this in case anyone ever comes across the same problem and bumps into my topic, so that this future internet wanderer isn't let saddened that his problem was left never answered:

This problem is caused by using an invalid VideoMode, simple as that. Using 64 bits per pixel without even checking if it was appropriate was a bad hack of mine to achieve the following:

In 32bpp the fullscreen automatically stretches whatever is rendered to fit the screen. In 64bpp, no scaling whatsoever is done. I prefer to leave it at 64 because then I can manually scale properly the game's graphics so that everything fits the screen while maintaining a 1:1 ratio to the original image.

I was pretty much getting to what I wanted by deliberately triggering an error. That'd be pretty hardcore, if it didn't actually have any side-effects.

If you want to do this, just create a screen with sf::VideoMode::getDesktopMode(); that's what it is for, after all.

EDIT: My assumptions were wrong, the error persists! Sorry, future internet wanderer.

23
Graphics / Re: Proper way of moving an image atlas.
« on: March 11, 2014, 12:57:40 am »
I think that what you need is sf::View. Here's how you use them: http://www.sfml-dev.org/tutorials/2.0/graphics-view.php

It will enable you to move the "world" without having to move any singular entity. If you want your player to move, or any other entity, just move it, and don't care about anyone else's movement - everything regarding the "whole image" should be taken care by the View.

24
Graphics / Re: Diagonal views
« on: March 10, 2014, 12:57:59 am »
This is what I thought at first glance (no code):

* Have two RenderTextures, two Views and two Sprites for each player.
* Both Views, which you will use to follow the players, should have the same rotation.
* The Sprites should have their textures' set to the RenderTextures' textures.
* Place one of the Sprites right below the other (sprite2.setPosition(0, sprite1.getGlobalBounds().height))

* Have a third RenderTexture (or draw straight to your window) and a third View.
* This third View should have the same rotation of the previous Views.
* Position the third View to the middle of the two sprites (view3.setCenter(sprite1.getGlobalBounds().width / 2.f, sprite2.getPosition().y))
* Don't forget to set our third RenderTexture's view to this third View.

* Then you have renderTexture1 draw player 1, renderTexture2 draw player 2, and renderTexture3 draw renderTexture1 and 2 through sprite1 and sprite2.

 ;)

25
Graphics / Re: Screen starts flickering when on fullscreen
« on: March 07, 2014, 01:37:05 am »
In 32bpp the fullscreen automatically stretches whatever is rendered to fit the screen. In 64bpp, no scaling whatsoever is done. I prefer to leave it at 64 because then I can manually scale properly the game's graphics so that everything fits the screen while maintaining a 1:1 ratio to the original image.

26
Graphics / Re: Screen starts flickering when on fullscreen
« on: March 07, 2014, 01:07:01 am »
Alright, I have managed to isolate the bug. Let's see if this code reproduces the behaviour in anyone else's computer.

int main() {   
        sf::RenderTexture m_pauseTex;
        sf::Sprite m_pauseScreen;

        sf::Font corbel;
        if (!corbel.loadFromFile("data/fonts/corbel.ttf")) return 0; // Might want to change the filename

        {

        static const auto windowWidth = 640;
        static const auto windowHeight = 480;

        static const float separation = 3.5f;
        static const unsigned char white = 160;

        sf::Text continueText("Continuar", corbel, 24);

        // continueText.setColor(sf::Color::White);
        auto continueLocal = continueText.getLocalBounds();
        auto continueBounds = continueText.getGlobalBounds();
        continueText.setPosition(
                windowWidth / 2 - continueBounds.width / 2.f - continueLocal.left,
                windowHeight / 2 - continueBounds.height - continueLocal.top - separation);

        sf::Text quitText("Sair", corbel, 24);

        // quitText.setColor(sf::Color(white, white, white));
        auto quitLocal = quitText.getLocalBounds();
        auto quitBounds = quitText.getGlobalBounds();
        // quitText.setPosition(
                // windowWidth / 2 - quitBounds.width / 2.f - quitLocal.left,
                // continueText.getPosition().y + continueLocal.height + separation);

        sf::Text disclaimerText("O jogo está pausado", corbel, 24);
        disclaimerText.move(5, 0);

        m_pauseTex.create(640, 480);
        m_pauseTex.setSmooth(true);

        m_pauseTex.clear(sf::Color(0, 0, 0, 160));

        m_pauseTex.draw(disclaimerText);
        m_pauseTex.draw(continueText);
        m_pauseTex.draw(quitText);

        m_pauseTex.display();

        m_pauseScreen.setTexture(m_pauseTex.getTexture());

        }
       
        sf::RenderWindow window(sf::VideoMode(640, 480, 64), "", sf::Style::Fullscreen);

        while (window.isOpen()) {
                sf::Event event;
                while (window.pollEvent(event)) {
                        switch(event.type) {
                                case sf::Event::Closed:
                                        window.close();
                                        break;
                        }
                }

                window.clear(sf::Color::White);
                window.draw(m_pauseScreen);
                window.display();
        }
}

I have only tested Corbel and Arial, but apparently it is independent of the font used.

27
Graphics / Re: Screen starts flickering when on fullscreen
« on: March 06, 2014, 05:48:32 am »
Framerate limit set to 40FPS, and vertical sync set to false. But the bug is present as well when framerate is set to 0 (unlimited) and/or vertical sync is enabled.

28
Graphics / Screen starts flickering when on fullscreen
« on: March 06, 2014, 04:11:24 am »
This is hard to explain. Whenever my game goes fullscreen, whatever is being drawn by the main RenderWindow gets erased patches over it, in a pattern. The following drawing illustrates what would happen if my window was drawing a sprite with a black background and a red smile, if the window had a 64 bits per pixel depth VideoMode (so that the sprite could be centered in such a way) and was calling clear(sf::Color::White).



The patterns go up and down through the sprite, but in a low framerate, it appears to be rather appearing in random spots through it.

These patterns only show up when I call clear() for the RenderWindow every tick. If I don't, no patterns show up, but the game still runs "choppy". I suspect that my window is skipping one every two frames.

Everything runs perfectly when windowed.

I can show some code if the community would like, but I would rather first have some insight of what could be the possibilities. It's somewhat messy code. Can a missing .clear() call have such an effect? .display()? As in, does this have any relation to double-buffering? Has anyone even seen this before?

---

edit:

Apparently, this was the excerpt of code that was making everything go haywire:

{

                        static const float separation = 3.5f;
                        static const unsigned char white = 160;

                        sf::Text continueText("Continuar", lib::defaultFont(), lib::defaultFontSize());
                       
                        // continueText.setColor(sf::Color::White);
                        // auto continueLocal = continueText.getLocalBounds(); /*1*/
                        // auto continueBounds = continueText.getGlobalBounds(); /*1*/ /*2*/
                        // continueText.setPosition(
                                // windowWidth / 2 - continueBounds.width / 2.f - continueLocal.left,
                                // windowHeight / 2 - continueBounds.height - continueLocal.top - separation);
                               
                        sf::Text quitText("Sair", lib::defaultFont(), lib::defaultFontSize());

                        // quitText.setColor(sf::Color(white, white, white));
                        // auto quitLocal = quitText.getLocalBounds(); /*3*/
                        // auto quitBounds = quitText.getGlobalBounds(); /*3*/ /*2*/
                        // quitText.setPosition(
                                // windowWidth / 2 - quitBounds.width / 2.f - quitLocal.left,
                                // continueText.getPosition().y + continueLocal.height + separation);

                        sf::Text disclaimerText(L"O jogo está pausado", lib::defaultFont(), lib::defaultFontSize());
                        disclaimerText.move(5, 0);
                       
                        m_pauseTex.create(windowWidth, windowHeight);
                        m_pauseTex.setSmooth(true);
                       
                        m_pauseTex.clear(::pausedBlack);
                       
                        // m_pauseTex.draw(disclaimerText);
                        // m_pauseTex.draw(continueText);
                        // m_pauseTex.draw(quitText);
                       
                        m_pauseTex.display();

                        m_pauseScreen.setTexture(m_pauseTex.getTexture());
                       
                        } // This block (and subsequent deaths of the Texts) isn't actually necessary, as the bug shows up even if the following 'while' is right below the m_pauseScreen.setTexture above.

Variables with the m_ prefix are indeed member variables. m_pauseTex is an sf::RenderTexture and m_pauseScreen is an sf::Sprite.

lib::defaultFont() returns a const sf::Font& reference to a font stored in static resources. lib::defaultFontSize() returns a simple int.

This m_pauseScreen is drawn every tick by something as simple as:

while (m_window.isOpen()) {
    sf::Event event;
        while (m_window.pollEvent(event));
       
        m_window.clear();
        m_window.draw(m_pauseScreen);
        m_window.display();
}

The error shows up whenever I uncomment any of the line combinations with the numbers. For example, if I uncomment only the two lines with that /*1*/, the error would show up. If I uncommented only the two lines with the /*2*/ in the end, the error would show up as well. Same for /*3*/

In the end, it's all because of calls to sf::Text::getLocalBounds() and getGlobalBounds(). I haven't yet nailed what exactly causes the problem, and I don't think I'd even be able to. I knew sf::Text had specially buggy boundary management, but I didn't know it was extreme enough that it could interfere with completely unrelated instances; even commenting the m_renderTex.draw calls doesn't prevent the bug.

Can anyone reproduce the situation with only what I've provided? The window is created with .create(sf::VideoMode(640, 480, 64), "", sf::Style::Fullscreen);

29
System / Re: Problems with making my own InputStream
« on: November 17, 2013, 07:18:32 pm »
At first I used <fstream>, but because of bugs unrelated to the final matter, I decided to just copy away Laurent's example - which uses C functions. The initial bugs were one of the factors that really stretched the time - the application wouldn't crash, but resources weren't loading properly -, but I also don't have an habit of using debuggers and rather I resort to spreading couts through the code, so that's it as well.  But thanks for the insight! If anything else happens, I'll come back here to pester you guys again. ;D

Nevertheless, I was aiming for very simply encrypting here, like, XOR cyphers. I just don't want your commoner user to be able to mess around with the game's files.

30
System / Re: Problems with making my own InputStream
« on: November 17, 2013, 04:33:39 am »
Pardon my incovenience. After 4 hours of debugging, apparently the only mistake was here:

        EncryptedStream::EncryptedStream()
                : m_file(nullptr)
        {       }

        EncryptedStream::EncryptedStream
                (const std::string& filePath)
        {
                open(filePath);
        }
 

The excerpt of code above would rather had been:

        EncryptedStream::EncryptedStream()
                : m_file(nullptr)
        {       }

        EncryptedStream::EncryptedStream(const std::string& filePath)
                : m_file(nullptr) // The lack of this was hindered by my silly typing of the parameters
        {
                open(filePath);
        }
 

The application crashed because of this line, in my open() method:

        void EncryptedStream::open (const std::string& filePath) {
                if (m_file) // Without default-setting m_file to nullptr, I'd often try to close a nonexistent address.
                        std::fclose(m_file);

                m_file = std::fopen(filePath.c_str(), "rb");

                if (!m_file)
                        throw FileCouldntOpen(filePath);
        }
 

All working, tout de suit! Who wants a free InputStream class for simple encrypted files?

Pages: 1 [2] 3