static inline char main_game(unsigned char plinkos) { unsigned char STATUS = RUNNING, x, y = 0, oldx = 59; unsigned int Amount, Total = 0; char buffer[15]; FontSetSys(F_4x6); while( plinkos-- ) { ClearGrayScreen2B(virtual_dark, virtual_light); GraySpriteX8_OR(0, 0, 100, plinkol, plinkod, 20, virtual_light, virtual_dark); PRINT_TOTAL(Total); SHOW_PLINKOS(5, plinkos - 1, virtual_light, virtual_dark); new_chip(oldx, plinkos); x = oldx; y = 2; DRAWALL(x, y); while (STATUS == RUNNING) { if (_keytest (RR_LEFT) && x > 3) MOVE_LEFT( &x ); if (_keytest (RR_RIGHT) && x < 115) MOVE_RIGHT( &x ); if (_keytest (RR_ESC)) STATUS = EXIT; if (_keytest (RR_2ND) || _keytest (RR_DOWN)) STATUS = DROP; } if (STATUS == EXIT) return -1; oldx = x; Amount = DROPPING( &x ); // After this, x will be from 0 to 8 if (Amount == EXIT) return -1; Total += Amount; //GRAPHIC(30, 20, /* HEIGHT */14, /* WIDTH */32, (char*) Zerol, (char*) Zerod, SMALL); /*for(y = 1; y < 6; y++) { period = 15000*(1+random( y )); memset (Actived, 255, LCD_SIZE); // clear virtual gray planes memset (Activel, 255, LCD_SIZE); for(wait = 1; wait < period; wait++); period = 15000*(1+random( y )); DRAWALL(14 * x + 3, 93); for(wait = 1; wait < period; wait++); }*/ SHUFFLE( x ); DRAWALL(14 * x + 3, 93); DRAWALL(14 * x + 3, 93); GRAPHIC(45, 36, x, FALSE);//, gfx_light[x], gfx_dark[x], x); GrayDBufToggleSync(); // switches two sets of planes Waitkey() STATUS = RUNNING; } sprintf(buffer, "Score %d", Total); x = (LCD_WIDTH - DrawStrWidth(buffer, F_6x8)) / 2 - 16; DrawGrayStrExt2B(x, 2, (char*)buffer, A_NORMAL|A_SHADOWED, F_6x8, Activel, Actived); wait_for_keypress(); if (CHECK_FOR_HIGH(Total) == QUIT) // Checks whether or not the user got a high score, writes a new // high score if they did get one, and calls a function to display the new high scores return QUIT; return STATUS; }
void GPMKDTree::ComputeKNN(PointId p0, int K, PointId* neighbors_array) { int neighbor_num = 0; Node* i = rev_mapping[p0]; int k, order0 = i->order; REAL diff; REAL* coords = GPM->coords; REAL* coord0 = GPM->coords + p0*DIM; REAL* current_diff = traversing_buf; REAL* stack = traversing_buf + D; neighbors.Init(K, neighbors_array); for (k=0; k<D; k++) current_diff[k] = 0; i = &nodes[0]; do { if (IS_LEAF(i)) { for (k=0; k<-i->d; k++) { PointId p = i->points[k]; if (p == p0) continue; double dist2; REAL* coord2 = coords+p*DIM; GPM_GET_DIST2(dist2, coord0, coord2); neighbors.Add(p, dist2); } } else { if (neighbors.GetNum() < K || GPM->Norm2(current_diff) < neighbors.GetMax()) { if (i->order > order0) { MOVE_DOWN_LEFT(i); } else { MOVE_DOWN_RIGHT(i); } continue; } } while ( i->parent ) { if (i->parent->order > order0) { if (i->parent->first_child == i) { MOVE_RIGHT(i); break; } } else { if (i->parent->first_child != i) { MOVE_LEFT(i); break; } } MOVE_UP(i); } } while ( i->parent ); }