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

Pages: [1]
1
General / Speedproblems with draw to window
« on: May 06, 2014, 05:37:26 pm »
Hello yeah I know again a thread but I think here it's better placed.

I'm measuring time with an sf::clock

t3=mClock2.restart().asSeconds();
draw(asteroids,bullets,ship,window,BgSprite);
t4=mClock2.restart().asSeconds();

like that I get the delta t used for this function, except I'm terribly wrong.

now like I said in the other thread I have lag issues. Because sometimes t4 jumps to 120 ms.
so what does this draw function?

void draw(std::vector<Asteroid>& asteroids, std::vector<Bullet>& bullets, SpaceShip& ship, RenderWindow& window, Sprite& BgSprite)
{
    window.clear();
    window.draw(BgSprite);
    for(b_it=bullets.begin(); b_it!=bullets.end();)
    {
        b_it->Draw(window);
        ++b_it;
    }
    for(a_it=asteroids.begin(); a_it!=asteroids.end();)
    {
        a_it->Draw(window);
        ++a_it;
    }
    ship.Draw(window);
}

Well not much at all, I handle over the vectors with the asteroids & bullets, my ship , my background and my render window.

The Draw(window) are just drawing the sprites to die render window.

I'm not sure that I pass the vectors the best way, but if you have an idea what it could be tell me.

Again sorting out the main problem these few lines of codes take sometimes (most of the time not) above 1/10 of a second.

thank you in advance

2
SFML projects / And again another Asteroids clone
« on: May 05, 2014, 06:44:39 pm »
Hello community, I'm a student from Switzerland, and we've to program a game in groups. We decided to program an Asteroids.

All what I know about C++ I learned while programming this game, so please be kind. :)

So right know most of it is running very smoothly but sometimes I get small lag spikes (100ms). As far as my measurements are correct they happen in the codelines where I draw the asteroids the background and the spaceship. The problem is I don't know why :)

I'm using the 2.1 sfml library which has the framerate limit. This one works fine but I'm not sure if its a clean way to have a stable clock for the whole system.

I'm not sure how I should upload the code that you can look at the code. I would be very happy if someone could look at it and give me some tips how I could improve the whole project.

At the moment there is no sound, no menu and so on (and no collision detection for the spaceship -that i can test the other parts of the project-) but this will all get into the project till June.

And now here is a video


I know the bullets are sound symbols "shhh"

I hope you understand my English :)




Pages: [1]
anything