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

Pages: [1]
1
Graphics / Re: Game Shakes
« on: July 24, 2014, 10:03:48 am »
Thanks for the help! Both problems were caused by the display() being inside the loop. I read somewhere you didn't need the clear if you were using the entire screen each frame?

Looks much better

http://tinypic.com/r/es5dmt/8

Cheers!

2
Graphics / Game Shakes
« on: July 23, 2014, 04:08:35 pm »
I'm relatively new to C++ and coding in general so I'm trying to make a basic Snake game to improve, I have a version of it working using ASCII characters instead of real graphics so I thought I would try SFML to make it look better. This is the code I wrote that uses SFML:


void Board::printBoard(sf::RenderWindow& window) {
        for (int y = 0; y < Board::sizeOfBoardY; y++) {
                for (int x = 0; x< Board::sizeOfBoardX; x++) {
                        //window.clear();
                        if (board[x][y] == 5) {
                                sf::RectangleShape rectangle;
                                rectangle.setSize(sf::Vector2f(10, 10));
                                rectangle.setFillColor(sf::Color::Red);
                                rectangle.setPosition(x * 10, y * 10);
                                window.draw(rectangle);
                        }
                        else if (board[x][y] == 0) {
                                sf::RectangleShape rectangle;
                                rectangle.setSize(sf::Vector2f(10, 10));
                                rectangle.setFillColor(sf::Color::White);
                                rectangle.setPosition(x * 10, y * 10);
                                window.draw(rectangle);
                        }
                        else if (board[x][y] == 9) {
                                sf::RectangleShape rectangle;
                                rectangle.setSize(sf::Vector2f(10, 10));
                                rectangle.setFillColor(sf::Color::Black);
                                rectangle.setPosition(x * 10, y * 10);
                                window.draw(rectangle);
                        }
                        else {
                                sf::RectangleShape rectangle;
                                rectangle.setSize(sf::Vector2f(10, 10));
                                rectangle.setFillColor(sf::Color::Green);
                                rectangle.setPosition(x * 10, y * 10);
                                window.draw(rectangle);
                        }
                        window.display();
                }
        }
}

It should produce a square with a black border and a white center, that you can move the snake around in and get the little red dots to grow the snake. However at the moment there are black lines appearing in the inbetween the white:

http://tinypic.com/view.php?pic=zlvp10&s=8#.U8_GS-kg9jE

The whole thing also shakes within the window and I cant figure out why, link to video of shaking below:



 Any help would be greatly appreciated,

Thanks.

Pages: [1]