Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 27 Nov 2011
Offline Last Active Oct 17 2014 11:54 PM

Posts I've Made

In Topic: typedef, structs, and arrays

30 January 2014 - 02:23 AM

Thanks, I didn't even think of that.

In Topic: SFML Texture errors

31 December 2013 - 10:50 PM

Yes it was the graphics card. My graphics card is very old. Thanks for the help.

In Topic: Sorting std::vectors

17 December 2013 - 01:01 AM

I fixed the issue two days ago, sorry for not commenting. I added a tilepos int and then wrote a predicate to pass into the std;:sort and that fixed it. Thanks for the responses. 

In Topic: Sorting std::vectors

15 December 2013 - 12:51 AM

When I have the image the same as the one on the right, it should say I win, but it doesn't. I believe it is because of the order of the vector. I want the top corner of the map to be 0 and then all the way down to the bottom right to be n in a sequential order, despite how I move the tiles. At the beginning of the game i shuffle the tiles using std::random_shuffle and reset the positions so it is jumbled and call std::sort:

std::random_shuffle(m_blocks.begin(), m_blocks.end());

//reset the positions
for(int y = 0; y != 10; ++y){
	for(int x = 0; x != 10; ++x){
		m_blocks[(y * 10) + x]->setPos(sf::Vector2f(offsetX + (x * 32), offsetY + (y * 32)));

std::sort(m_blocks.begin(), m_blocks.end());

m_blocks is the tiles and 32 is the size of the block.


I also call std:;sort after I move the tiles: 

std::sort(m_blocks.begin(), m_blocks.end());

Also I am overloading the < operator:

bool Block::operator<(Block& rhs){
	return (m_tile_pos < rhs.m_tile_pos);

and the m_tile_pos is set everytime the block is updated

In Topic: std::vector memory leak issues

12 November 2013 - 11:26 AM

Thank you everyone. I figured out the error was with my singleton, it wasn't deleting properly. Thanks for the help.