MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->chatTimeout = true; this->connected = false; this->currColorId = 2; // czarny this->lastColorButton = ui->blackPushButton; this->graphicsScene = new QGraphicsScene(); ui->graphicsView->setScene(graphicsScene); this->currentPen.setColor(QColor("black")); connect(ui->graphicsView,SIGNAL(drawPoint(QPoint)),this,SLOT(drawPoint(QPoint))); connect(ui->graphicsView,SIGNAL(drawLineTo(QPoint)),this,SLOT(drawLineTo(QPoint))); connect(ui->clearPushButton,SIGNAL(clicked()),this,SLOT(clearView())); connect(ui->redPushButton,SIGNAL(clicked()),this,SLOT(switchColor())); connect(ui->greenPushButton,SIGNAL(clicked()),this,SLOT(switchColor())); connect(ui->blackPushButton,SIGNAL(clicked()),this,SLOT(switchColor())); connect(ui->sendMessagePushButton,SIGNAL(clicked()),this,SLOT(sendMessage())); connect(ui->chatLineEdit,SIGNAL(returnPressed()),this,SLOT(sendMessage())); this->socket = new KalSocket(); this->chatTimer = new QTimer(); connect(socket,SIGNAL(connected()),this,SLOT(connectionSuccess())); connect(socket,SIGNAL(error(QAbstractSocket::SocketError)), this,SLOT(displayError(QAbstractSocket::SocketError))); connect(socket,SIGNAL(pointsReceived(int,int,int,KalSocket::DrawType)), this,SLOT(pointsReceived(int,int,int,KalSocket::DrawType))); connect(socket,SIGNAL(clear()),graphicsScene,SLOT(clear())); connect(socket,SIGNAL(someoneLoggedIn(QString)),this,SLOT(someoneLoggedIn(QString))); connect(socket,SIGNAL(chatMessage(QString,QString)),this,SLOT(addMessage(QString,QString))); connect(socket,SIGNAL(nicknames(QList<QString>)),this,SLOT(getNicknames(QList<QString>))); connect(socket,SIGNAL(logout(QString)),this,SLOT(someoneLoggedOut(QString))); connect(socket,SIGNAL(drawStart(QString)),this,SLOT(drawStart(QString))); connect(socket,SIGNAL(gotSettings(ServerSettings)),this,SLOT(getSettings(ServerSettings))); connect(socket,SIGNAL(errorMessage(QString)),this,SLOT(showMessage(QString))); connect(ui->wantDrawCheckBox,SIGNAL(toggled(bool)),this,SLOT(wantDrawToggled(bool))); // actiony z menu: Polaczenie connect(ui->actionPo_cz,SIGNAL(triggered()),this,SLOT(connectWindowExec())); // laczymy sie connect(ui->actionRoz_cz,SIGNAL(triggered()),this,SLOT(disconnect())); // rozlaczamy sie connect(ui->actionZako_cz,SIGNAL(triggered()),this,SLOT(close())); // koniec programu // timer connect(chatTimer,SIGNAL(timeout()),this,SLOT(timeout())); connect(ui->progressBar,SIGNAL(full()),this,SLOT(drawTimeout())); // inne this->disableActions(false); // Polacz - aktywne, Rozlacz - nieaktywne }
void GraphicsLib::fillRect(int_least16_t x0, int_least16_t y0, int_least16_t w, int_least16_t h, uint_least16_t color) { uint_least32_t size; if(x0 >= lcd_width) { x0 = lcd_width-1; } if(y0 >= lcd_height) { y0 = lcd_height-1; } if(x0+w >= lcd_width) { w = lcd_width-x0; } if(y0+h >= lcd_height) { h = lcd_height-y0; } setArea(x0, y0, x0+w-1, y0+h-1); drawStart(); for(size=((uint_least32_t)w*h); size!=0; size--) { draw(color); } drawStop(); return; }
Github::Github(QWidget *parent) : QMainWindow(parent), ui(new Ui::Github) { ui->setupUi(this); drawStart(); }
void Github::backToStartClicked() { delete backToStart; delete talker; delete repositories; delete userName; drawStart(); }
//Game Loop bool ce_game::start_game(){ //Create the tick timer functions LOCK_VARIABLE(ticks); LOCK_FUNCTION(ticker); install_int_ex(ticker, BPS_TO_TIMER(fps)); //----------GameLoop---------- while (isPlaying || end_timer > 0 || start_timer > 0){ //Wait until a tick has happened while(ticks == 0){ rest(1); } //If there is a tick pending update the logic and remve the tick while(ticks > 0){ //Do game logic or decriment end/start timers if (isPlaying){ checkEscape(); update(); checkState(); }else if (start_timer >= 0){ if (start_timer == 0){ isPlaying = true; start_timer = -1; }else{ start_timer--; } }else{ end_timer--; } ticks--; } //Draw game or start/end screens if (start_timer > 0){ drawStart(); }else if (isPlaying || end_timer > 150){ draw(); }else{ drawEnd(); } } return hasWon; }
void GraphicsLib::drawPixel(int_least16_t x0, int_least16_t y0, uint_least16_t color) { if((x0 >= lcd_width) || (y0 >= lcd_height)) { return; } setArea(x0, y0, x0, y0); drawStart(); draw(color); drawStop(); return; }
void MI0283QT9::drawPixel(uint16_t x0, uint16_t y0, uint16_t color) { if((x0 >= lcd_width) || (y0 >= lcd_height)) { return; } setCursor(x0, y0); drawStart(); draw(color); drawStop(); return; }
void renderDisplayStart(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt( 0.0f, 0.0f, 10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); drawStart(0.0f); setOrthographicProjection(); glPushMatrix(); glLoadIdentity(); glColor3f(0.0f, 0.0f, 1.0f); renderBitmapString(315,250,1,fontBitmap,(char *)"START"); glPopMatrix(); restorePerspectiveProjection(); glutSwapBuffers(); }
void MI0283QT2::clear(uint16_t color) { uint16_t size; setArea(0, 0, lcd_width-1, lcd_height-1); drawStart(); for(size=(320UL*240UL/8UL); size!=0; size--) { draw(color); //1 draw(color); //2 draw(color); //3 draw(color); //4 draw(color); //5 draw(color); //6 draw(color); //7 draw(color); //8 } drawStop(); return; }
void GraphicsLib::fillScreen(uint_least16_t color) { uint_least32_t size; setArea(0, 0, lcd_width-1, lcd_height-1); drawStart(); for(size=(((uint_least32_t)lcd_width*lcd_height)/8UL); size!=0; size--) { draw(color); //1 draw(color); //2 draw(color); //3 draw(color); //4 draw(color); //5 draw(color); //6 draw(color); //7 draw(color); //8 } drawStop(); return; }
int main() { sdcard_Init(); initVGA(); initAnonProfile(); brickmap = malloc(sizeof(BrickMap)); currentLevel->paddle = malloc(sizeof(Paddle)); currentLevel->buff=malloc(sizeof(Buff)); int i,j; for(i=0;i<maxBalls;i++) currentLevel->ball[i] = malloc(sizeof(Ball)); for(i=0;i<maxRows;i++) for(j=0;j<bricksPerRow;j++) currentLevel->bricks[i][j]=malloc(sizeof(Brick)); level=1; //pre load the root menu getMenu(¤tMenu,rootMenu, 1); //allocate memory for level farm //set the game to playing prevState=currentState=Playing; //look up the level from level farm and load it into currentLevel levelLookUp(brickmap,level); initLevel(*brickmap); drawStart(currentLevel); //this is optional here swapBuffers(); drawStart(currentLevel); runCountDown(); //count down from three initInterrupt(); //start the game (we dont need to right off the bat (probably shouldnt) int counter=0; //so were not doing direct IO reads on EVERY iteration (we could timer this buttttt no) while(1) { //input to state machine counter++; if(counter>22000) { counter=0; if(getMenuPB()) { while(getMenuPB() != 0); if(currentState == Playing) changeState(MenuShow); } } //flicker changes if(prevState != currentState) { if(currentState == Playing) { clearScreen(); drawStart(currentLevel); //this is optional here swapBuffers(); drawStart(currentLevel); runCountDown(); initInterrupt(); }else { stopInterrupt(); getMenu(¤tMenu,rootMenu, 1); clearScreen(); drawStart(currentLevel); //this is optional here swapBuffers(); drawStart(currentLevel); drawMenu(currentMenu); } prevState = currentState; } //state machine if(currentState == MenuShow) { menuLoop(); }else //while were playing we will have to check for other things (all balls gone etc.) { if(currentLevel->brickCount<=0) { printf("starting new level \n"); stopInterrupt(); level++; levelLookUp(brickmap,level); initLevel(*brickmap); prevState= currentState - 1; currentState = Playing; printf("finished starting new level \n"); } } } return 0; }
int_least16_t GraphicsLib::drawChar(int_least16_t x, int_least16_t y, char c, uint_least16_t color, uint_least16_t bg, uint_least8_t size) { int_least16_t ret, pos; #if FONT_WIDTH <= 8 uint_least8_t data, mask; #elif FONT_WIDTH <= 16 uint_least16_t data, mask; #elif FONT_WIDTH <= 32 uint_least32_t data, mask; #endif uint_least8_t i, j, width, height; const PROGMEM uint8_t *ptr; #if FONT_WIDTH <= 8 pos = (c-FONT_START)*(8*FONT_HEIGHT/8); #elif FONT_WIDTH <= 16 pos = (c-FONT_START)*(16*FONT_HEIGHT/8); #elif FONT_WIDTH <= 32 pos = (c-FONT_START)*(32*FONT_HEIGHT/8); #endif ptr = &font_PGM[pos]; width = FONT_WIDTH; height = FONT_HEIGHT; size = size&0x7F; if(size <= 1) { ret = x+width; if((ret-1) >= lcd_width) { return lcd_width+1; } else if((y+height-1) >= lcd_height) { return lcd_width+1; } setArea(x, y, (x+width-1), (y+height-1)); drawStart(); for(; height!=0; height--) { #if FONT_WIDTH <= 8 data = pgm_read_byte(ptr); ptr+=1; #elif FONT_WIDTH <= 16 data = pgm_read_word(ptr); ptr+=2; #elif FONT_WIDTH <= 32 data = pgm_read_dword(ptr); ptr+=4; #endif for(mask=(1<<(width-1)); mask!=0; mask>>=1) { if(data & mask) { draw(color); } else { draw(bg); } } } drawStop(); }
void KalSocket::drawingStart(QByteArray byteArray) { emit drawStart(QString(byteArray).replace(QString("\n"),QString(""))); }
uint16_t MI0283QT9::drawChar(uint16_t x, uint16_t y, char c, uint8_t size, uint16_t color, uint16_t bg_color) { uint16_t ret; #if FONT_WIDTH <= 8 uint8_t data, mask; #elif FONT_WIDTH <= 16 uint16_t data, mask; #elif FONT_WIDTH <= 32 uint32_t data, mask; #endif uint8_t i, j, width, height; const prog_uint8_t *ptr; i = (uint8_t)c; #if FONT_WIDTH <= 8 ptr = &font_PGM[(i-FONT_START)*(8*FONT_HEIGHT/8)]; #elif FONT_WIDTH <= 16 ptr = &font_PGM[(i-FONT_START)*(16*FONT_HEIGHT/8)]; #elif FONT_WIDTH <= 32 ptr = &font_PGM[(i-FONT_START)*(32*FONT_HEIGHT/8)]; #endif width = FONT_WIDTH; height = FONT_HEIGHT; if(size <= 1) { ret = x+width; if((ret-1) >= lcd_width) { return lcd_width+1; } else if((y+height-1) >= lcd_height) { return lcd_width+1; } setArea(x, y, (x+width-1), (y+height-1)); drawStart(); for(; height!=0; height--) { #if FONT_WIDTH <= 8 data = pgm_read_byte(ptr); ptr+=1; #elif FONT_WIDTH <= 16 data = pgm_read_word(ptr); ptr+=2; #elif FONT_WIDTH <= 32 data = pgm_read_dword(ptr); ptr+=4; #endif for(mask=(1<<(width-1)); mask!=0; mask>>=1) { if(data & mask) { draw(color); } else { draw(bg_color); } } } drawStop(); }
void MI0283QT9::fillRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) { uint32_t size; uint16_t tmp, i; if(x0 > x1) { tmp = x0; x0 = x1; x1 = tmp; } if(y0 > y1) { tmp = y0; y0 = y1; y1 = tmp; } if(x1 >= lcd_width) { x1 = lcd_width-1; } if(y1 >= lcd_height) { y1 = lcd_height-1; } setArea(x0, y0, x1, y1); drawStart(); size = (uint32_t)(1+(x1-x0)) * (uint32_t)(1+(y1-y0)); tmp = size/8; if(tmp != 0) { for(i=tmp; i!=0; i--) { draw(color); //1 draw(color); //2 draw(color); //3 draw(color); //4 draw(color); //5 draw(color); //6 draw(color); //7 draw(color); //8 } for(i=size%8; i!=0; i--) { draw(color); } } else { for(i=size; i!=0; i--) { draw(color); } } drawStop(); return; }