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.


Topics - zephiro309

Pages: [1]
1
General / Rand() not working?
« on: December 08, 2012, 11:33:34 pm »
Im trying to relocate a sprite using rand(), but it doesn't seem to work

Considering the following excerpt:

std::cout << "Relocating goal..." << std::endl;
                        srand((unsigned)time(NULL));
                        stick_x = (rand() % (640 - 32)) + 1;
                        stick_y = (rand() % (360 - 32)) + 1;
                        std::cout << "Position change..." << std::endl;
                        stick_sprite.setPosition(stick_x, stick_y);

X only increments by a few bits (4 or 5) and Y keeps decrementing (by, like, 30). I have no idea why. Also, this happens upon collision. However, when there is a change in position in only occurs after a second, instead on instantly.

Pages: [1]