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

Pages: [1]
1
SFML projects / The Binding of Isaac Remake
« on: May 17, 2017, 09:10:52 pm »
So I found this lovely game called The Binding of Isaac by Edmund McMillen and Florian Himsl. I thought I'd have a go a making something similar since the basic game play is so simple and thought it would be a good way for me to learn how an entity component system design works within a game.

Before I say anything about this project let me just say that it's an absolute piece of trash, I'm not even going to provide a download link because no one should play this. I really like programming but not so much the art side of things so you know, it's not the best looking game. I learned a lot during the makings of it and I had never used an entity component system design before so the code also isn't the best. I'll link the repository below but I wouldn't advise using the code too much to learn off of. I could go on but who wants to read about that. This game may be awful but it's the first complex game I've finished and I hope it inspires anyone struggling with game development to make their own awesome piece of trash too.

Here's the main room. You control the green guy, he has 8 directional movement and 4 directional shooting. The map of the floor in the lower left is randomly generated for each floor just like in the actual game. Once you kill every enemy on the floor that dark grey box in the middle will open and you can move onto the next one.



Every time you kill an enemy you get a coin which can be used to buy the items you can see in the room. I wanted to fill this room up with different items and have them randomly chosen upon generating the floor but I lost interest in further development so I only implemented four lol.


Bombs now explode into projectiles?


I wanted to make the items work together like the actual game so if you pick up the range upgrade item, not only will your bullets travel farther but so will the bullets that come out of the bomb.

The rooms are randomly pulled from a premade set and they are full of various enemies that all behave differently.


Here's a gameplay video. I'm not sure why the video gets choppy when the player transitions from room to room. It runs at a smooth 60fps, it must be some settings in the screen recording software.


Lastly, I just wanted to personally thank Laurent Gomila and the SFML development team for making such a great game library.

https://github.com/KyleNBurke/TheBindingOfIsaac

2
General / Re: Strange Movement with Fixed Timestep
« on: August 17, 2016, 09:06:57 am »
Never mind the issue is back, updating the graphics drivers did not work.

Yes, it looks like your frame is being delayed quite unusually. Try closing other things you have running to see if it's being affected by those. Also, try running the built release executable directly.

No change.

If those still cause the delayed frames, try increasing their priority to see if that changes anything; it could be an indication that something is hogging the CPU when it wants to use it.

Also no change.

Make sure your graphics card drivers are up-to-date.

I've done so, no change.

3
General / Re: Strange Movement with Fixed Timestep
« on: August 17, 2016, 06:35:08 am »
So I updated my graphics drivers which was actually one of the first things I thought to do upon encountering this issue. The problem was that I was using the Intel Driver Update Utility tool which told me that my graphics drivers did not need to be updated. It turns out they were not up to date. It's been over two days now and I have not experienced the issue since manually updating the drivers. I'll report back if I experience it again but for now if anyone has the same problem with their application go to the manufacture's website and download and install the graphics drivers manually. If you have integrated graphics on an Intel CPU do not trust the Intel Driver Update Utility tool it did not show that my graphics drivers were not up to date so it might do the same to you.

4
General / Re: Strange Movement with Fixed Timestep
« on: August 14, 2016, 04:19:56 pm »
Try timing the frames and outputting that information to see if there any unusual spikes.

I'm restarting an sf::Clock just before the window is rendered. Then I'm subtracting away the previous frame time from that time and printing out "--- stutter ---" if the difference is > 0.05. Okay so during the simulation I noticed it stuttered about 5 or 6 times (I didn't run the application for very long) and this is the output which you can see 6 times "--- stutter ---" was printed. So yeah it looks like the window isn't getting rendered consistently.

I'm holding down the right arrow key so as soon as the application starts the circle moves to the right and when it get's to the end I close it down so the application isn't running for very long. Then I'm printing out the x position of the circle and if the current position - previous position > 5 I'm printing out "--- stutter ---". Here's the output for the x position of the circle. If you put the two outputs side by side the stutter output line's line up. (Also the position of the circle is being rounded which is why they're whole numbers)

PD: It seems a problem of cpu or memory usage because if i restart laptop and pc it doesn't happen the stuttering. It comes with time.

Same with me when I restart my  computer it goes away just to come back later in the day.

5
General / Re: Strange Movement with Fixed Timestep
« on: August 13, 2016, 10:39:36 pm »
There was no need to change the timestep in that example to 1/30 from 1/5; you can toggle between 1/5 and 1/60 by pressing Space. The resulting timestep information text in the title bar is showing 1/60 because it's expecting either 1/5 or 1/60 so chooses one. tl:dr; Use the example as is and press Space  :P

Just so you know, the 1/5 is there to show just how much interpolation does. Running at 1/5 with interpolation switched on has motion that is as smooth as 1/60 with interpolation on.  ;)

Oh okay I didn't notice the code that changed the time step to 1/60 when the space bar is pressed and yeah, using interpolation while the time step is 1/5 sure does show you how beneficial interpolation can be.

I may be seeing things but it looks like "Time passed" is stuttering when the circle does. This would suggest that the window itself is being delayed.
I guess the most important (you might think it's too obvious) but required unasked questioned is:
Is this on a release build or does it only occur during debug builds?

It does look a little like the "Time passed" is stuttering when the circle does in the gif. But when it's running on my computer the "Time passed" doesn't stutter. I think it just didn't record the application as well as it runs. And as for the question of if there's a difference with it running on a release vs a debug build. No there is not, I get the same stuttery movement regardless of if it's a release or debug build.

Could be valuable information: Like with my application commenting out this code in your example makes the issue go away:
sf::Event event;
while(window.pollEvent(event))
{
        ...
}
 

6
General / Re: Strange Movement with Fixed Timestep
« on: August 13, 2016, 08:25:18 am »
If you're getting 800 draw calls per second and you're calling it once per frame, you're getting (internally) 800 frames (or ticks/cycles) per second. That is, the interpolation is not interpolating between the previous "seen" position and the current position but the previous position at the previous frame. This pretty much removes the effect for which interpolation is used so try limiting your framerate (something like 60-80) or activating v-sync (but not both). I think this is not a very good explanation so I apologise. Anyway, your logic should probably be running higher that the speed of the refresh/frame rate.

I did some more research, looked at your implementation with your Kairos timing library, changed my code and still didn't notice a change. Then I just downloaded your library altogether and used the timeStepExample.cpp example. I changed the timestep to be 1 / 30 because updating the physics 5 times a second made the circle move 250 * (1 / 5) = 50 pixels each physics update which is quite a jump. Anyway after doing that and experimenting with the interpolation and extrapolation and I can tell you that it doesn't make the movement smooth on my computer.

Sorry the dimensions are so big. Here's the link.


Here's what I conclude from messing around with your application. There is cyclic behavior with how the circle moves: It's smooth then a freeze, smooth then a freeze, smooth then a freeze, etc. The cycle seems to repeat about once every fith of a second. And the only line of code I changed was this: timestep.setStep(1.0 / 30.0);. Now it's hard to tell the difference but when I turn interpolation on, the movement between the freezes does look smoother, however the freezes are still there.

7
General / Re: Strange Movement with Fixed Timestep
« on: August 12, 2016, 09:29:16 pm »
I'm getting a solid 60 frames per second and around 800 draw calls per second
How? If you are drawing 60 frames per second and drawing three things per frame, you should be getting 180 draw calls per second.

Sorry, I meant that the state.draw() function is getting called about 800 times per second. This doesn't seem irregular to me because since state.draw() is inside the while(window.isOpen()) loop it's going to get lots and lots of calls basically as fast as the CPU can do it.

When I run the minimal application on a different less powerful I get again a solid 60 frames per second and about 400 calls to state.draw() per second which would make since seeing that it's got a Pentium processor and my main computer has a core i7. (I know the CPU isn't everything and if you want the full specs of each computer I can give them to you.) And the movement is smooth. So I don't know I feel like the issue isn't with the code.

Okay so here is how I can get the movement to be smooth:
sf::Event event;
while(window.pollEvent(event))
    if(event.type == sf::Event::Closed)
        window.close();
  • Restart my computer. Yes, when I restart my computer the movement is smooth but at the end of the day when it's time for me to work on the project the jitteryness comes back. So I restart  my computer and everything is fine but the next day after I get home from work and decide to do some development at the end of the day I have to again restart it.


I said this before but this only started happening after I applied the Window 10 anniversary update to my computer which was August 1st if I remember correctly. I've ran the Intel Driver Update Utility  and it does not return back that the graphics drivers are not up to date.

8
General / Re: Strange Movement with Fixed Timestep
« on: August 12, 2016, 08:49:45 am »
Fixed Timestep creates a reliable and regular update for physics and logic. It doesn't, however, fix the refresh rate of the window. This is decided by the OS; if it would prefer to do something else, your window will have to wait.
Therefore, each frame shown isn't guaranteed to be perfectly regular and, in some cases, not at the exact time you expect a frame - it could be part way.
Frame interpolation can help solve this visual artifact. It's the very last part in the Fix Your Timestep article. I commented about this here recently and there is a small accompanying video to that comment showing the difference. See the comment here (also includes a link to Fix Your Timestep article).

I looked at your video and it appears the same issue is happening with me so I implemented interpolation but unfortunately the issue is still there. Here is a minimal code example which is also on github:

main.cpp
#include "State.h"

int main()
{
        sf::RenderWindow window(sf::VideoMode(1500, 1000), "Timestep Testing");
        window.setKeyRepeatEnabled(false);

        State state;

        sf::Clock clock;
        float dt = 1.0f / 60.0f;
        float accumulator = 0.0f;

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

                accumulator += clock.restart().asSeconds();

                while(accumulator >= dt)
                {
                        state.update(dt);
                        accumulator -= dt;
                }

                float interp = accumulator / dt;

                window.clear();
                state.draw(window, interp);
                window.display();
        }

    return 0;
}

State.h
#pragma once

#include "SFML\Window.hpp"
#include "SFML\Graphics.hpp"

class State
{
public:
        State();

        void update(float timeStep);
        void draw(sf::RenderWindow& window, float interp);

private:
        sf::RectangleShape rect;
        sf::Font font;
        sf::Text fps;
        sf::Text dps;
        sf::Clock clockUpdate;
        sf::Clock clockDraw;
        int frames;
        int draws;
        sf::Vector2f pos;
        sf::Vector2f lastPos;
};

State.cpp
#include "State.h"

State::State() : rect(sf::Vector2f(100.0f, 100.0f))
{
        font.loadFromFile("lucon.ttf");
        fps.setFont(font);
        dps.setFont(font);
        fps.setPosition(10.0f, 0.0f);
        dps.setPosition(10.0f, 30.0f);
        frames = -1;
        draws = -1;
}

void State::update(float timeStep)
{
        if(clockUpdate.getElapsedTime().asSeconds() >= 1.0f) {
                fps.setString("FPS: " + std::to_string(frames));
                frames = 0;
                clockUpdate.restart();
        }

        frames++;

        sf::Vector2f d;

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W))
                d.y = -1;

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S))
                d.y = 1;

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A))
                d.x = -1;

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D))
                d.x = 1;

        lastPos = pos;

        pos += 150.0f * d * timeStep;
        rect.setPosition(pos);
}

void State::draw(sf::RenderWindow& window, float interp)
{
        if(clockDraw.getElapsedTime().asSeconds() >= 1.0f) {
                dps.setString("Draw Calls: " + std::to_string(draws));
                draws = 0;
                clockDraw.restart();
        }

        draws++;

        window.draw(fps);
        window.draw(dps);

        sf::Vector2f posInterp = pos * interp + lastPos * (1.0f - interp);
        rect.setPosition(posInterp);
        window.draw(rect);
}

I'm getting a solid 60 frames per second and around 800 draw calls per second but the movement is still noticeably jittery. I also noticed that if I comment out the following code from main.cpp the issue goes away and the movement is buttery smooth.

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

It appears that calling window.pollEvent() is causing the movement to be jittery.

9
General / Re: Strange Movement with Fixed Timestep
« on: August 11, 2016, 09:15:07 pm »
I should better use window.setFramerateLimit

I've experimented with this function before and if it set it to the match the frame rate I've implemented in my code it has no visual impact which would make since because it just checks to see if an amount of time has passed before displaying the contents.

I've decided to experiment a little more with it though. Here's what I changed the code to:

window.setFramerateLimit(60);

while (window.isOpen())
{
    pollEvents();
    updateStates(dt);
    clearInput();

    window.clear();
    drawStates(window);
    window.display();
}

So after making this change I noticed that the movement is the same, it's not smooth. This tells me that the code I wrote in the first post is probably fine and that the issue is elsewhere. I figured maybe it's my computer so I ran the application on a different less powerful computer and strangely the movement is smooth! Now that I think about it this issue started happening when I applied the windows 10 anniversary update to my computer. The graphics drivers are up to date so I have absolutely no clue why this would be happening. Does anyone have any ideas?

10
General / Strange Movement with Fixed Timestep
« on: August 11, 2016, 08:02:20 am »
So the movement in my game isn't smooth. It looks like every tenth of a second the game freezes for a very short period of time then continues along until it freezes again.

You can see here as the rectangle moves, it stops for a short while then continues along.



Here is my code for updating and rendering the game:

float dt = 1.0 / 60.0f;
float accumulator = 0.0f;

while (window.isOpen())
{
        float frameTime = clock.restart().asSeconds();
        accumulator += frameTime;

        while(accumulator >= dt)
        {
                pollEvents();
                updateStates(dt);
                clearInput();

                accumulator -= dt;
        }

        window.clear();
        drawStates(window);
        window.display();
}
 

Is my code flawed in someway and is this behavior a result of it? Or should this create smooth movement and thus the problem is with something else?

11
Graphics / Re: Sprite::getGlobalBounds() returning incorrect values
« on: August 11, 2016, 07:01:58 am »
Thanks for your help, I guess nothing is really wrong so I'll round the values.

12
Graphics / Sprite::getGlobalBounds() returning incorrect values
« on: August 09, 2016, 07:46:00 am »
sf::Sprite s(playerSpriteSheet, sf::IntRect(1, 1, 7, 6));
s.setScale(9.0f, 9.0f);
s.setOrigin(s.getLocalBounds().width / 2, s.getLocalBounds().height / 2);
s.setPosition(400.0f, 50.0f);
s.setRotation(180.0f);

I'm initializing a sprite with the above code. If I was to then find the value for the top of the global bounds I should get 23 and here's how: Since the scale of the sprite is 9 the height would be 6 x 9 or 54. The origin of the sprite is in the very center so the center of the sprite globally is 400, 50. To get the top of the global bounds you'd subtract half of the height from 50: 50 - 54 / 2 = 23. So when I call s.getGlobalBounds().top I should get 23 but I actually get 22.9999962 and when I call s.getGlobalBounds().height I should get 54 but instead I get 54.0000038.

I'm aware that since the sprite is rotated 180 degrees some floating point arithmetic is involved and thus gives me incorrect numbers because of the inherit problems with floating point arithmetic. But what if I was to tell you that the incorrect value are only present when the position of the sprite on the y axis is less than 92? When I set the y position of the sprite to 92 the correct values are returned, but when I set the y position of the sprite to 91, I then get values that are slightly off like mentioned above.

It's so strange to me that the values are only incorrect when the sprite's y position is less than 92. Why is this the case and is there anything I can do to ensure I'll always get the correct values regardless of the sprites position?

13
General / Application Builds but VS's Error List Shows Errors
« on: December 22, 2014, 02:33:58 am »
I've created a project with the minimal amount of code required to reproduce this issue on my machine. It was created with the default Microsoft Visual Studio C++ application wizard settings so it has an precompiled header file. The I've created one class:

GameManager.h
#pragma once

#include "stdafx.h"

class GameManager
{
public:
        GameManager();

private:
        sf::RenderWindow window;
};
 

GameManager.cpp
#include "stdafx.h"
#include "GameManager.h"

GameManager::GameManager() : window(sf::VideoMode(800, 600), "Testing") {}
 

I can assure you, I've got the proper SFML files downloaded and linked to my project correctly.

When I build my application the output shows that the project succeeded in building however the error list shows a total of 6 errors that all say "no instance of constructor "sf::ContextSettings::ContextSettings" matches the argument list". Visual Studio says 4 of them are from the Window.hpp SFML file and the other two are from the RenderWindow.hpp SFML file.

This baffles me because there is nothing wrong with the construction of the render window variable and I have no idea why Visual Studio would give me 6 errors but still build the application.

Anyone know what is going on and how I can get these errors fixed?

Pages: [1]
anything