void solver_bis(t_fill *fill) { update_coord(&fill->coord[fill->piece], fill->map_size); if (fill->piece == 0) { fill->map_size++; init_map(fill->map_size, fill->map); } else { fill->piece--; place(fill->parsing[fill->piece], &fill->coord[fill->piece], fill->map, '.'); update_coord(&fill->coord[fill->piece], fill->map_size); } }
void Cube::move_to(GLfloat x, GLfloat y, GLfloat z) { center_x = x; center_y = y; center_z = z; update_coord(); }
void Cube::move(GLfloat x, GLfloat y, GLfloat z) { center_x += x; center_y += y; center_z += z; update_coord(); }
Cube::Cube(GLfloat x, GLfloat y, GLfloat z, GLfloat edge, QObject *parent) { speed = 0.1; last_id++; id = last_id; fixed = false; center_x = x; center_y = y; center_z = z; size = edge/2; //extreme hardcode, i'll change it later //vertex positions //filling index update_coord(); IndexArray[0][0] = 0; IndexArray[0][1] = 1; IndexArray[0][2] = 2; IndexArray[1][0] = 0; IndexArray[1][1] = 3; IndexArray[1][2] = 2; IndexArray[2][0] = 2; IndexArray[2][1] = 1; IndexArray[2][2] = 5; IndexArray[3][0] = 2; IndexArray[3][1] = 6; IndexArray[3][2] = 5; IndexArray[4][0] = 0; IndexArray[4][1] = 1; IndexArray[4][2] = 4; IndexArray[5][0] = 1; IndexArray[5][1] = 4; IndexArray[5][2] = 5; IndexArray[6][0] = 0; IndexArray[6][1] = 3; IndexArray[6][2] = 7; IndexArray[7][0] = 0; IndexArray[7][1] = 4; IndexArray[7][2] = 7; IndexArray[8][0] = 4; IndexArray[8][1] = 5; IndexArray[8][2] = 6; IndexArray[9][0] = 4; IndexArray[9][1] = 7; IndexArray[9][2] = 6; IndexArray[10][0] = 2; IndexArray[10][1] = 3; IndexArray[10][2] = 6; IndexArray[11][0] = 3; IndexArray[11][1] = 7; IndexArray[11][2] = 6; //colors for (int i = 0; i < 8; i++) { ColorArray[i][0] = 0.3f*(i%8)/9.0f; ColorArray[i][1] = (i%8)/9.0f; ColorArray[i][2] = (i%8)/9.0f; } }
void Object::convert_to_beeb(Object* beeb) { if(beeb){ old_appearance_storage = new Object; *old_appearance_storage = *this; memcpy(&n_models,&beeb -> n_models,(char*)&old_appearance_storage - (char*)&n_models); memcpy(&m,&beeb -> m,(char*)&end_of_object_data - (char*)&m); } else if(old_appearance_storage){ memcpy(&n_models,&old_appearance_storage -> n_models,(char*)&old_appearance_storage - (char*)&n_models); memcpy(&m,&old_appearance_storage -> m,(char*)&end_of_object_data - (char*)&m); delete old_appearance_storage; old_appearance_storage = 0; } update_coord(); }
void solver(t_fill *fill) { fill->map_size = 2; while (fill->map_size * fill->map_size < fill->num_piece * 4) fill->map_size++; init_map(fill->map_size, fill->map); fill->piece = 0; while (fill->piece <= fill->num_piece) { if (check_place(fill->parsing[fill->piece], &fill->coord[fill->piece], fill->map)) { place(fill->parsing[fill->piece], &fill->coord[fill->piece], fill->map, 'A' + fill->piece); fill->piece++; } else if (check_coord(&fill->coord[fill->piece], fill->map_size)) update_coord(&fill->coord[fill->piece], fill->map_size); else solver_bis(fill); } }
int _GrReadInputs(void) { GrEvent evaux; int nev = 0; int mb = 0, mx = 0, my = 0; if (_lnxfb_waiting_to_switch_console) _LnxfbSwitchConsoleAndWait(); if (MOUINFO->msstatus == 2) { if (_ReadPS2MouseData(&mb, &mx, &my)) { update_coord(x, mx); update_coord(y, my); /** NOTE we know PS2_LEFTBUTTON == GRMOUSE_LB_STATUS, etc */ MOUINFO->bstatus = mb; GrMouseUpdateCursor(); MOUINFO->moved = TRUE; if (mb != mou_buttons) { evaux.type = GREV_MOUSE; evaux.kbstat = kbd_lastmod; evaux.p2 = MOUINFO->xpos; evaux.p3 = MOUINFO->ypos; if ((mb & PS2_LEFTBUTTON) != (mou_buttons & PS2_LEFTBUTTON)) { if (mb & PS2_LEFTBUTTON) evaux.p1 = GRMOUSE_LB_PRESSED; else evaux.p1 = GRMOUSE_LB_RELEASED; GrEventEnqueue(&evaux); nev++; } if ((mb & PS2_MIDDLEBUTTON) != (mou_buttons & PS2_MIDDLEBUTTON)) { if (mb & PS2_MIDDLEBUTTON) evaux.p1 = GRMOUSE_MB_PRESSED; else evaux.p1 = GRMOUSE_MB_RELEASED; GrEventEnqueue(&evaux); nev++; } if ((mb & PS2_RIGHTBUTTON) != (mou_buttons & PS2_RIGHTBUTTON)) { if (mb & PS2_RIGHTBUTTON) evaux.p1 = GRMOUSE_RB_PRESSED; else evaux.p1 = GRMOUSE_RB_RELEASED; GrEventEnqueue(&evaux); nev++; } mou_buttons = mb; MOUINFO->moved = FALSE; } else if ((MOUINFO->genmmove == GR_GEN_MMOVE_ALWAYS) || ((MOUINFO->genmmove == GR_GEN_MMOVE_IFBUT) && (MOUINFO->bstatus != 0))) { evaux.type = GREV_MMOVE; evaux.kbstat = kbd_lastmod; evaux.p1 = MOUINFO->bstatus; evaux.p2 = MOUINFO->xpos; evaux.p3 = MOUINFO->ypos; GrEventEnqueue(&evaux); MOUINFO->moved = FALSE; nev++; } } } if (kbd_isatty && _CheckKeyboardHit()) { unsigned int key = _ReadCharFromKeyboard(); evaux.type = GREV_PREKEY; evaux.kbstat = kbd_lastmod; evaux.p3 = 0; if (key > 0xff) { evaux.p1 = key; evaux.p2 = GRKEY_KEYCODE; } else if ((key >= 0x80) && (kbsysencoding == GRENC_UTF_8)) { evaux.p1 = 0; if ((key & 0xe0) == 0xc0) { /* two bytes */ evaux.cp1[0] = key; evaux.cp1[1] = _ReadCharFromKeyboard(); evaux.p2 = 2; } else if ((key & 0xf0) == 0xe0) { /* three bytes */ evaux.cp1[0] = key; evaux.cp1[1] = _ReadCharFromKeyboard(); evaux.cp1[2] = _ReadCharFromKeyboard(); evaux.p2 = 3; } else { /* four bytes */ evaux.cp1[0] = key; evaux.cp1[1] = _ReadCharFromKeyboard(); evaux.cp1[2] = _ReadCharFromKeyboard(); evaux.cp1[3] = _ReadCharFromKeyboard(); evaux.p2 = 3; } } else { evaux.p1 = key; evaux.p2 = 1; } GrEventEnqueue(&evaux); MOUINFO->moved = FALSE; nev++; } if (nev == 0) { usleep(1000L); // wait 1 ms to not eat 100% cpu } return nev; }