Author Topic: what is wrong with this code  (Read 5308 times)

Offline michellembrodeur

  • Single posting newcomer
  • *
  • Posts: 5
what is wrong with this code
« on: March 31, 2011, 04:42:01 pm »
i have a gridsizer1 on it I have a wxpanel which i named MainPanel

then I have this code
"
void Magic_MappingFrame::OnbtnDrawClick(wxCommandEvent& event)
{
    int Map[100][100][4];

    int i,j;
    int dir; // direction the tunnel is taking
    int clength; // coorridor length
    int startx=100, starty=100; // starting position of the map

    srand(time(NULL));  // random seed generator
    wxPaintDC dc( MainPanel );\

    dc.SetPen(wxPen(*wxBLACK, 2, wxSOLID));
    dc.DrawPoint(startx,starty);  // Draw the starting point
    dir = (rand() %4 ) + 1;  // 4 directions

    // Random length of the coorridor up to 10
    clength = (rand() %10 ) + 1;

    dc.DrawLine(startx,starty,startx,starty-clength);
    dc.DrawLine(50,50,75,80);
    dc.DrawCircle(30,30,10);
    lblDir->SetLabel(_("dir"));
    //StaticText1->SetLabel(_("Label changed"));
    Layout();

    if (dir == 0)   // north
    {
        dc.DrawLine(startx,starty,startx,starty-clength);

    }
    else
    if (dir == 1)   // east
    {
        dc.DrawLine(startx,starty,startx+clength,starty);

    }
    else
    if (dir == 2)   // south
    {
        dc.DrawLine(startx,starty,startx,starty+clength);

    }
    else
     // 3 west
    {
        dc.DrawLine(startx,starty,startx-clength,starty);

    }








    //dc.DrawLine( 5,0 , 5, 10 );
   // dc.SetPen(wxDOT);
    //dc.DrawPoint(15,15);
    //dc.DrawPoint(15,16);
    //dc.DrawPoint(15,17);
    //dc.DrawPoint(25,25);

    //dc.DrawCircle(30,30,10);
    //dc.DrawRectangle(50,50,10,10);


}
"

it will not draw anything, the label will change to say "dir". so I know the code goes through.

thanks all

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: what is wrong with this code
« Reply #1 on: March 31, 2011, 05:28:06 pm »
Unrelated to Code::Blocks. Please ask that in an appropriate place (wxWidgets forum).

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: what is wrong with this code
« Reply #2 on: March 31, 2011, 06:48:34 pm »
Unrelated to Code::Blocks. Please ask that in an appropriate place (wxWidgets forum).
That's why I lock this topic !