// Load the resources for the scene from a resource loader void MainMenu::load(const ResourceLoader& resourceLoader) { Color normalColor(100, 100, 0), selectedColor(255, 255, 0); Font menuFont = resourceLoader.loadFont("mainMenu.ttf", 42); Game* game = getGame(); _mainMenu.addElement( menuFont, "Play", normalColor, selectedColor); _mainMenu.addElement( menuFont, "Settings", normalColor, selectedColor); _mainMenu.addElement( menuFont, "Quit", normalColor, selectedColor, [&game](){ game->quit(); }); }
void Item::Search(int iNo) { ifstream inFile; inFile.open("ITEM.DAT",ios::binary); if(!inFile) { gotoxy(44,16); warningColor(); cprintf("File does not exist!!"); cout<<'\a'; normalColor(); return; } lightgreenColor(); inFile.read((char*)&a,sizeof(a)); boolean found=FALSE; while(!inFile.eof() && (!found)) { if(iNo==a.itemNo) found=TRUE; else inFile.read((char*)&a, sizeof(a)); } if(found) { gotoxy(38,15); lightcyanColor(); cprintf("Item Name : %s",a.name); gotoxy(38,17); lightcyanColor(); cprintf("Quantity : %d",a.qty); gotoxy(38,19); lightcyanColor(); cprintf("Rate : %.2f",a.rate); gotoxy(38,21); lightcyanColor(); cprintf("Price : %.2f",a.qty*a.rate); } else { gotoxy(43,16); warningColor(); cprintf("Item #. %d Not Found!",iNo); cout<<'\a'; } inFile.close(); }
virtual void processTriangle(btVector3* triangle,int partId, int triangleIndex) { (void)partId; (void)triangleIndex; btVector3 wv0,wv1,wv2; wv0 = m_worldTrans*triangle[0]; wv1 = m_worldTrans*triangle[1]; wv2 = m_worldTrans*triangle[2]; btVector3 center = (wv0+wv1+wv2)*btScalar(1./3.); btVector3 normal = (wv1-wv0).cross(wv2-wv0); normal.normalize(); btVector3 normalColor(1,1,0); m_debugDrawer->drawLine(center,center+normal,normalColor); m_debugDrawer->drawLine(wv0,wv1,m_color); m_debugDrawer->drawLine(wv1,wv2,m_color); m_debugDrawer->drawLine(wv2,wv0,m_color); }
int main(void) { myEngine::Timing::Clock *clock = myEngine::Timing::Clock::createAndStart(); int temp = LoadScene(LOAD_FILE); Point3 cameraRight = (camera.dir ^ camera.up).GetNormalized(); double aspectRatio = static_cast<double>(camera.imgWidth) / static_cast<double>(camera.imgHeight); float camera_l = 1 / (tan((camera.fov / 2) * (M_PI/ 180))); Point3 Sx = cameraRight; Point3 Sy = (-1.0f) * camera.up; Point3 pixel; Point3 k = camera.pos + camera_l* camera.dir;// -cameraRight + camera.up; HitInfo hitInfo; //Color24 hitPixelColor = { 255,255,255 }; Color noHitPixelColor = { 0,0,0 }; Color24* temp_image = renderImage.GetPixels(); float* temp_zBuffer = renderImage.GetZBuffer(); for (int i = 0;i < camera.imgHeight; i++) { //printf("%d\n",i); for (int j = 0; j < camera.imgWidth; j++) { hitInfo.Init(); float flipped_i = camera.imgHeight - i - 1; pixel = k + (((2.0f*aspectRatio * (j + 0.5f)) / camera.imgWidth) - aspectRatio)*Sx + ((((flipped_i + 0.5) * 2) / camera.imgHeight) - 1)* Sy; pixelRay.p = camera.pos; pixelRay.dir = (pixel - camera.pos).GetNormalized(); if (TraceRay(&rootNode, pixelRay, hitInfo)) { #ifdef RELEASE_DEBUG temp_image[i*camera.imgWidth + j] = normalColor(hitInfo); #else temp_image[i*camera.imgWidth + j] = hitInfo.node->GetMaterial()->Shade(pixelRay, hitInfo, lights, 7); #endif temp_zBuffer[i*camera.imgWidth + j] = hitInfo.z; } else { temp_image[i*camera.imgWidth + j] = noHitPixelColor; temp_zBuffer[i*camera.imgWidth + j] = hitInfo.z; } } } renderImage.SaveImage("RayCasted.ppm"); renderImage.ComputeZBufferImage(); renderImage.SaveZImage("RayCastWithZ.ppm"); clock->updateDeltaTime(); double time = clock->getdeltaTime(); printf("Time to render ray casting %f", clock->getdeltaTime()); printf("Time to render zBuffer Image %f", clock->getdeltaTime()); ShowViewport(); }
void Item::Billing() { normalColor(); clrscr(); ifstream inFile; inFile.open("ITEM.DAT",ios::in | ios::binary); if(!inFile) { gotoxy(30,12); warningColor(); cprintf("File does not exist!!"); cout<<'\a'; delay(500); normalColor(); return; } fstream recordBill("BILLS.TXT",ios::app); inFile.close(); char* time; int billNo; int sNo=0; int sQty; int iNo; int itemK=0; int lcount; float price; float amount=0; billNo=nextBillNo(); time=getTime(); clrscr(); gotoxy(30,1); headingColor(); cprintf("ABC STORES MANAGEMENT"); gotoxy(30,2); cprintf("---------------------"); gotoxy(37,3); cprintf("BILLING"); gotoxy(37,4); cprintf("-------"); gotoxy(4,4); yellowColor(); time=getTime(); cprintf("%s",time); lcount=8; do { sNo++; whiteColor(); drawBox(3,5,55,23); gotoxy(3,25); yellowColor(); cprintf("Type '0' to item# to end input"); gotoxy(4,7); whiteColor(); horLine(4,54); lightgreenColor(); gotoxy(5,6); cprintf("Item# Name Qty Rate Price"); clrBox(57,5,80,23); whiteColor(); drawBox(57,5,80,23); gotoxy(58,7); whiteColor(); horLine(58,79); lightgreenColor(); gotoxy(59,6); cprintf("Item# Name"); normalColor(); inFile.open("ITEM.DAT",ios::binary); int line=8; inFile.read((char*)&a,sizeof(a)); while(inFile) { gotoxy(59,line); cprintf("%d",itemNo); gotoxy(66,line); cprintf("%s",name); line++; inFile.read((char*)&a,sizeof(a)); } inFile.close(); gotoxy(5,lcount); cin>>iNo; if(iNo==0) { gotoxy(3,25); clreol(); gotoxy(5,lcount); clrBox(5,lcount,10,lcount); clrBox(57,5,80,23); gotoxy(39,lcount+1); cprintf("------------"); gotoxy(30,lcount+2); cprintf("Amount = Rs. "); gotoxy(43,lcount+2); cout<<setw(6)<<amount; gotoxy(39,lcount+3); cprintf("------------"); gotoxy(4,lcount+4); whiteColor(); drawBox(4,lcount+4,54,lcount+6); gotoxy(20,lcount+5); normalColor(); cprintf("PLEASE PAY Rs. %.2f",amount); getch(); if(itemK) { recordBill<<"Bill No. "<<billNo<<'\t'<<time; recordBill<<"Amount = Rs. "<<amount<<'\n'<<'\n'<<'\n'<<'\n'; } else { ofstream outFile; outFile.open("BILL_NO.TXT"); outFile<<billNo; } return; } inFile.open("ITEM.DAT",ios::binary); inFile.read((char*)&a,sizeof(a)); boolean found=FALSE; while(!inFile.eof() && (!found)) { if(iNo==a.itemNo) found=TRUE; else inFile.read((char*)&a, sizeof(a)); } if(found) { itemK++; gotoxy(12,lcount); cprintf("%s",a.name); clrBox(57,5,80,23); whiteColor(); drawBox(57,5,80,23); gotoxy(58,7); whiteColor(); horLine(58,79); gotoxy(59,6); line=8; yellowColor(); cprintf("Item# Qty"); normalColor(); gotoxy(60,line); cprintf("%d",itemNo); gotoxy(68,line); cprintf("%d",qty); do { gotoxy(27,lcount); cin>>sQty; if(sQty>qty) { clrBox(27,lcount,35,lcount); cout<<'\a'; } }while(sQty>qty); fstream modifyFile; modifyFile.open("ITEM.DAT",ios::in | ios::out | ios::binary); modifyFile.read( (char*)&a,sizeof(a) ); found = FALSE; int rec = 0; while( (!modifyFile.eof()) && (!found) ) { rec++; if(iNo == a.itemNo) { a.qty-=sQty; modifyFile.seekg( (rec-1)*sizeof(a),ios::beg); modifyFile.write( (char*)&a, sizeof(a) ); found = TRUE; } else modifyFile.read( (char*)&a, sizeof(a) ); } modifyFile.close(); gotoxy(35,lcount); cout<<setw(6)<<rate; price=sQty*rate; gotoxy(43,lcount); cout<<setw(6)<<price; amount+=price; recordBill<<setw(7)<<setiosflags(ios::left) <<setiosflags(ios::fixed)<<sNo; recordBill<<setw(18)<<setiosflags(ios::left) <<setiosflags(ios::fixed)<<a.name; recordBill<<setw(10)<<setiosflags(ios::left) <<setiosflags(ios::fixed)<<sQty; recordBill<<setw(10)<<setiosflags(ios::left) <<setiosflags(ios::fixed)<<a.rate; recordBill<<setw(10)<<setiosflags(ios::left) <<setiosflags(ios::fixed)<<price; recordBill.put('\n'); lcount++; } else { gotoxy(5,lcount); clrBox(5,lcount,10,lcount); cout<<'\a'; } inFile.close(); if(lcount+5==22) { clrBox(3,5,55,23); lcount=8; } }while(iNo!=0);
ScreenProgressBar::ScreenProgressBar() :_nodeBase(NULL), _layerFrame(NULL), _layerProgressBar(NULL), _controller(NULL) { { CCSize size; size.width = SingleElementWidth(); size.height = CCDirector::sharedDirector()->getWinSize().height; setContentSize(size); } { CCLayerColor* layerN = CCLayerColor::create(normalColor(), SingleElementWidth(), 30); CCLabelTTF *label = CCLabelTTF::create("Loading. Please stand by.", MAX_DEFAULT_FONT, 10); label->setTag(BUTTON_LABEL_TAG); label->setColor(MAX_COLOR_WHITE); CCSize sz = layerN->getContentSize(); sz.height /= 2; label->setPosition(ccp((int)(sz.width * 0.25), (int)(sz.height * 0.25))); sz.width *= CCDirector::sharedDirector()->getContentScaleFactor(); sz.height *= CCDirector::sharedDirector()->getContentScaleFactor(); label->setContentSize(sz); label->setAnchorPoint(ccp(0, 0)); layerN->addChild(label); CocosHelper::MoveNode(layerN->getChildByTag(11), ccp(15, 5)); addChild(layerN); _buttons->addObject(layerN); } if (!_nodeBase) { _nodeBase = CCNode::create(); _nodeBase->setContentSize(CCSizeMake(SingleElementWidth(), SingleElementHeight())); _nodeBase->setAnchorPoint(ccp(0, 0)); _nodeBase->setPosition(ccp(0, 0)); addChild(_nodeBase); _buttons->addObject(_nodeBase); } ccColor4B color; color = normalColor(); if (!_layerFrame) { _layerFrame = CCLayerColor::create(color, SingleElementWidth(), 50); _layerFrame->setAnchorPoint(ccp(0, 0)); _layerFrame->setPosition(ccp(0, 0)); _nodeBase->addChild(_layerFrame); } color = selectedColor(); if (!_layerProgressBar) { _layerProgressBar = CCLayerColor::create(color, 0, 50); _layerProgressBar->setAnchorPoint(ccp(0, 0)); _layerProgressBar->setPosition(ccp(0, 0)); _nodeBase->addChild(_layerProgressBar); } SetProgress(0.0); }
/*绘制*/ void CheckersPicture::paintEvent(QPaintEvent *event) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); painter.setViewport(p.x(),p.y(),side,side); painter.setWindow(0, 0, zoom*(n), zoom*(n)); QColor dark(0xcc,0xcc,0xcc,200); QColor endColor(0x78,0xff,0x21,200); /*终点颜色*/ QColor startColor(0xea,0x76,0x0f,200); /*起点颜色*/ QColor capturedColor(0xed,0x50,0x62,200); /*捕获颜色*/ QColor normalColor(0xd6,0xb8,0x2c,200); /*正常色*/ QColor black(0x00, 0x00, 0x00, 200); QColor white(0xff, 0xff, 0xff, 220); QColor light(0xed,0xfc,0xdf,200); QColor deep(0x5a,0x61,0x54,200); /*绘制棋盘*/ for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { QRect rect = pixelRect(i, j); if( !((i+j%2)%2) ) { painter.fillRect(rect, deep); } else { painter.fillRect(rect, light); } } } int ix,jx; if(v.size()) { int type; for(unsigned i=0; i< v.size(); i++) { color==WHITE ? jx = n-1-v.at(i).y : jx = v.at(i).y; color==WHITE ? ix = n-1-v.at(i).x : ix = v.at(i).x; QRect rect = pixelRect(ix, jx); type = v.at(i).type; if(type == MOVEDFROM) painter.fillRect(rect, startColor); else if(type == MOVEDTO || type == TOKING) painter.fillRect(rect, endColor); else if(type == MOVEDTHROUGH) painter.fillRect(rect, normalColor); else if(type == DELETED) painter.fillRect(rect, capturedColor); } } int s = zoom*0.4; int sd = zoom*0.3; /*画白棋*/ if(curstate){ /*如果棋局状态发生了改变*/ painter.setPen(QPen(black,zoom*0.025)); painter.setBrush(QBrush(white)); for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { /*如果是白色则从最后一行开始画*/ color==WHITE ? jx = j+1 : jx = n-j; color==WHITE? ix = n-i : ix = i+1; if(curstate->at(i,j)==WHITE) painter.drawEllipse(QPoint(zoom*(ix-0.5),zoom*(jx-0.5)),s,s); if(curstate->at(i,j)==WHITEKING) { painter.drawEllipse(QPoint(zoom*(ix-0.5),zoom*(jx-0.5)),s,s); painter.drawEllipse(QPoint(zoom*(ix-0.5),zoom*(jx-0.5)),sd,sd); } } } /*画黑棋*/ painter.setBrush(QBrush(black)); for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { color==WHITE ? jx = j+1 : jx = n-j; color==WHITE ? ix = n-i : ix = i+1; if(curstate->at(i,j)==BLACK) painter.drawEllipse(QPoint(zoom*(ix-0.5),zoom*(jx-0.5)),s,s); if(curstate->at(i,j)==BLACKKING) { painter.drawEllipse(QPoint(zoom*(ix-0.5),zoom*(jx-0.5)),s,s); painter.setPen(QPen(white,zoom*0.1)); painter.drawEllipse(QPoint(zoom*(ix-0.5),zoom*(jx-0.5)),sd,sd); painter.setPen(QPen(black,zoom*0.1)); } } } } if (thinking && showHourglass) { painter.setWindow(painter.viewport()); painter.drawImage((width() - hourglass.width()) / 2, (height() - hourglass.height()) / 2, hourglass); } }
QColor ColorPalette::defaultBackground() const { return normalColor(DefaultBackground); }