-
May 7th, 2010, 09:57 PM
#1
if Statement Problem
Hey Guys,
For this game I am creating, there are many loops involved and if statements involved that determine where to go in my point-click RPG. Take a look at the code:
if (iX>=100 && iY>=45 && iX<=300 && iY<=160)
// iX and iY are the coordinates of a bottom that goes to another screen when clicked
{
// East Area (-1,0)
// The coordinates are to resemble the 2nd quadrant of a graph; you can only go
// east and north
testWindow.DrawString(220,300, "(-1,0)");
testWindow.DrawRectangle(0, 0,600, 440);
testWindow.SetPen(WHITE, 0);
testWindow.SetBrush(WHITE);
if (iX>=100 && iY>=45 && iX<=300 && iY<=160)
// This is where the problem is. What I'm trying to do is to have the same bottom
//location but when I have this, it would just write (-2,0) over the (-1,0)
// East Area (-2,0)
testWindow.DrawString(220,300, "(-2,0)");
testWindow.DrawRectangle(0, 0,600, 440);
testWindow.SetPen(WHITE, 0);
testWindow.SetBrush(WHITE);
}
By the way, I am using Codewarrior C++ with CMU Graphics Lab, and if any of you guys are, that would be great.
-
May 10th, 2010, 12:07 PM
#2
Re: if Statement Problem
Please use code tags:
Code:
if (iX>=100 && iY>=45 && iX<=300 && iY<=160)
// iX and iY are the coordinates of a bottom that goes to another screen when clicked
{
// East Area (-1,0)
// The coordinates are to resemble the 2nd quadrant of a graph; you can only go
// east and north
testWindow.DrawString(220,300, "(-1,0)");
testWindow.DrawRectangle(0, 0,600, 440);
testWindow.SetPen(WHITE, 0);
testWindow.SetBrush(WHITE);
if (iX>=100 && iY>=45 && iX<=300 && iY<=160)
// This is where the problem is. What I'm trying to do is to have the same bottom
//location but when I have this, it would just write (-2,0) over the (-1,0)
// East Area (-2,0)
testWindow.DrawString(220,300, "(-2,0)");
testWindow.DrawRectangle(0, 0,600, 440);
testWindow.SetPen(WHITE, 0);
testWindow.SetBrush(WHITE);
}
What is the purpose of the nested 'if'?
Viggy
-
May 11th, 2010, 10:27 PM
#3
Re: if Statement Problem
You're telling two things to draw in the same location. Why wouldn't they draw in the same location?
-
May 12th, 2010, 07:23 AM
#4
Re: if Statement Problem
Your if statements looks the same..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|