Outpost Universe Forums

Projects & Development => Outpost 2 Programming & Development => Topic started by: Angellus Mortis on July 25, 2010, 02:05:10 PM

Title: Simple C++/coding Question
Post by: Angellus Mortis on July 25, 2010, 02:05:10 PM
This is for a disaster code for generating x and y values. It is on a 512x512 world map. The x and y values cannot fell into both of these ranges at the same time (a box):

501 - 512, 1 -28 for x
232- 256 for y

The code I have

Code: [Select]
int x = TethysGame::GetRand(512);
    int y;
    if (x < 28 || x > 501)
    {
        y = TethysGame::GetRand(232);
    }
    else
    {
        y = TethysGame::GetRand(256);
    }

I keep getting values within the box that is it not suppose to be in. (6,241) seems to be a common one. It is probably a stupid simple error I do not see but I am tired of looking at it. What is wrong?
Title: Simple C++/coding Question
Post by: Sirbomber on July 25, 2010, 05:27:16 PM
Uhh, I'm not even sure what you're trying to do.  Do you want stuff to be in that box, or not in that box?  Regardless, there's probably a better way to do it.
Title: Simple C++/coding Question
Post by: Angellus Mortis on July 25, 2010, 05:49:07 PM
Nevermind Sirbomber. The code is correct. It was another part of code that was making that meteor... It had been too long since I used the code, I forgot about it.