News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

what is wrong with this code

Started by michellembrodeur, March 31, 2011, 04:42:01 PM

Previous topic - Next topic

michellembrodeur

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

Ceniza

Unrelated to Code::Blocks. Please ask that in an appropriate place (wxWidgets forum).

Jenna

Quote from: Ceniza on March 31, 2011, 05:28:06 PM
Unrelated to Code::Blocks. Please ask that in an appropriate place (wxWidgets forum).
That's why I lock this topic !