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

Pages: 1 ... 3 4 [5] 6 7 ... 9
61
Code: [Select]
...
int main()
{
    // Create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
    tgui::Gui gui(window);
 
    // Load the font (you should check the return value to make sure that it is loaded)
    gui.setGlobalFont("C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/fonts/DejaVuSans.ttf");
...
        //window.clear();
 
        // Draw all created widgets
        gui.draw();

tgui::Button::Ptr button(gui);
button->load("C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/widgets/Button/BabyBlue/Normal.conf");

        window.display();
 ...

2 things I noticed right away. First, you don't even follow your own comments direction (about checking the return value on the font loading). This leads me to believe you just copied and pasted this code without knowing what your doing.

And second, you load a button every single frame after the gui draw call is done. This also leads me to believe you have no idea what your working on. Understand the libraries your working with before you randomly throw code together and ask why it's not working and ask us to fix it for you.

I apologize if I come off as harsh, but honestly it doesn't even look like you tried...

62
General / Re: Collisions in simple platform game
« on: September 08, 2013, 06:21:53 pm »
Maybe it's just me, but this is just a nightmare to read. My suggestion would be to take a step back and figure out what you're trying to achieve.

No offence, but stuff like this:
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right) && map.checkPosition(x+player.getGlobalBounds().width/2+0.1,y+player.getGlobalBounds().height/2) && map.checkPosition(x+player.getGlobalBounds().width/2+0.1,y-player.getGlobalBounds().height/2) && map.checkPosition(x+player.getGlobalBounds().width/2+0.1,y))
 

is not fun to work with, you have keyboard checks AND 3 collision checks in the same statement.

Also: http://sscce.org/ , we can't run a debugger on code fragments, and is that something you've tried?
Have you added print statements to see the state of values? Have you paused the application to run through this code line by line to see whats happening?

63
Graphics / Re: Tiled map with vectors
« on: September 04, 2013, 09:51:41 pm »
Also depends on what kind of movement you are doing. Is moving around tile to tile? If so then you just need to check the tile in the direction you are moving.

If you plan on having free unrestrained movement, then your going to need to get a little tricker. You could do something along the lines of: Check to see what location your player is going to end up, is that new spot on impassable block (like water)? If so then don't move, otherwise apply the move.

64
General / Re: Weird - Collision not occuring
« on: September 01, 2013, 07:41:09 pm »
Even better then removing from the list and re-adding (well I think so), just use a flag like 'isAlive' to determine if the object should be updated or drawn. When you go to shoot another laser, just check if any in the list first are 'isAlive == false', if it is, reuse it, if there isn't any, add a new one.

65
General / Re: Rotating Help
« on: September 01, 2013, 12:11:49 am »
float rad = sprite.getRotation() / 180 * PI;

this looks wrong.
Unless your trying to turn from rad to deg, but sprite.getRoation() doesn't return radians.

66
General / Re: Can't get animation to work
« on: August 30, 2013, 08:22:24 pm »
also I noticed you are using a vector of Textures. Do you have each image in a completely separate file? if this is the case, look into texture atlases.

Edit: I noticed you actually do load in 8 separate files, which is a lot more expensive then having all the images on 1 file. I would definitely look into a texture atlas (spritesheet)

67
General / Re: Can't get animation to work
« on: August 30, 2013, 06:51:29 pm »
as G. said

void Animation::update(sf::Time delta)
{
    if (playing)
    {
        time += delta;

        if (time >= frameTime)
        {
            time = sf::Time::Zero;
            currentFrame ++;

            if (currentFrame = frames.size())
                currentFrame = 0;

            setTexture(frames.at(currentFrame));
        }
 

currentFrame = frames.size(), which sets currentFrame to the size, so it's true, then it will set currentFrame to 0.

68
General / Re: Weird - Collision not occuring
« on: August 30, 2013, 06:48:36 pm »
I noticed your using lists, I'm not overly familiar with them as I always take preferences to vectors, however back when I was learning this stuff I would do:

for(int i = 0; i < enemyList.size(); i++)
{
    sf::Sprite enemySpr = enemyList[i];
    for(int j =0; j < otherList.size(); j++)
    {
        sf::Sprite otherSpr = otherList[j];
        if(enemySpr.intersects(otherSpr))
       {
            ...//whatever you want to do on a collision
        }        
    }
}
 

Nice and simple and easy to understand. Not fast by any means, but it'll do the job of getting things to work
I should note if your going to be removing items from the lists, make sure iterate from back to front.

Edit: Formatting

69
General / Re: Weird - Collision not occuring
« on: August 30, 2013, 06:20:24 am »
of course it's possible. A list of sprites is the same as a sprite, just more of them, and sprite to sprite collision is certainly possible.

Quit trying to use techniques you don't fully understand, it only leads to these issues. My advice, access each element of the lists using objects and loop over the lists using for loops. Something nice and basic. Get that working and then you can move on to more complicated stuff.

70
Graphics / Re: left and top of FloatRect, some explanation needed
« on: August 25, 2013, 10:24:31 pm »
Well I was explaining it in the simplest of forms, no need to confuse him further if he doesn't know what the top and left are to begin with

71
Graphics / Re: left and top of FloatRect, some explanation needed
« on: August 25, 2013, 10:15:12 pm »
                            v -- this is the top
                             _______
this is the left ->     |            |
                            |            |
                            |            |
                            |_______|

The top is your Y coordinate, left is your x coordinate. Top and Left are used to signify the top left corner of the rectangle.

72
General / Re: linking c++ and sfml
« on: August 25, 2013, 10:06:49 pm »
Your trying to build a 32 bit application using a 64 bit library.

73
General / Re: linking c++ and sfml
« on: August 25, 2013, 09:56:07 pm »
Which version of the library did you download?

74
General / Re: Need help in creating a game state manager class
« on: August 23, 2013, 08:53:16 pm »
Can you please suggest a game dev book for beginners. The ones I use for learning C++ are The complete C++ reference by Herbert Schildt and Learn C++ in 21 Days by Jesse Liberty & Bradley Jones.

But I didn't consult any game dev book until now.


Thanks

My apologies on the delay, I've used this book: http://www.amazon.com/Introduction-Game-Development-Second-Edition/dp/1584506792 and it is an amazing read and reference tool. Best Game Development book I've seen yet. Although kind of pricey I wouldn't trade my copy for anything

75
General / Re: Need help in creating a game state manager class
« on: August 21, 2013, 07:32:04 pm »
You have a lot of update and draw code mixed together... It honestly looks like it went through a blender.

Maybe you should try setting up some function calls to separate everything into Input->Update->Draw. Might make things easier to read.

Also I should note that your doing .LoadFromFile every frame for stuff. You only need to do this once, you just need to make sure the font/texture/whatever else stays alive as long as it's being drawn.

Actually going through it some more, you should consider picking up a good C++ book and a good game dev book. Both will have a wealth of knowledge in learning this stuff.

BUT if all your looking for is a fix to your issue, this is the problem:
void playVsComputer(sf::RenderWindow &GAME_WINDOW, int GAME_WINDOW_WIDTH, int GAME_WINDOW_HEIGHT,
                            Paddle &PLAYER_1_PADDLE, Paddle &PLAYER_2_PADDLE, Ball &GAME_BALL)
{
...
 

Pages: 1 ... 3 4 [5] 6 7 ... 9