void initField(){ drawField(fieldX - 1, fieldY - 1, GAME_FIELD_WIDTH + 23, GAME_FIELD_HEIGHT + 2, BACK_WHITE | BACKGROUND_INTENSITY); drawField(fieldX, fieldY, GAME_FIELD_WIDTH, GAME_FIELD_HEIGHT, BACK_WHITE); setTextColor(BACK_WHITE | BACKGROUND_INTENSITY); moveCursor(fieldX + GAME_FIELD_WIDTH + 2, fieldY + GAME_FIELD_HEIGHT - 1); printf("Use \"w, a, s, d\""); }
Window::Window() { setWindowTitle(tr("Ultimate Maze")); const short menu_size = 0; setFixedSize(MAZE_SIZE * TILE_SIZE, MAZE_SIZE * TILE_SIZE + menu_size); maze = new Screen(this); maze->setGeometry(0, 0, MAZE_SIZE * TILE_SIZE, MAZE_SIZE * TILE_SIZE); engine = new Engine(); connect(this, SIGNAL(keyPressed(PRESSED_KEY)), engine, SLOT(keyPressed(PRESSED_KEY))); connect(engine, SIGNAL(drawField(QImage)), maze, SLOT(drawField(QImage))); engine->run(); }
void QtRPT::processRTitle(int &y, bool draw) { if (reportTitle.isNull()) return; QDomElement e = reportTitle.toElement(); if (draw) drawField(reportTitle,y); y += e.attribute("height").toInt(); //painter.drawLine(0,y*koefRes_h,r.width(),y*koefRes_h); }
void QtRPT::processMHeader(int &y, bool draw) { if (masterHeader.isNull()) return; QDomElement e = masterHeader.toElement(); if (draw) drawField(masterHeader,y); y += e.attribute("height").toInt(); //painter.drawLine(0,y*koefRes_h,r.width(),y*koefRes_h); }
void QtRPT::processMasterData(QPrinter *printer, int &y, bool draw, int pageReport) { if (recordCount.size() > 0) { if (pageReport < recordCount.size() && recordCount.at(pageReport) > 0) { if (!masterData.isNull()) { for (int i = 0; i < recordCount.at(pageReport); i++) { m_recNo = i; int yPF = 0; if (!pageFooter.isNull()) { QDomElement pf = pageFooter.toElement(); yPF = pf.attribute("height").toInt(); } int yMF = 0; if (!masterFooter.isNull()) { QDomElement mf = masterFooter.toElement(); yMF = mf.attribute("height").toInt(); } QDomElement e = masterData.toElement(); if (y + e.attribute("height").toInt() > ph-mb-mt-yPF-yMF) { newPage(printer, y, draw); processMHeader(y,draw); } if (draw) drawField(masterData,y); else fillListOfValue(masterData); y += e.attribute("height").toInt(); //painter.drawLine(0,y*koefRes_h,r.width(),y*koefRes_h); } } } } }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); drawField(); glFlush(); glutSwapBuffers(); }
void QtRPT::processPHeader(int &y, bool draw) { if (pageHeader.isNull()) return; QDomElement e = pageHeader.toElement(); if (draw) drawField(pageHeader,y); y += e.attribute("height").toInt(); //painter.drawLine(0,y*koefRes_h,pw*koefRes_h,y*koefRes_h); }
void drawSet(AGDrawBuffer* DBuf, struct Field* field, struct Player* player) { int i; //Init agDrawBufferInit( DBuf , DrawBuffer ); agDrawSETDAVR( DBuf , 0 , 0 , aglGetDrawFrame() , 0 , 0 ); agDrawSETDAVF( DBuf, 0, 0, s(FB_WIDTH), s(FB_HEIGHT) ); //白背景 agDrawSETFCOLOR( DBuf, ARGB( 255, 255, 255, 255 ) ); agDrawSETDBMODE( DBuf, 0xff, 0, 0, 1 ); agDrawSPRITE( DBuf, 0, 0, 0, s(FB_WIDTH), s(FB_HEIGHT) ); //フィールド drawField( DBuf, field); //戦艦 for(i=0;i<5;i++){ drawBattleShip(DBuf, &(player->battleShip[i])); } /* //数字を描画する場所の白い四角 agDrawSETFCOLOR( DBuf, ARGB( 255, 255, 255, 255 ) ); agDrawSETDBMODE( DBuf, 0xff, 0, 0, 1 ); agDrawSPRITE( DBuf, 0, 100-20, 100-20, 100+50*10+20, 100+90+20); //数字の描画 drawNumberGraph(20131120, 100,100,50,90,10,DBuf); */ }
void drawGame(void) { if (state == STATE_LEAVE) return; if (isInvalid) { arduboy.clear(); if (state == STATE_ISSUES) { drawIssues(); } else if (state == STATE_RESULT) { drawResult(); } else { drawField(); if (state == STATE_PLAYING) { drawStrings(); drawCursor(); } if (blinkFrameFrames > 0 && blinkFlg) arduboy.drawRect(0, 0, WIDTH, HEIGHT, WHITE); } isInvalid = false; } if (state == STATE_MENU || state == STATE_RESULT) { drawMenuItems(false); arduboy.setRGBled(0, 0, 0); } else { if (state == STATE_OVER) drawOverAnimation(); arduboy.setRGBled(ledRGB[0] * vanishFlashFrames, ledRGB[1] * vanishFlashFrames, ledRGB[2] * vanishFlashFrames); } }
PaintField::PaintField(QObject *parent, float sF): BMPImage(parent) { scaleFactor = sF; bitmap = QImage(FIELD_WIDTH*scaleFactor, FIELD_HEIGHT*scaleFactor, QImage::Format_ARGB32); drawField(); }
void showLeaderboard(){ char d[10][50]; int i; FILE * f = fopen(leadersTableFile, "r"); if(NULL == f){ initLeaderboardFile(); fclose(f); f = fopen(leadersTableFile, "r"); if(NULL == f) exit(1); } for(i = 0; i < 10; i++){ fgets(d[i], 50, f); } drawField(fieldX - 1, 0, 40, 24, BACK_WHITE | BACKGROUND_INTENSITY); setTextColor(BACK_WHITE | BACKGROUND_INTENSITY); moveCursor(fieldX + 2, 0); printf("LEADERBOARD:"); for(i = 0; i < 10; i++){ moveCursor(fieldX + 2, 2*i + 2); printf(d[i]); } moveCursor(fieldX + 2, 23); printf("Press any key to continue..."); getch(); fclose(f); }
void nextTurn(int field[n][n],int crossFlag) { if (crossFlag%2==0) printf("\nX turn\nEnter X Y (sample '1 2' or '3 1'):\n"); else printf("\nO turn\nEnter X Y (sample '1 2' or '3 1'):\n"); int x,y; do { scanf("%d%d",&x,&y); if (field[x-1][y-1]!=0) printf("\nIncorrect move. Please repeat again.\nEnter X Y (sample '1 2' or '3 1'):\n"); } while (field[x-1][y-1]!=0); system("cls"); if (crossFlag%2==0) field[x-1][y-1]=1; else field[x-1][y-1]=2; drawField(field); if (endGame(field)==1 && crossFlag%2==0) printf("\nX Win!\n"); if (endGame(field)==1 && crossFlag%2!=0) printf("\nO Win!\n"); if (endGame(field)==2) printf("\nDraw!\n"); }
void draw() { drawField(); drawWalls(); drawFruits(); drawInhabitants(); refreshNcurses(); }
void QtRPT::processMFooter(QPrinter *printer, int &y, bool draw) { if (masterFooter.isNull()) return; QDomElement e = masterFooter.toElement(); if (y + e.attribute("height").toInt() > ph-mb-mt-e.attribute("height").toInt()) newPage(printer, y, draw); if (draw) drawField(masterFooter,y); y += e.attribute("height").toInt(); }
void render(sf::RenderWindow& window, const Packman& packman, const Field& field) { window.clear(); drawField(window, field); // пакман рисуется после поля. window.draw(packman.shape); window.display(); }
void QtRPT::processRSummary(QPrinter *printer, int &y, bool draw) { if (reportSummary.isNull()) return; QDomElement e = reportSummary.toElement(); if (y + e.attribute("height").toInt() > ph-mb-mt-e.attribute("height").toInt()) newPage(printer, y, draw); if (draw) drawField(reportSummary,y); y += e.attribute("height").toInt(); //painter.drawLine(0,y*koefRes_h,pw*koefRes_h,y*koefRes_h); }
void QtRPT::processPFooter(bool draw) { if (pageFooter.isNull()) return; QDomElement e = pageFooter.toElement(); int y1 = ph-mb-mt-e.attribute("height").toInt(); if (draw) { drawField(pageFooter,y1); } //painter.drawLine(0,y1*koefRes_h,pw*koefRes_h,y1*koefRes_h); }
void RenderArea::paintEvent(QPaintEvent *) { QPainter painter(this); drawField(painter); drawStartPos(painter); drawEndPos(painter); drawObstacles(painter); drawNodes(painter); emit painting(); }
void MiniMap::paint(){ mLabel->setPixmap(QPixmap::fromImage(*this)); mLabel->repaint(); ++mRefreshCount; if(mRefreshCount > mRefreshRate){ this->fill(COLOR_GREEN); mRefreshCount = 0; } drawField(); }
void FieldSim::drawStepByStep(const Field* pField, const std::string& path) { int lambdasCollected = 0; int score = 0; std::string state = "In progress"; int lambdaCount = pField->getLambdaCount(); int numOfSteps = 0; drawField(pField, 0); if (path.length() > 0) { const Field *oldField = new Field(*pField); for (unsigned int i = 0; i < path.length(); i++) { const Field *newField = calcNextState(oldField, path[i]); delete oldField; oldField = newField; if (!newField->isRobotAlive()) { score = 0; state = "Dead"; break; } else if (*newField->getLift() == *newField->getRobot()) { score += 50 * lambdasCollected - 1; state = "Finished"; drawField(newField, i + 1); break; } else if (lambdaCount > newField->getLambdaCount()) { lambdasCollected++; lambdaCount--; score += 25; } else if (path[i] == 'A') { score += 25 * lambdasCollected; state = "Aborted"; break; } drawField(newField, i + 1); numOfSteps++; score--; } delete oldField; std::cout << "Score: " << score << " NumSteps: " << numOfSteps << " NumLambdas: " << lambdasCollected << " LC: " << pField->getLambdaCount() << " State " << state << "\n"; } }
int main() { int field[3][3]= {0},crossFlag=0; drawField(field); while (endGame(field)==0) { nextTurn(field, crossFlag); ++crossFlag; } return 0; }
void main(void) { short mx, my, tmx, tmy, ignoreBtn; char stat[14]; // TODO initialise variables with the riht value //mx = -1; //my = -1; //ignoreBtn = 0; lcd_init(); initIO(); adc_init(); lcd_clear(0); drawField(); for (;;) { tmx = (short) (2 - adc_getValue(1) / 255.0 * 2 + 0.5); tmy = (short) (2 - adc_getValue(2) / 255.0 * 2 + 0.5); if (tmy != my || tmx != mx) { drawMarker(mx, my, 0); if (fields[mx][my] == 1) { placePlayerMark(mx, my, 1); } drawMarker(mx = tmx, my = tmy, 1); } if (!BUTTON_RIGHT && !ignoreBtn && !fields[mx][my]) { ignoreBtn = 1; pushes++; placePlayerMark(mx, my, player); if (checkStatus(mx, my)) { lcd_clear(0); sprintf(stat, "Player %u won!", player); lcd_drawString(27, 4, 0, 4, 0, 0, &stat[0], 1, 1); lcd_flush(); break; } if (pushes == 9) { lcd_clear(0); sprintf(stat, "Undecided!"); lcd_drawString(32, 4, 0, 4, 0, 0, &stat[0], 1, 1); lcd_flush(); break; } if (player == 1) { player = 2; } else if (player == 2) { player = 1; } } else if (BUTTON_RIGHT && ignoreBtn) { ignoreBtn = 0; } } }
void initStat(Stat * stat){ clearScr(); drawField(fieldX - 1, fieldY - 1, 40, 4, BACK_WHITE | BACKGROUND_INTENSITY); setTextColor(BACK_WHITE | BACKGROUND_INTENSITY); moveCursor(fieldX + 2, fieldY - 1); printf("Please, enter your nickname:"); moveCursor(fieldX + 2, fieldY); scanf("%s", stat->nickname); stat->level = -1; do{ drawField(fieldX - 1, fieldY - 1, 40, 4, BACK_WHITE | BACKGROUND_INTENSITY); setTextColor(BACK_WHITE | BACKGROUND_INTENSITY); moveCursor(fieldX + 2, fieldY - 1); printf("Please, enter level(from 1 to 9):"); moveCursor(fieldX + 2, fieldY); scanf("%d", &stat->level); }while( stat->level > MAX_LEVEL || stat->level <= 0); clearScr(); stat->score = 0; stat->blocksNum = INIT_BLOCKS_NUM; }
void printMatr(int length, int height, int matr[height][length], int isTurned, int toSwitch, short color){ int i, j, initX, x, y; setTextColor(color); y = 2; if(!isTurned){ if(toSwitch){ clearScr(); drawField(0, 0, COLS - 1, 2 + height*2); } initX = (COLS - length*6)/2; for(i = 0; i < height; i++){ x = initX; for(j = 0; j < length; j++){ moveCursor(x, y); printf("%5d", matr[i][j]); x += 6; } y +=2; } }else{ if(toSwitch){ clearScr(); drawField(0, 0, COLS - 1, 2 + length*2); } initX = (COLS - height*6)/2; for(i = 0; i < length; i++){ x = initX; for(j = 0; j < height; j++){ moveCursor(x, y); printf("%5d", matr[j][i]); x += 6; } y +=2; } } }
// Main function. int main(int argc, char** argv) { rowIndexNew = 10; colIndexNew = 55; initTerminal(); while (true) { drawField(); int key = getch(); moveTetromino(key); showTetromino(); usleep(1000); count++; // Arrow up will exit the program if (key == 65) {break;} } endwin(); }
void COverlappedWindow::drawGrid(HDC hdc) { for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { int x = i * cell_size_; int y = j * cell_size_; drawBitmap(hdc, x, y, digits[grid[i][j]], false); } } if (is_digit_pressed_) { drawBitmap(hdc, i_pressed_ * cell_size_, j_pressed_ * cell_size_, digits_pressed_[grid[i_pressed_][j_pressed_]], false); } drawField(hdc); }
MainWindow::MainWindow() { contents = new QWidget(this); mainImage = new QLabel(this); statistics = new QLabel(this); iteration = 0; QHBoxLayout *layout = new QHBoxLayout(); addMenu(); addToolbar(); drawField(); layout->addWidget(mainImage); layout->addWidget(statistics); contents->setLayout(layout); setCentralWidget(contents); }
void COverlappedWindow::drawDigit(HDC hdc, int x, int y, int digit, bool redrawField) { BITMAP bm; HDC hdcMem = CreateCompatibleDC(hdc); HBITMAP hbmOld = reinterpret_cast<HBITMAP>(SelectObject(hdcMem, (digits[digit]))); GetObject(digits[digit], sizeof(bm), &bm); BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmOld); DeleteDC(hdcMem); if (redrawField) { drawField(hdc); } }
robotField::robotField(QGraphicsView *parent) : QGraphicsView(parent) { //connect(this,SIGNAL(mousePressed()),this,SLOT(drawRobot())); initZonesSize(); //widget = new QGraphicsWidget(); scene = new QGraphicsScene(); // scene->setItemIndexMethod(QGraphicsScene::BspTreeIndex); scene->setSceneRect(0,0,300,210); // setViewport(); // setMinimumSize(300,210); // setWindowTitle(tr("Simulation robot")); // setRenderHints(QPainter::Antialiasing); setScene(scene); drawField(); // // drawRobot(); // *(scene->addRect(10,10,10,10)); }
void drawGameScene(sf::RenderWindow &window, const GameScene &scene) { drawField(window, scene.field); // Персонажи рисуются после поля. drawPackman(window, scene.packman); // pair имеет тип `const std::pair<const GhostId, Ghost> &` for (const auto &pair : scene.ghosts) { drawGhost(window, pair.second); } if ((scene.gameState == GameState::PlayerLosed) || (scene.gameState == GameState::PlayerWon)) { window.draw(scene.gameOverBackground); window.draw(scene.gameOverLabel); } }