if Statement Problem
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: if Statement Problem

  1. #1
    Join Date
    May 2010
    Posts
    3

    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.

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    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

  3. #3
    Join Date
    May 2010
    Posts
    4

    Re: if Statement Problem

    You're telling two things to draw in the same location. Why wouldn't they draw in the same location?

  4. #4
    Join Date
    May 2010
    Posts
    5

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center