Author Topic: Simple C++/coding Question  (Read 2471 times)

Offline Angellus Mortis

  • Full Member
  • ***
  • Posts: 138
Simple C++/coding Question
« 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?

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Simple C++/coding Question
« Reply #1 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.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Angellus Mortis

  • Full Member
  • ***
  • Posts: 138
Simple C++/coding Question
« Reply #2 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.
« Last Edit: July 25, 2010, 06:07:54 PM by angellus »