static void recursefindpack(coord *current, coord currentsz, coord *set, coord *best, int minarea, int *maxarea, int depth, int n, int xinc, int yinc) { coord c; if (depth == n) { if (currentsz.x * currentsz.y < *maxarea) { memcpy(best, current, sizeof(coord) * n); *maxarea = currentsz.x * currentsz.y; } return; } for (current[depth].x = 0; imax(current[depth].x + set[depth].x, currentsz.x) * imax(currentsz.y, set[depth].y) < *maxarea; current[depth].x += xinc) { for (current[depth].y = 0; imax(current[depth].x + set[depth].x, currentsz.x) * imax(currentsz.y, current[depth].y + set[depth].y) < *maxarea; current[depth].y += yinc) { c.x = imax(current[depth].x + set[depth].x, currentsz.x); c.y = imax(current[depth].y + set[depth].y, currentsz.y); if (!checkcollision(current, set, ¤t[depth], &set[depth], depth)) { recursefindpack(current, c, set, best, minarea, maxarea, depth + 1, n, xinc, yinc); if (*maxarea <= minarea) return; } } } }
void snake::game() { void main(); x=43; y=12; length=6; score=0; for(;;) { while (!kbhit()) { if ((eatx==x)&&(eaty==y)) { gamescore(); eatxy(); length=length+2; } gotoxy(x,y); cout<<""; /* for (int i=1; i<=length+1; i++) { if (newkey==72) { gotoxy(x,y+i); a[i]=x; b[i]=y+i; } if (newkey==75) { gotoxy(x+i,y); a[i]=x+i; b[i]=y; } if (newkey==80) { gotoxy(x,y-i); a[i]=x; b[i]=y-i; } if (newkey==77) { gotoxy(x-i,y); a[i]=x-i; b[i]=y; } if (i==length+1) cout<<" "; else cout<<"Û"; } */ delay(speed); gotoxy(x,y); checkcollision(); if (newkey==72) y--; if (newkey==75) x--; if (newkey==80) y++; if (newkey==77) x++; if (newkey==27) programmer(); if (newkey==13) getch(); if (newkey==110) main(); cout<<" "; } newkey=getch(); if (newkey==0) newkey=getch(); } }
void Background::Run(Weapon &gun1, Weapon &gun2) { checkcollision(gun1,gun2); DrawBackground(); DrawMountain(); }