void gradientfillbyselection(ZZTworld * myworld, selection fillsel, patbuffer pbuf, gradline grad, int randomseed, int preview, displaymethod * mydisplay) { int x = -1, y = 0; ZZTtile pattern = pbuf.patterns[pbuf.pos]; ZZTblock * prevBlock = NULL; if (randomseed != 0) srand(randomseed); if (preview) { prevBlock = zztBlockDuplicate(zztBoardGetCurPtr(myworld)->bigboard); if (prevBlock == NULL) return; } /* Plot the patterns */ while (!nextselected(fillsel, &x, &y)) { pattern = pbuf.patterns[gradientscaledistance(grad, x, y, pbuf.size-1)]; if (!preview) { zztPlot(myworld, x, y, pattern); } else { zztTilePlot(prevBlock, x, y, pattern); } } if (preview) { drawblock(mydisplay, prevBlock, 0, 0); zztBlockFree(prevBlock); } }
static void killcell (struct state *st, cell *c) { c->prev->next = c->next; c->next->prev = c->prev; c->prev = 0; c->speed = 0.0; drawblock (st, cell_x(c), cell_y(c), c->col); }
static void w32_drawblock(int x, int y, int w, int h, GrxColor color) { RECT Rect; GRX_ENTER(); drawblock(x, y, w, h, color); Rect.left = x; Rect.top = y; Rect.right = x + w; Rect.bottom = y + h; InvalidateRect(hGRXWnd, &Rect, FALSE); GRX_LEAVE(); }
void paste(keveditor * myeditor) { ZZTworld * myworld = myeditor->myworld; int done = 0; int x = 0, y = 0; selection pasteselection; if (myeditor->copyBlock == NULL) return; /* Initialize valid pasting region selection */ initselection(&pasteselection, ZZT_BOARD_X_SIZE, ZZT_BOARD_Y_SIZE); if (myeditor->selectmode) { /* Only paste within the selected region */ copyselection(pasteselection, myeditor->selCurrent); } else { /* Paste everywhere */ setselection(pasteselection); } /* Don't paste over the player */ unselectpos(pasteselection, myworld->boards[zztBoardGetCurrent(myworld)].plx, myworld->boards[zztBoardGetCurrent(myworld)].ply); while (!done) { int key; ZZTblock * previewBlock; /* Merge the current board and copyBlock onto the previewBlock */ previewBlock = zztBlockDuplicate(zztBoardGetBlock(myeditor->myworld)); pasteblock(previewBlock, myeditor->copyBlock, pasteselection, myeditor->copySelection, x, y); /* Draw the preview */ drawblock(myeditor->mydisplay, previewBlock, 0, 0); key = myeditor->mydisplay->getch(); movebykeystroke(key, &x, &y, -myeditor->copyBlock->width, -myeditor->copyBlock->height, myeditor->copyBlock->width, myeditor->copyBlock->height, myeditor->mydisplay); if (key == ' ' || key == DKEY_ENTER) { pasteblock(zztBoardGetBlock(myeditor->myworld), myeditor->copyBlock, pasteselection, myeditor->copySelection, x, y); /* Set the paramcount for the board */ zztBoardSetParamcount(myeditor->myworld, zztBoardGetBlock(myeditor->myworld)->paramcount); done = 1; } if (key == DKEY_ESC) done = 1; zztBlockFree(previewBlock); } deleteselection(&pasteselection); myeditor->clearselectflag = 1; myeditor->updateflags |= UD_BOARD | UD_OBJCOUNT; }
static void update (struct state *st) { cell *a; for (a = st->head->next; a != st->tail; a = a->next) { static const XPoint all_coords[] = {{-1, -1}, {-1, 1}, {1, -1}, {1, 1}, {-1, 0}, { 1, 0}, {0, -1}, {0, 1}, {99, 99}}; const XPoint *coords = 0; if (a->speed == 0) continue; a->growth += a->speed; if (a->growth >= st->diaglim) { coords = all_coords; } else if (a->growth >= st->orthlim) { coords = &all_coords[4]; } else { continue; } while (coords->x != 99) { int x = cell_x(a) + coords->x; int y = cell_y(a) + coords->y; coords++; if (x < 0) x = st->arr_width - 1; else if (x >= st->arr_width) x = 0; if (y < 0) y = st->arr_height - 1; else if (y >= st->arr_height) y = 0; newcell (st, &st->arr[y * st->arr_width + x], a->col, a->speed); } if (a->growth >= st->diaglim) killcell (st, a); } randblip (st, (st->head->next) == st->tail); for (a = st->head->next; a != st->tail; a = a->next) { if (a->isnext) { a->isnext = 0; a->speed = a->nextspeed; a->growth = 0.0; a->col = a->nextcol; drawblock (st, cell_x(a), cell_y(a), a->col + st->count); } } }
/* The main drawing function. */ void DrawGLScene() { // printf("printf here %d %f\n",w_flag,boost_factor); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if(lookAt_flag==1){ printf("jere \n"); gluLookAt(50.0f,50.0f,50.0f,10.0f,10.0f,-10.0f,0,1,0); } else{ printf("here at 000 \n"); gluLookAt(00.0f,10.0f,10.0f,10.0f,10.0f,-10.0f,0,1,0); } if(w_flag == 0) { _model->setAnimation("run"); } else{ boost_factor=1.0f; _model->setAnimation("stand"); } GLfloat xtrans, ztrans, ytrans; GLfloat sceneroty; // calculate translations and rotations. xtrans = -xpos; ztrans = -zpos; ytrans = -walkbias-0.25f; sceneroty = 360.0f - yrot; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); glRotatef(lookupdown, 1.0f, 0, 0); glRotatef(sceneroty, 0, 1.0f, 0); glTranslatef(xtrans, ytrans, ztrans); // ---> to execute the draw function !! // glScalef(0.5f,0.5f,0.5f); glTranslatef(-x_dimension/2-3,0,-2); // Let us draw something !! int i,j; float scale ; for(i=0;i<x_dimension;i=i++){ for(j=0;j<y_dimension;j=j++){ glPushMatrix(); // glScalef(1.0f,1.0f,1.0f); // printf("%d %d for block i ,j \n",i,j); if(WORLD[i][j]==4){ scale = Scale; // glScalef(1.0f,Scale,1.0f); } else if(WORLD[i][j]==2){ scale = 2.0; } else if(WORLD[i][j]==3){ scale =0.1; } else if(WORLD[i][j]==6){ // 6 denotes moving tiles ! glPushMatrix(); drawblock(2*(float)i+block_left,6.0f,-2*(float)j,0.04); glPopMatrix(); } else scale=1; if(WORLD[i][j]!=3&&WORLD[i][j]!=6) // glRotatef(rquad,0.0f,1.0f,0.0f); // Rotate The Cube On X, Y, and Z drawblock(2*(float)i,0.0f,-2*(float)j,scale); glPopMatrix(); } } // makecoin(0,6,0,0); for(i=0;i<x_dimension;i=i++) for(j=0;j<y_dimension;j++){ // -- > HERE WE ARE GOING TO DRAW !! FOOD COINS AND MAYBE BARRIERS , BOOST ! , POWER !! :D :D !! glPushMatrix(); if(TOKENS[i][j]!=0){ int k = WORLD[i][j]; float zz; if(k == 3){ zz=1.5f; } else if(k == 2 ){ zz=1.5f*3.0f; } else if(k==4){ zz=1.5f*2.0f; } else zz=2.0f; if(TOKENS[i][j]==5){ // here we are going to make a pillar !! :D :D :D :D // printf("here making the pillar ! \n"); glPushMatrix(); // glScalef(0.5f,1.0f,0.5f); drawblock(2*(float)i,0.0f,-2*(float)j,6); glPopMatrix(); } else makecoin(2*(float)i,zz,-2*(float)j,TOKENS[i][j]); } glPopMatrix(); } Robot_func(); /* glPushMatrix(); drawblock(0.0,0.0,0.0); glPopMatrix(); glPushMatrix(); glRotatef(rquad,0.0f,1.0f,0.0f); // Rotate The Cube On X, Y, and Z drawblock(2.0,0.0,0.0); glPopMatrix();*/ rquad-=1.0f; // Decrease The Rotation Variable For The Cube // swap the buffers to display, since double buffering is used. glutSwapBuffers(); }
void drawboard(int startx, int starty, int blocksize) { //Integers declaration int iter,iterx,itery; //Constant integers decalaration int scale = blocksize * 15; setcolor(BLACK); //Draw boxes for ludo board:- //~~~~~~~~~~~~~~~~~~~~~~~~~ { int locationfromx, locationfromy, locationtox, locationtoy; for (iter = 1; iter <=4; iter++) { switch(iter) { case 1: // For the upper portion locationfromx = 6; locationfromy = 0; locationtox = 8; locationtoy = 5; break; case 2: // For the left portion locationfromx = 0; locationfromy = 6; locationtox = 5; locationtoy = 8; break; case 3: // For the right locationfromx = 9; locationfromy = 6; locationtox = 14; locationtoy = 8; break; case 4: // For the lower portion locationfromx = 6; locationfromy = 9; locationtox = 8; locationtoy = 14; break; } for(itery = (blocksize*locationfromy) + starty; itery <= (blocksize * locationtoy) + starty; itery = itery + blocksize) for(iterx = (blocksize*locationfromx)+startx; iterx <= (blocksize * locationtox) + startx; iterx = iterx + blocksize) { rectangle (iterx, itery, iterx + blocksize, itery + blocksize); } } // Draw home in middle line(startx + blocksize * 6, starty + blocksize * 6, startx + blocksize * 9, starty + blocksize * 9); line(startx + blocksize * 9, starty + blocksize * 6, startx + blocksize * 6, starty + blocksize * 9); setfillstyle(SOLID_FILL, BLUE); floodfill( startx + blocksize * 6.5, starty + blocksize * 7.5, BLACK); setfillstyle(SOLID_FILL, GREEN); floodfill( startx + blocksize * 7.5, starty + blocksize * 6.5, BLACK); setfillstyle(SOLID_FILL, RED); floodfill( startx + blocksize * 8.5, starty + blocksize * 7.5, BLACK); setfillstyle(SOLID_FILL, YELLOW); floodfill( startx + blocksize * 7.5, starty + blocksize * 8.5, BLACK); setcolor(BLACK); setfillstyle(SOLID_FILL, WHITE); fillellipse(startx + blocksize * 7.5, starty + blocksize * 7.5, blocksize, blocksize); settextjustify(CENTER_TEXT, CENTER_TEXT); outtextxy(startx + blocksize * 7.5, starty + blocksize * 7.5, "Home"); } //End draw boxes //Draw blue player's home area setcolor(BLUE); setfillstyle(CLOSE_DOT_FILL, BLUE); bar(startx, starty, startx + blocksize * 6 - 1, starty + blocksize * 6 - 1); setfillstyle(SOLID_FILL, WHITE); bar(startx + blocksize * 0.5, starty + blocksize * 0.5, startx + blocksize * 5.5, starty + blocksize * 5.5); setfillstyle(SOLID_FILL, BLUE); circle(startx + blocksize + blocksize / 2 , starty + blocksize + blocksize / 2 , blocksize / 2 ); circle(startx + blocksize * 4 + blocksize / 2 , starty + blocksize + blocksize / 2 , blocksize / 2 ); circle(startx + blocksize + blocksize / 2 , starty + blocksize * 4 + blocksize / 2 , blocksize / 2 ); circle(startx + blocksize * 4 + blocksize / 2 , starty + blocksize * 4 + blocksize / 2 , blocksize / 2 ); line(startx + blocksize * 2, starty + blocksize * 1.5, startx + blocksize * 2 , starty + blocksize * 4.5); line(startx + blocksize * 4, starty + blocksize * 1.5, startx + blocksize * 4 , starty + blocksize * 4.5); line(startx + blocksize * 1.5, starty + blocksize * 2, startx + blocksize * 4.5, starty + blocksize * 2); line(startx + blocksize * 1.5, starty + blocksize * 4, startx + blocksize * 4.5, starty + blocksize * 4); floodfill(startx + blocksize * 2.5, starty + blocksize * 2.5, BLUE); //Draw green player's home area setcolor(GREEN); setfillstyle(CLOSE_DOT_FILL, GREEN); bar(startx + blocksize * 9 + 1, starty, startx + blocksize * 15, starty + blocksize * 6 - 1); setfillstyle(SOLID_FILL, WHITE); bar(startx + blocksize * 9.5, starty + blocksize * 0.5, startx + blocksize * 14.5, starty + blocksize * 5.5); setfillstyle(SOLID_FILL, GREEN); circle(startx + blocksize * 10.5, starty + blocksize * 1.5, blocksize / 2 ); circle(startx + blocksize * 13.5, starty + blocksize * 1.5, blocksize / 2 ); circle(startx + blocksize * 10.5, starty + blocksize * 4.5, blocksize / 2 ); circle(startx + blocksize * 13.5, starty + blocksize * 4.5, blocksize / 2 ); line(startx + blocksize * 11, starty + blocksize * 1.5, startx + blocksize * 11 , starty + blocksize * 4.5); line(startx + blocksize * 13, starty + blocksize * 1.5, startx + blocksize * 13 , starty + blocksize * 4.5); line(startx + blocksize * 10.5, starty + blocksize * 2, startx + blocksize * 13.5, starty + blocksize * 2); line(startx + blocksize * 10.5, starty + blocksize * 4, startx + blocksize * 13.5, starty + blocksize * 4); floodfill(startx + blocksize * 12, starty + blocksize * 2.5, GREEN); //Draw yellow player's home area setcolor(BLACK); setfillstyle(CLOSE_DOT_FILL, YELLOW); bar(startx, starty + blocksize * 9 + 1, startx + blocksize * 6 - 1, starty + blocksize * 15); setfillstyle(SOLID_FILL, WHITE); bar(startx + blocksize * 0.5, starty + blocksize * 9.5, startx + blocksize * 5.5, starty + blocksize * 14.5); setfillstyle(SOLID_FILL, BLACK); circle(startx + blocksize * 1.5, starty + blocksize * 10.5, blocksize / 2 ); circle(startx + blocksize * 4.5, starty + blocksize * 10.5, blocksize / 2 ); circle(startx + blocksize * 1.5, starty + blocksize * 13.5 , blocksize / 2 ); circle(startx + blocksize * 4.5, starty + blocksize * 13.5 , blocksize / 2 ); line(startx + blocksize * 2, starty + blocksize * 10.5, startx + blocksize * 2 , starty + blocksize * 13.5); line(startx + blocksize * 4, starty + blocksize * 10.5, startx + blocksize * 4 , starty + blocksize * 13.5); line(startx + blocksize * 1.5, starty + blocksize * 11, startx + blocksize * 4.5, starty + blocksize * 11); line(startx + blocksize * 1.5, starty + blocksize * 13, startx + blocksize * 4.5, starty + blocksize * 13); floodfill(startx + blocksize * 2.5, starty + blocksize * 11.5, BLACK); //Draw red player's home area setcolor(RED); setfillstyle(CLOSE_DOT_FILL, RED); bar(startx + blocksize * 9 + 1, starty + blocksize * 9 + 1, startx + blocksize * 15, starty + blocksize * 15); setfillstyle(SOLID_FILL, WHITE); bar(startx + blocksize * 9.5, starty + blocksize * 9.5, startx + blocksize * 14.5, starty + blocksize * 14.5); setfillstyle(SOLID_FILL, RED); circle(startx + blocksize * 10.5, starty + blocksize * 10.5, blocksize / 2 ); circle(startx + blocksize * 13.5, starty + blocksize * 10.5, blocksize / 2 ); circle(startx + blocksize * 10.5, starty + blocksize * 13.5, blocksize / 2 ); circle(startx + blocksize * 13.5, starty + blocksize * 13.5, blocksize / 2 ); line(startx + blocksize * 11, starty + blocksize * 10.5, startx + blocksize * 11 , starty + blocksize * 13.5); line(startx + blocksize * 13, starty + blocksize * 10.5, startx + blocksize * 13 , starty + blocksize * 13.5); line(startx + blocksize * 10.5, starty + blocksize * 11, startx + blocksize * 13.5, starty + blocksize * 11); line(startx + blocksize * 10.5, starty + blocksize * 13, startx + blocksize * 13.5, starty + blocksize * 13); floodfill(startx + blocksize * 12, starty + blocksize * 11.5, RED); //Draw stops and home paths on board for(iterx = 0; iterx <= 5; iterx++) for(itery = 6; itery <= 8; itery++) drawblock(iterx,itery); for(iterx = 6; iterx <= 8; iterx++) for(itery = 0; itery <= 5; itery++) drawblock(iterx,itery); for(iterx = 9; iterx <= 14; iterx++) for(itery = 6; itery <= 8; itery++) drawblock(iterx,itery); for(iterx = 6; iterx <= 8; iterx++) for(itery = 9; itery <= 14; itery++) drawblock(iterx,itery); }