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

Pages: [1]
1
I'm currently working on a small game and what I want is for the music to loop in small segments, with each segment building up the music.

The solution was to set loop points when playing a track and then after a specific event change the loop points to further along in the song.

The solution worked, anytime new loop points were set the music would keep on playing up until the end of the new loop point where it would jump back to start of the new loop point. However, the music would stop playing eventually, even though no functions were called to stop the sound.

I assumed it was just something in my engine, but I've modified the sound example to only play my music file and update the loop points every 25 seconds, and the music eventually stops (even the music status no longer returning the Playing state). I've attached the sample code and file in the post.

 // Load an ogg music file
sf::Music music;
if (!music.openFromFile("resources/" + filename))
    return;

music.setLoop(true);
music.setLoopPoints(sf::Music::TimeSpan(sf::seconds(0.0f), sf::seconds(8.0f)));

// Play it
music.play();

int level = 1;

// Loop while the music is playing
while (music.getStatus() == sf::Music::Playing)
{
     // Leave some CPU time for other processes
     sf::sleep(sf::milliseconds(25000));

     level++;
     float loopEnd = (level + 2) * 8.0f;

     if (loopEnd <= music.getDuration().asSeconds())
     {
        music.setLoop(true);
        music.setLoopPoints(sf::Music::TimeSpan(sf::seconds(loopEnd - 8.0f), sf::seconds(8.0f)));
    }
}

I'm using the latest SFML source code (last update 15th April 2020) and running on Windows 10, using Visual Studio 2017 for dev.

I've found that setting the loop points only once does not cause any issues, but setting loop points to the same music stream more than once causes it to eventually stop.

2
Graphics / Nothing displaying with Modern OpenGL with SFML 2.5.0
« on: May 20, 2018, 09:37:40 pm »
So I've been working on getting Vigilante Framework to support SFML 2.5.0, and I've been getting a few issues with the sf::RenderTexture. The main ones I've been going back and forth with eXpl0it3r on Twitter so I want to make this one separate and look for some help.

Basically, I use modern OpenGL rendering that's based on the Mastering SFML Game Development: Chapter 7 book by Raimondas. The key difference being that instead of rendering to an sf::RenderWindow I render to an sf::RenderTexture.

This implementation worked fine in 2.4.2 (as seen in the first attachment) but stops working 2.5.0. There is no error found using glGetError() and the only GL specific error I get is RenderTextureImplFBO (third attachment).

My only hint so far is that if I try to clear the RenderTexture to a specific colour, the screen doesn't display that colour, meaning that there could be a context issue causing the texture data not to display properly?

Also I'm not sure how about to create a simplified version of this project, since I need glew for the extensions and GLM for matrices since you cannot use the GL legacy stuff. I managed to convert the OpenGL example project to use modern OpenGL although texture coordinates and recreating the window to toggle sRGB aren't working properly.

3
SFML projects / Vigilante Game Framework
« on: April 05, 2017, 09:16:16 pm »
View on GitHub





So I've open sourced the framework I built for my game on Steam, Gemstone Keeper.

The basic goal of this was to provide a code base to allow me to have a base game loop with ability to render, update, change game states and so on, and I was mostly inspired by how HaxeFlixel structured their framework. Later on I added some of the more fancy features like the infinite scrolling backdrop and 3D rendering.

I'd appreciate some feedback and ways to improve the code, optimisations and whatnot. Since almost all of us are coders I'm sure there are many ways stuff in here could be approached, hopefully it's all clear enough but if not I'm willing to answer any questions.

4
SFML projects / Gemstone Keeper - An ASCII based Roguelike Shooter
« on: May 06, 2016, 10:00:13 pm »
Hello everyone!

I'm surprised I didn't post here earlier, considering I made posts on other threads about it. This is Gemstone Keeper, a combination of twin-stick shooter and roguelike. The player explores multiple layers of procedurally generated caverns, and while you defend yourself from the creatures within, you also break rocks to find gemstones and minerals. The deeper down you go, the more valuable gemstones you can find, but the creatures get stronger.



I moved engines from Allegro to SFML in July 2015, the long reason why I wrote about a while back but the short version is that SFML was being kept stable, more up-to-date and had features I was more keen in such as shader support.



Features the game currently has:
  • Procedurally Generated Levels
  • Procedurally Rendered 3D Gemstones
  • Modular Weapons System (Choose the Weapon, Choose the Bullet, each interchangeable)
  • Randomized Characters + Stats
  • Permadeath
  • Level Visual Effects





As you can also tell, this game heavily uses ASCII graphics. I render the glyphs onto RenderTextures and have them rendered as Sprites so more complex designs such as the tilemap can be rendered much more easily.

The game was Greenlit on Steam Greenlight on June 11th 2016, you can find the Greenlight page here here!

The game will be was released on Steam on March 31st of 2017 at around 6pm GMT. Check out the game's official website and Steam page!

WANTED: Linux users to test run port.
I have been working on a Linux port for a while and I've got a demo build available for download. If anyone who uses a Linux machine run the game and tell me if it works, how well it functions, and if not, specifically what is wrong.

5
Graphics / Fullscreen Rendering between Game States
« on: March 05, 2016, 01:41:25 am »
Short Version: Changing from one state to another on fullscreen has unusual rendering behaviour, while the same action in window mode does not show the same behaviour.

So I'm using SFML 2.3 in my framework and I've come across an issue that's mainly specific to when I'm rendering in fullscreen mode. I use a Game State Manager class so I can render different screens in separate classes, as well as store multiple states that I can push and pop out of in a stack:

VState* VStateManager::CurrentState()
{
        return states.back();
}

void VStateManager::ChangeState(VState* state)
{
        if (states.size())
        {
                states.back()->Cleanup();
                delete states.back();
                states.pop_back();
        }

        state->Initialise();
        states.push_back(state);
}

void VStateManager::PushState(VState* state)
{
        if (states.size())
        {
                states.back()->Pause();
        }

        state->Initialise();
        states.push_back(state);
}

void VStateManager::PopState()
{
        if (states.size())
        {
                states.back()->Cleanup();
                delete states.back();
                states.pop_back();
        }

        if (!states.empty())
        {
                states.back()->Resume();
        }
}

When you want to change a state from either the ChangeState or PushState functions, the switch doesn't occur straight away to avoid any errors from continuing a state function after it has been destroyed. Instead the new state is saved until the start next game loop iteration, I do this by calling the function and passing in NULL.

//Start of loop
if (stateManager->IfChangedState)
{
        stateManager->ChangeState(NULL);
}

if (stateManager->IfPushedState)
{
        stateManager->PushState(NULL);
}

HandleEvents();
if (focused)
{
        Update(dt * timeScale);
}

if (focused && !stateManager->IfChangedState && !stateManager->IfPushedState)
{
        PreRender();
        for (unsigned int c = 0; c < CurrentState()->Cameras.size(); c++)
        {
                currentView = c;
                Render();
        }
        PostRender();
}

Now onto the SFML specific stuff.  :P

So when I run my game in Windowed mode, and change the state, the screen might pause for a short amount of time, but it'll render the next scene without any problems like below:


However, if I try running the same scene again in fullscreen mode, for some reason it renders the last state for a short amount of time before starting the next state. It was very difficult for me to capture (neither FRAPS or GifCam could capture the fullscreen rendering, but OBS could capture this), what you don't see below is the very short lasting white screen going to black.


This is the code I use to switch between window mode and fullscreen. I initially thought it might be because the previous sf::RenderWindow (App) wasn't being destroyed, but I think that's already handled in create.

void VGame::SetFullscreen(bool set)
{
        if (set && !fullscreen)
        {
                App.create(sf::VideoMode::getDesktopMode(), Title, sf::Style::Fullscreen);
                App.setMouseCursorVisible(set);
                fullscreen = true;
        }
        else if (!set && fullscreen)
        {
                App.create(sf::VideoMode(WindowWidth, WindowHeight), Title, WindowStyle);
                App.setMouseCursorVisible(set);
                fullscreen = false;
        }
}

As for rendering, I use an sf::RenderTexture (called RenderTarget) to render the scene, and then I could apply post process effects before setting the texture to a sf::Sprite, which is positioned, scaled and then rendered to the sf::RenderWindow. I separated it into three functions so I could organise each part of the rendering.

void VGame::PreRender()
{
        RenderTarget.clear(BackgroundColor);
}

void VGame::Render()
{
        RenderTarget.setView(CurrentState()->Cameras[currentView]->GetView());

        if (CurrentState()->visible)
                CurrentState()->Draw(RenderTarget);

        if (CurrentState()->SubState)
        {
                CurrentState()->SubState->Draw(RenderTarget);
        }

        CurrentState()->Cameras[currentView]->Render(RenderTarget);
}

void VGame::PostRender()
{
        RenderTarget.display();
        if (RenderTarget.isSmooth() != Antialiasing)
        {
                RenderTarget.setSmooth(Antialiasing);
        }
        App.setVerticalSyncEnabled(VSync);

        App.clear();

        if (PostProcess == NULL || !VPostEffectBase::isSupported())
        {
                RenderSprite.setTexture(RenderTarget.getTexture());
                App.draw(RenderSprite, RenderState);
        }
        else
        {
                PostProcess->Apply(RenderTarget, App);
        }

        App.display();
}
 

All I could gather from debugging was that after the ChangeState function is called, the rendering functions are skipped for one frame, the states are changed and then the next render is called, and the window outputs what you see above.

Sorry about this being very long-winded. I've tried my best to cut out some parts of the code that might not be relevant, however I'm not sure if I could reproduce this issue with something much smaller.

6
Graphics / Strange Rendering Behaviour with sf::Text and sf::RenderTexture
« on: November 13, 2015, 01:37:00 am »
So I've been having this weird rendering issue. My game project uses very specific text rendering, which requires me to paste text onto a texture, and then render it as a sprite or another render entity using VertexArrays. Below is one example of how I achieve this:

if (!VContent::FindTexture("player"))
        {
                sf::RenderTexture renderTex;
                renderTex.create(18, 26);

                sf::Font font;
                VContent::LoadFont("Assets\\lucon.ttf", font);
                sf::Text text = sf::Text("@", font, 32);
                text.setColor(sf::Color::White);
                text.setStyle(sf::Text::Regular);
                text.setPosition(0, -7);
                renderTex.draw(text);
                renderTex.display();

                VContent::StoreTexture("player", renderTex.getTexture());
        }

VContent by the way, is my content manager, which I use to store and load textures and other copyable assets essentially anywhere in my project. It stores textures like so:

bool VContent::StoreTexture(string name, sf::Texture texture)
{
        if (!FindTexture(name))
        {
                sf::Texture tex(texture);
                textureDir.insert(textureDir.begin(), std::pair<string, sf::Texture>(name, tex));

#if _DEBUG
                cout << name << " stored." << endl;
#endif
               
                return true;
        }

#if _DEBUG
        cout << "Error storing texture: " << name << endl;
#endif

        return false;
}

Anyway, on my home PC (see left image) it displays like normal with the text being rendered with the correct characters, but when I was testing on another PC (see image right), I was getting incorrect characters and random artefacts.



As far as hardware is concerned, there isn't much difference as they are both have Intel Core iSeries CPU, decent hard drive space and are both relatively high performance machines (although my home PC has a dedicated gaming graphics card, but I haven't discovered if the other PC has one itself).

7
SFML projects / XPText - A Text Renderer for the ASCII art tool REXPaint
« on: November 03, 2015, 02:27:17 am »
Hello there! Thought I'd finally make my forum debut by showing this neat little project I just uploaded.

REXPaint is an ASCII art tool developed by GridSageGames, as the summary implies, it allows you to produce artwork using text, a particular art form found in roguelike games.

REXReader++ is a lightweight file reader class that allows you to decompress and read REXPaint's xp file format in a readable tilemap structure. What I did was use this with a custom text class so you can render your REXPaint creations in SFML 2.0!


Pages: [1]
anything