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

Pages: [1]
1
General / Re: Collision "dont know how"
« on: July 21, 2012, 09:22:33 pm »
That's my way how to check the collision between the player (spaceship) and every asteroid im looping through:

void PlayState::CheckCollisions()
{
        std::list<Asteroid>::iterator It;
        for(It = asteroids.begin(); It != asteroids.end(); It++)
        {              
                if(It->getPos().x <= playerRect.left + playerRect.width &&
                        It->getPos().x + It->getRect().width >= playerRect.left &&
                        It->getPos().y <= playerRect.top + playerRect.height &&
                        It->getPos().y + It->getRect().height >= playerRect.top) {
                                // asteroid collides player
                                It = asteroids.erase(It);
                                playerLives--;
                                if (playerLives == 0)
                                        gameOver = true;

                                Lives.setString("Lives: " + toString(playerLives));
                }
        }
}

2
General / Re: Game States
« on: July 14, 2012, 08:57:07 pm »
Thanks a lot!  :)
I will go through the code later and check the difference to my "SFML-Port".

Edit: You are using SFML 2.0, right?

3
General / Re: Game States
« on: July 14, 2012, 04:09:12 pm »
Welcome to the forum and SFML! :)

Hi :)

I can advice you to use SFML 2.0 since it's far more advanced and less buggy (last relevant commit to the SFML 1.6 was over two years ago...). The down side of SFML 2.0 is that at moment there aren't all tutorials available but it's not that hard to go with the 1.6 tutorials and 'translate' them with the help of the documentation.

This game is just for learning so I thought I start with 1.6 cause there are all tutorials available. With my next project I will switch to 2.0.

As for your problem, I don't see how the tutorial you linked (btw the link is corrupt, don't know how you managed that ^^) is directly related to SDL. Sure if you download the source you get some SDL stuff, but the tutorial actually more emphazised on the state manager. You can look at the exampels of SFML to understand what exactly is needed to work with SFML and then implement the functions on your own.
Yeah of course it's still c++, but for a beginner like me, it's hard to rewrite the SDL stuff ;)

Then there's the tutorial section maintained by the users which has also a tutorial on a basic game engine with a description for states.
I will check that out, thanks.


The basic principle remains the same, only the implementation differs for different multimedia libraries. And you needn't adapt everything 1:1 from the tutorial, it should rather give you the fundamental idea of an abstract "surface" base class and derived classes which implement the single surfaces.

But be careful with this tutorial, it seems to use a questionable C++ style (Init() and Cleanup() instead of constructors and destructors, C prefix for classes, no virtual destructors). Even one more reason not to copy code ;)
Yeah, I would have rewritten it anyway (I guess).


For example I tried to rewrite:
gameengine.h
Code: [Select]
SDL_Surface* screen;
with
Code: [Select]
sf::RenderWindow *window;

gameengine.cpp
Code: [Select]
// create the screen surface
screen = SDL_SetVideoMode(width, height, bpp, flags);
with
Code: [Select]
screen.Create(sf::VideoMode(800, 600, bpp), "test");

Leads me to something like:
Quote
Expression must have a pointer-to-function.

I will read some more tutorials and try to get this running. Thanks anyway!

4
General / Game States
« on: July 14, 2012, 02:57:43 pm »
Hi,
i'm new to SFML (right now using 1.6), trying to write a Game State Manager for different states of my game (splash screen, menu, game, highscore..).
I found this tutorial, sadly it's using SDL. Is there a similiar Tutorial for SFML?

I tried to adopt the tutorial using SFML, but it didn't work out well.

Any help would be much appreciated, thanks!

Pages: [1]