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

Pages: [1]
1
SFML projects / Re: Looking for a newby partner(s)
« on: July 11, 2012, 09:14:40 pm »
Hey,

This is interesting. I'll keep an eye on this thread to see where it goes. Feel free to PM me as well.

2
General / Re: Efficient and easy collision detection?
« on: April 03, 2012, 01:34:49 pm »
Maybe you should do some research about quadtree collision detection on google

3
Window / Can i pass a RenderWindow to another class
« on: February 16, 2012, 11:40:30 pm »
I suppose you want to do something like that ...
Code: [Select]
#include <SFML/Graphics.hpp>

class MyClass
{
public:

    MyClass(sf::RenderWindow& window) :
        m_window(window),
        m_text("My Text")
    {}

    void Draw()
    {
        m_window.Draw(m_text);
    }

private:

    sf::RenderWindow& m_window;
    sf::Text m_text;
};

int main(int argc, char* argv[])
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Test");

    MyClass myObject(window);

    while(window.IsOpen())
    {
        sf::Event ev;
        while(window.PollEvent(ev))
        {
            if(ev.Type == sf::Event::Closed)
                window.Close();
        }

        window.Clear();
        myObject.Draw();
        window.Display();
    }

    return 0;
}


Remember that a reference MUST be initialized when it's declared. In the case of an object member reference, it must be initialized in the constructor's initialization list. If you can't initialize the reference, you may consider using a pointer (which can be set at any time).

4
Window / Can i pass a RenderWindow to another class
« on: February 16, 2012, 03:56:12 pm »
Of course, but make sure you don't copy it. Use references (or pointer) to the sf::RenderWindow.

Code: [Select]
class MyCustomClass
{
    public:
        void classMethod(sf::RenderWindow& windowRef);
}


You can also store a reference in your class.

5
Graphics / Move Pacman/Snake automatically
« on: February 13, 2012, 12:15:22 pm »
Hi,

What you should do is setting the direction where your pacman is moving with the key events and then, update your pacman position every X milliseconds in your main loop.

Here is a good article on different implementation of game loop and timing : http://www.koonsolo.com/news/dewitters-gameloop/

6
Graphics / Tank doesn't Shoot Multiple Bullets
« on: February 02, 2012, 12:50:04 pm »
Hi

In your Fire method, you add "SmallBulleti"

Also, the bullet may not be correctly removed. Could you show us your GameObjectManager::Remove() method ?

7
General discussions / Choosing a project
« on: January 13, 2012, 01:42:35 pm »
Hi, maybe this article could give you some ideas ?

http://lazyfoo.net/articles/article01/index.php

8
General / Weird drawing issue
« on: November 11, 2011, 02:04:23 pm »
Hi

I don't think copying a texture in the loop is a good idea. Maybe you could use a reference ?

Also, what is the purpose of the sprite scaling ?

9
Graphics / [SOLVED] Sprite resize error
« on: October 28, 2011, 04:14:57 pm »
Hi

Your first call to sprite.Resize() is actually useless. When you set an image of a sprite for the first time, the sprite will take the size of the image.

Then, the Resize() method is used to change the size of the sprite itself (with scale handling), not the surface that is drawn from the image.

To modify the image surface drawn by the sprite, you shall use the SetSubRect() method : http://www.sfml-dev.org/documentation/1.6/classsf_1_1Sprite.php#a54bf1e6b425c40b00dd544a9c4fb77df

If you want to change the image drawn of a sprite, this could help you :
Code: [Select]
mySprite.SetImage(myNewImage);
mySprite.SetSubRect(sf::IntRect(0, 0, myNewImage.GetWidth(), myNewImage.GetHeight()));

10
General discussions / State machines or Screens?
« on: October 25, 2011, 02:03:29 pm »
Ok, thanks. I'll keep that in mind and try to implement my next state machine that way.

11
General discussions / State machines or Screens?
« on: October 25, 2011, 09:52:51 am »
I should have seen your second design earlier ... Because it's kind of similar to what PeterWelzien suggested. Thank you, this is what I'm going to consider for my next design.

But I have a new question. I saw some designs given in this thread that use a stack of states, with the running one one top of the stack. Is it really useful to store old states ? Do you have an example of situation where this could be necessary ?

12
General discussions / State machines or Screens?
« on: October 21, 2011, 11:26:59 am »
Thank you PeterWelzien, I think I'll try something that follows your idea.

13
General discussions / State machines or Screens?
« on: October 21, 2011, 09:59:08 am »
Hello

This subject highly interests me. I've been confronted to state machine designs issues (I'm still a beginner in game programming). For my last project, I used the implementation given by the LazyFoo tutorial.

My main problem was that retrieving data from a previous state was a real pain in the ***. It seems Vit got a similar problem.
My question is : if you pass the previous state pointer to the constructor of the new one, is there another way than casting the pointer (which is an abstract GameState class pointer) to be able to get some data ?
I never really used casting, and in my mind, if you need to cast, this means the program design is flawed. Is it true ? Or is casting something common ?

Thanks for your advices, I hope what I asked was understandable (I don't speak english very often ...).

Pages: [1]
anything