int main() { gra(); do { faz(); } while (!kbhit()); return(0); }
void updateDb(struct gracze* gr, struct stoliki* st, int msgSend){ int i=0; int j=0; int k=0; for(i;i<liczS;i++){ int zaj=0; for(j=0;j<liczG;j++){ if(gr[j].stolik == (i+1)){ st[i].gracze[zaj] = gr[j].login; zaj++; } } if(zaj<3){ int pom=zaj; for(pom;pom<3;pom++){ st[i].gracze[pom] = ""; } st[i].gra=0; } if(zaj==3 && st[i].gra!=1){ printf("Pokoj %d zapelniony!\n",(i+1)); clearTab(buf->val, MAX); strcpy(buf->val, "Pokoj zapelniony!\nGracze:\n"); for(k=0;k<zaj;k++){ strcat(buf->val, "\t"); strcat(buf->val, st[i].gracze[k]); strcat(buf->val, "\n"); } for(k=0;k<zaj;k++){ buf->mtype=1000*(i+1); buf->nr=k+1; if(msgsnd(msgSend, buf, (sizeof(struct mybuf)-sizeof(long)), 0) == -1){ perror("Powiad. o zapel. pokoju"); } } st[i].gra=1; int rozpGre = fork(); if(rozpGre == 0) { printf("Rozpoczynam gre dla stolika %d.\n",(i+1)); gra(i+1); exit(0); } } st[i].zajete=zaj; } }
void Game::beginGame() { while (state != END) { switch (state) { case GameState::MENU: menu(); break; case GameState::GAME: gra(); state = MENU; break; case GameState::GAME_OVER: break; } } }
/* =============== idParticleStage::ParticleOrigin =============== */ void idParticleStage::ParticleOrigin( particleGen_t* g, idVec3& origin ) const { if( customPathType == PPATH_STANDARD ) { // // find intial origin distribution // float radiusSqr, angle1, angle2; switch( distributionType ) { case PDIST_RECT: // ( sizeX sizeY sizeZ ) { origin[0] = ( ( randomDistribution ) ? g->random.CRandomFloat() : 1.0f ) * distributionParms[0]; origin[1] = ( ( randomDistribution ) ? g->random.CRandomFloat() : 1.0f ) * distributionParms[1]; origin[2] = ( ( randomDistribution ) ? g->random.CRandomFloat() : 1.0f ) * distributionParms[2]; break; } case PDIST_CYLINDER: // ( sizeX sizeY sizeZ ringFraction ) { angle1 = ( ( randomDistribution ) ? g->random.CRandomFloat() : 1.0f ) * idMath::TWO_PI; idMath::SinCos16( angle1, origin[0], origin[1] ); origin[2] = ( ( randomDistribution ) ? g->random.CRandomFloat() : 1.0f ); // reproject points that are inside the ringFraction to the outer band if( distributionParms[3] > 0.0f ) { radiusSqr = origin[0] * origin[0] + origin[1] * origin[1]; if( radiusSqr < distributionParms[3] * distributionParms[3] ) { // if we are inside the inner reject zone, rescale to put it out into the good zone float f = sqrt( radiusSqr ) / distributionParms[3]; float invf = 1.0f / f; float newRadius = distributionParms[3] + f * ( 1.0f - distributionParms[3] ); float rescale = invf * newRadius; origin[0] *= rescale; origin[1] *= rescale; } } origin[0] *= distributionParms[0]; origin[1] *= distributionParms[1]; origin[2] *= distributionParms[2]; break; } case PDIST_SPHERE: // ( sizeX sizeY sizeZ ringFraction ) { // iterating with rejection is the only way to get an even distribution over a sphere if( randomDistribution ) { do { origin[0] = g->random.CRandomFloat(); origin[1] = g->random.CRandomFloat(); origin[2] = g->random.CRandomFloat(); radiusSqr = origin[0] * origin[0] + origin[1] * origin[1] + origin[2] * origin[2]; } while( radiusSqr > 1.0f ); } else { origin.Set( 1.0f, 1.0f, 1.0f ); radiusSqr = 3.0f; } if( distributionParms[3] > 0.0f ) { // we could iterate until we got something that also satisfied ringFraction, // but for narrow rings that could be a lot of work, so reproject inside points instead if( radiusSqr < distributionParms[3] * distributionParms[3] ) { // if we are inside the inner reject zone, rescale to put it out into the good zone float f = sqrt( radiusSqr ) / distributionParms[3]; float invf = 1.0f / f; float newRadius = distributionParms[3] + f * ( 1.0f - distributionParms[3] ); float rescale = invf * newRadius; origin[0] *= rescale; origin[1] *= rescale; origin[2] *= rescale; } } origin[0] *= distributionParms[0]; origin[1] *= distributionParms[1]; origin[2] *= distributionParms[2]; break; } } // offset will effect all particle origin types // add this before the velocity and gravity additions origin += offset; // // add the velocity over time // idVec3 dir; switch( directionType ) { case PDIR_CONE: { // angle is the full angle, so 360 degrees is any spherical direction angle1 = g->random.CRandomFloat() * directionParms[0] * idMath::M_DEG2RAD; angle2 = g->random.CRandomFloat() * idMath::PI; float s1, c1, s2, c2; idMath::SinCos16( angle1, s1, c1 ); idMath::SinCos16( angle2, s2, c2 ); dir[0] = s1 * c2; dir[1] = s1 * s2; dir[2] = c1; break; } case PDIR_OUTWARD: { dir = origin; dir.Normalize(); dir[2] += directionParms[0]; break; } } // add speed float iSpeed = speed.Integrate( g->frac, g->random ); origin += dir * iSpeed * particleLife; } else { // // custom paths completely override both the origin and velocity calculations, but still // use the standard gravity // float angle1, angle2, speed1, speed2; switch( customPathType ) { case PPATH_HELIX: // ( sizeX sizeY sizeZ radialSpeed axialSpeed ) { speed1 = g->random.CRandomFloat(); speed2 = g->random.CRandomFloat(); angle1 = g->random.RandomFloat() * idMath::TWO_PI + customPathParms[3] * speed1 * g->age; float s1, c1; idMath::SinCos16( angle1, s1, c1 ); origin[0] = c1 * customPathParms[0]; origin[1] = s1 * customPathParms[1]; origin[2] = g->random.RandomFloat() * customPathParms[2] + customPathParms[4] * speed2 * g->age; break; } case PPATH_FLIES: // ( radialSpeed axialSpeed size ) { speed1 = idMath::ClampFloat( 0.4f, 1.0f, g->random.CRandomFloat() ); speed2 = idMath::ClampFloat( 0.4f, 1.0f, g->random.CRandomFloat() ); angle1 = g->random.RandomFloat() * idMath::PI * 2 + customPathParms[0] * speed1 * g->age; angle2 = g->random.RandomFloat() * idMath::PI * 2 + customPathParms[1] * speed1 * g->age; float s1, c1, s2, c2; idMath::SinCos16( angle1, s1, c1 ); idMath::SinCos16( angle2, s2, c2 ); origin[0] = c1 * c2; origin[1] = s1 * c2; origin[2] = -s2; origin *= customPathParms[2]; break; } case PPATH_ORBIT: // ( radius speed axis ) { angle1 = g->random.RandomFloat() * idMath::TWO_PI + customPathParms[1] * g->age; float s1, c1; idMath::SinCos16( angle1, s1, c1 ); origin[0] = c1 * customPathParms[0]; origin[1] = s1 * customPathParms[0]; origin.ProjectSelfOntoSphere( customPathParms[0] ); break; } case PPATH_DRIP: // ( speed ) { origin[0] = 0.0f; origin[1] = 0.0f; origin[2] = -( g->age * customPathParms[0] ); break; } default: { common->Error( "idParticleStage::ParticleOrigin: bad customPathType" ); } } origin += offset; } // adjust for the per-particle smoke offset origin *= g->axis; origin += g->origin; // add gravity after adjusting for axis if( worldGravity ) { idVec3 gra( 0, 0, -gravity ); gra *= g->renderEnt->axis.Transpose(); origin += gra * g->age * g->age; } else { origin[2] -= gravity * g->age * g->age; } }
// G³owne menu void menu() { TIM_Cmd(TIM2, ENABLE); while(1) { PCD8544_GotoXY(0,10); PCD8544_Puts(" START", PCD8544_Pixel_Set, PCD8544_FontSize_5x7); PCD8544_GotoXY(0,20); PCD8544_Puts(" REKORD", PCD8544_Pixel_Set, PCD8544_FontSize_5x7); PCD8544_GotoXY(0,30); PCD8544_Puts(" AUTORZY", PCD8544_Pixel_Set, PCD8544_FontSize_5x7); PCD8544_GotoXY(0,40); PCD8544_Puts(" ZAKONCZ", PCD8544_Pixel_Set, PCD8544_FontSize_5x7); // WskaŸnik w menu PCD8544_GotoXY(0,b); PCD8544_Puts("-->", PCD8544_Pixel_Set, PCD8544_FontSize_5x7); PCD8544_Refresh(); // Wskaznik do góry if(kier==3 && b!=10) { PCD8544_GotoXY(0,b); PCD8544_Puts(" ", PCD8544_Pixel_Set, PCD8544_FontSize_5x7); b=b-10; kier=0; } // Wska¿nik w dó³ if(kier==4&& b!=40) { PCD8544_GotoXY(0,b); PCD8544_Puts(" ", PCD8544_Pixel_Set, PCD8544_FontSize_5x7); b=b+10; kier=0; } if(kier==1 && b==10) { gra(); kier=0; } // Rekord if(kier==1 && b==20) { rekord(); kier=0; } // Opcje if(kier==1 && b==30) { PCD8544_Clear(); PCD8544_Refresh(); opcje(); kier=0; } // Wyjscie if(kier==1 && b==40) { PCD8544_Clear(); kier=0; return; } } }
VOID RenderPlaying() { UINT i; // Draw Background SelectObject(hdcBuffer, GetStockObject(NULL_PEN)); Rectangle(hdcBuffer, 0, 0, WNDWIDTH, (int)(WNDHEIGHT * 0.26)); Rectangle(hdcBuffer, 0, (int)(WNDHEIGHT * 0.5), WNDWIDTH, (int)(WNDHEIGHT * 0.76)); INT totalLength = INT_MIN; for (i = 0; i < 4; i++) if (global.barriers[i].size() && totalLength < global.barriers[i].back().msecs) totalLength = global.barriers[i].back().msecs; totalLength += INT(global.currSong().msPerBeat * 0.5); for (i = 0; i < 4; i++) // Four tracks. Want more? { DOUBLE trackTop = i * 0.25 + (i % 2) * 0.01; DOUBLE trackBottom = (i + 1) * 0.25 + ((i + 1) % 2) * 0.01; // Draw Barriers DrawBarriers(i); // Draw Card Machine if (i == 0) for (int k = 0; k <= 2; k++) { DOUBLE machineX = (totalLength * k / 2 - gameTimePass) / global.currSong().msPerBeat / beatPerScreen; if (machineX < 1.02 && machineX > -0.18) { int height = 0; for (size_t j = 0; j < global.barriers[0].size(); j++) if (global.barriers[0][j].msecs <= totalLength * k / 2) height = global.barriers[0][j].height; else break; SelectObject(hdcBmp, machineX > 0 ? resource.machine : resource.machineok); TransparentBlt(hdcBuffer, ToWindowX(machineX + stickmanX) - 24, ToWindowY(0.21 - height * 0.05) - 49, 48, 48, hdcBmp, 0, 0, 48, 48, RGB(255, 255, 255)); } } // Draw StickMan DOUBLE beatPassed = gameTimePass / global.currSong().msPerBeat; DOUBLE beatPerLoop; if (global.currSong().msPerBeat <= 1000. / 3) beatPerLoop = 1.0; else beatPerLoop = 0.5; int heroTotalFrame = int(beatPassed / beatPerLoop * 8); UINT heroFrame = ((heroTotalFrame + 3) % 8 + 8) % 8; // loop begin from 3rd frame // prevent negative time (audioLeadIn) if (heroFrame >= 6) heroFrame++; COLORREF backColor; if (i & 1) { SelectObject(hdcBmp, resource.wHero[heroFrame]); backColor = RGB(0, 0, 0); } else { SelectObject(hdcBmp, resource.hero[heroFrame]); backColor = RGB(255, 255, 255); } TransparentBlt( hdcBuffer, ToWindowX(stickmanX) - 21, ToWindowY(trackBottom - 0.1 - global.heroes[i].height * 0.05) - 8, global.heroWidth, global.heroHeight, hdcBmp, 0, 0, 420, 504, backColor ); } SelectObject(hdcBmp, resource.cloud); TransparentBlt(hdcBuffer, ToWindowX(1 - gameTimePass * 0.99 / totalLength), 10, 48, 48, hdcBmp, 0, 0, 48, 48, RGB(255, 255, 255)); if (settings.foggyMode) { Gdiplus::Graphics gra(hdcBuffer); Gdiplus::Image sonSelPic(_T("res/ui/foggy.png")); gra.DrawImage(&sonSelPic, 0, 0, WNDWIDTH, WNDHEIGHT); } // Draw blood SelectObject(hdcBuffer, GetStockObject(WHITE_BRUSH)); Rectangle(hdcBuffer, 0, 0, ToWindowX(0.01), WNDHEIGHT); HBRUSH darkRedBrush = CreateSolidBrush(RGB(194, 70, 49)); SelectObject(hdcBuffer, darkRedBrush); Rectangle(hdcBuffer, 0, ToWindowY(1. - global.blood / 100.), ToWindowX(0.01), WNDHEIGHT); SelectObject(hdcBuffer, GetStockObject(WHITE_BRUSH)); DeleteObject(darkRedBrush); // Draw accuracy indicator if (settings.showAccuracyIndicator) { HBRUSH indicatorYellowBrush = CreateSolidBrush(RGB(242, 215, 80)); SelectObject(hdcBuffer, indicatorYellowBrush); Rectangle(hdcBuffer, ToWindowX(0.01) - 1, 0, ToWindowX(0.02), WNDHEIGHT); HBRUSH indicatorGreenBrush = CreateSolidBrush(RGB(36, 180, 85)); SelectObject(hdcBuffer, indicatorGreenBrush); DeleteObject(indicatorYellowBrush); Rectangle(hdcBuffer, ToWindowX(0.01) - 1, ToWindowY(0.1667), ToWindowX(0.02), ToWindowY(0.8333)); HBRUSH indicatorBrush = CreateSolidBrush(RGB(107, 203, 255)); SelectObject(hdcBuffer, indicatorBrush); DeleteObject(indicatorGreenBrush); Rectangle(hdcBuffer, ToWindowX(0.01) - 1, ToWindowY(0.5 - global.accuracyIndicator) - 5, ToWindowX(0.02), ToWindowY(0.5 - global.accuracyIndicator) + 5); SelectObject(hdcBuffer, GetStockObject(WHITE_BRUSH)); DeleteObject(indicatorBrush); } WCHAR timeText[20]; wsprintf(timeText, _T("%d"), gameTimePass); SetTextColor(hdcBuffer, RGB(0, 0, 0)); TextOut(hdcBuffer, ToWindowX(0.8), ToWindowY(0.05), timeText, wcslen(timeText)); // Draw pause button SelectObject(hdcBmp, resource.pauseButton); TransparentBlt(hdcBuffer, WNDWIDTH - 45, 10, 15, 21, hdcBmp, 0, 0, 124, 175, RGB(255, 255, 255)); }