void Game::drawFigures(){ //increase time if (++time > cycle) time = 0; bool noCollision = true; for (int i = 0; i < figures.size(); ++i){ Figure * fig = figures[i]; fig->draw(); } }
void Truck::draw() { FigureLink *p=content.GetNext(); Figure *cast; while(/*p->GetNext()!=NULL*/1) { cast=p->Get(); cast->draw(); p=p->GetNext(); if(p==0) return; } }
/* Dibuja una lista de figuras en una imagen. Parámetros: image la imagen donde dibuja. list la lista de figuras que dibuja en la imagen. */ void drawList(IplImage* image, std::list<Figure> &list) { std::list<Figure>::iterator pos; Figure temp = Figure(0,0,0); pos = list.begin(); while(pos != list.end()) { temp = *pos; temp.draw(image); pos++; } }
void Group::draw(CDC* cdc) { //노드 데이터 변경 POSITION posNode = NodeData.GetHeadPosition(); while (posNode) { Figure* pObj = (Figure*)NodeData.GetNext(posNode); pObj->draw(cdc); } //차일드 데이터 변경(recursion이 일어남) POSITION posChild = Child.GetHeadPosition(); while (posChild) { Group* pGroup = (Group*)Child.GetNext(posChild); pGroup->draw(cdc); } return ; }
void Group::drawBoundary(CDC* cdc) { CRect rect = getBoundary();// 그릴 사각형을 가져온다. CPen m_pen(PS_SOLID, 1, RGB(0, 0, 0));// 그릴 펜의 속성을 지정 CPen *oldpen = cdc->SelectObject(&m_pen); cdc->SelectStockObject(NULL_BRUSH); cdc->Rectangle(rect);// 테두리 사각형 그리고 cdc->SelectStockObject(WHITE_BRUSH); CRect box(rect.TopLeft().x - 5, rect.TopLeft().y - 5, rect.TopLeft().x + 5, rect.TopLeft().y + 5); cdc->Rectangle(box);// 왼쪽 위 사각형 그리고 box.SetRect(rect.right - 5, rect.top - 5, rect.right + 5, rect.top + 5); cdc->Rectangle(box);// 오른쪽 위 사각형 그리고 box.SetRect(rect.left - 5, rect.bottom - 5, rect.left + 5, rect.bottom + 5); cdc->Rectangle(box);// 왼쪽 아래 사각형 그리고 box.SetRect(rect.BottomRight().x - 5, rect.BottomRight().y - 5, rect.BottomRight().x + 5, rect.BottomRight().y + 5); cdc->Rectangle(box);// 오른쪽 아래 사각형 그리고 //노드 데이터 변경 POSITION posNode = NodeData.GetHeadPosition(); while (posNode) { Figure* pObj = (Figure*)NodeData.GetNext(posNode); pObj->draw(cdc); } //차일드 데이터 변경(recursion이 일어남) POSITION posChild = Child.GetHeadPosition(); while (posChild) { Group* pGroup = (Group*)Child.GetNext(posChild); pGroup->drawBoundary(cdc); } cdc->SelectObject(&oldpen); }
void on_mouse(int event, int x, int y, int flags, void* param) { switch(event) { case CV_EVENT_LBUTTONUP://evento del boton cuando se suelta window.followmousemove = 0; if(figure.task != '9') { figure.lp.x=x; figure.lp.y=y; } else { window.refresh(); figure.task = '?'; } if(figure.drawtype != '?' ) list.push_back(figure); drawList(window.image, list); break; case CV_EVENT_LBUTTONDOWN://evento del boton cuando se presiona xx = x; yy = y; window.followmousemove = 1; if(variable[3] != 9 && variable[3]<50) { figure = Figure(variable[0],variable[1],variable[2]); figure.fp.x=x; figure.fp.y=y; figure.drawtype=variable[3]; } else { figure = find(x,y,list); if(variable[4]==50 || variable[4]==75 || variable[4]==125 || variable[4]==150) { figure.setZoom((float)variable[4]/100); figure.task = '9'; } if(variable[0]!=-1 && variable[1]!=-1 && variable[2]!=-1) { figure.setColor(variable[0],variable[1],variable[2]); figure.task = '9'; } if(variable[3]==9) figure.task = '9'; } break; } if(CV_EVENT_MOUSEMOVE==event && window.followmousemove == 1)//evento del boton en movimiento { window.refresh(); if(figure.task == '9') { figure.move(x-xx,y-yy); xx=x; yy=y; } else { figure.lp.x = x; figure.lp.y = y; } figure.draw(window.image); drawList(window.image, list); } }