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

Pages: [1]
1
General / Re: Speedproblems with draw to window
« on: May 07, 2014, 03:35:06 pm »
Yes you're right it would safe me a lot of problems if I would know more about everything. But where isn't that so. And I do belive I know some basics about C++ classes. The Objhandler with drawing and update position is now a class yay.... (Still have these lags perhaps codeblocks like I said yesterday when I was halfasleep and asked every question I got, without thinking about itself)

@Ghostmemory
I've and I want to program a game for a project in the university. I never waited for any of your answers I was trying to find the answers myself in the meantime.
The problem is that I don't have time right now because it's not the only thing I've to do for university and yes there is a deadline.
What can I do if the prof didn't teach us the basics and just said make a game...
But when I'll have time I'll take a book and take my time.
Till then I won't bother you anymore

2
General / Re: Speedproblems with draw to window
« on: May 07, 2014, 12:43:02 pm »
Well I know what you mean, and I would do that If I would have the time to learn all the basics. But I don't. So I won't. And I don't think that  the proper C++ coding knowledge would help to solve my initial probs.

3
General / Re: Speedproblems with draw to window
« on: May 06, 2014, 08:18:59 pm »
Ah you meant like this in the for loop :) thx why is it better this way ?

Do I need a to specify the Iterator different if i iterate over a const std::vector?
Because my compiler bombarded me with errors when I passed the vectors as constants :/

In function 'void draw(const std::vector<Asteroid>&, std::vector<Bullet>&, SpaceShip&, sf::RenderWindow&, sf::Sprite&)':|
error: no match for 'operator=' in 'a_it = (& asteroids)->std::vector<_Tp, _Alloc>::begin<Asteroid, std::allocator<Asteroid> >()'|


Quote
Is your graphics driver up to date? Does it happen in release mode as well? Does it still happen if you disable your AV? Do you have any applications running in the background?

Drivers are up to date. It happens also in release mode. Without AV a bit better but that could just be luck. But without codeblocks it seems to run smoother.
Or perhaps the program is just trolling me....

ahh perhaps I should just sleep

thanks for your replies perhaps till tomorrow

4
General / Re: Speedproblems with draw to window
« on: May 06, 2014, 06:56:14 pm »
The thread was in the project directory, but since I only want to solve this problem and don't want to get any © problems because of images *cough*, I made a new thread. ;)

If any of my answers sound stupid for you I'm sorry. I'm a newb to C++ and SFML I learnt it all while I was programming the game.

So to the problem

What should happen:
Well that's easy
1. clear render window
2. draw the background
3. iterate through bullets and draw them
4. iterate through asteroids and draw them
5. draw the ship

What happens?:
Exactly what I mentioned above.
But (here is my problem) sometimes there is something hanging up in there. Taking a huge amount of time which the player sees as lag.

And now my question what can cause lags in these codelines ?


To work down your post

Quote
If you only iterate over a vector you should definitely put the ++it within the for loop
Didn't I ?

Quote
and make the Draw method const as well if they aren't
like that?
void Object::Draw(RenderWindow& Window) const
{
    Window.draw(mSprite);
}
I saw somewhere that a draw function from the visible game objects was virtual would this help ?


Quote
or probably even better, don't use free functions for this, but instead use a dedicated application class or similar, that way the vectors could be within the class' scope.
yeah nasty habit of me, for testing purposes in a free function, can this cause major problems ?

Could you make an example of
Quote
you could pass the vectors by const reference

Other questions will come later :)

5
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

6
SFML projects / Re: And again another Asteroids clone
« on: May 05, 2014, 09:49:18 pm »
Jup sorry forgot that. The game wasn't supposed to be available for anyone. And the images were for testing purposes. Well forgot that when I came here for some help.

Well then I'll delete the youtube video, and then I'll rewrite my game with an elapsedTime. Thread can be closed. cya

7
SFML projects / Re: And again another Asteroids clone
« on: May 05, 2014, 09:37:13 pm »
This looks good, but you may want to specify where you got your art assets. I'm just saying this because those asteroids look vaguely familiar with another game that I know of.

Perhaps it wasn't the best idea to get it from google :O It's an image from Tavis Coburn out of the magazin wired.uk

8
SFML projects / Re: And again another Asteroids clone
« on: May 05, 2014, 08:13:07 pm »
Have you used git before? That'd be optimal.

Well never used it before but I think i could get it working.

Welcome to the forum!

The video looks good and I really like how you implemented the collision between the asteroids, maybe you could also put the weights into account, so it does look more realistic when they bounc of?

As for the lag spikes I couldn't see any and without any code we have no idea what could probably cause such an issue.
Are you using the elapsed time to update your stuff, or do you just use the frame limit? If you only use the frame limit, this could be a possible reason for your problem ;)

Well the collisions don't take the weight into account because I think it's easier to play with only one speed of asteroids. If I take the weight into account they'll end up with different speeds I believe :)

And no I don't update with the elapsed time. If I'm correct the frame limit should just wait until the 1/30 fps time is over then display it and after this the calculations for the updates should be done again. But If you tell me that this doesn't work like that and could end up in lagspikes sometimes (rly its just sometimes) then Ill perhaps change that.


Try to get git to work :)

what should i upload to git ? I'm using codeblocks so the project file won't help all of you, so should I upload this one ? Or should I just upload the Header, the .cpp files and the images?

9
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