Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <graphics.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <conio.h>
- using namespace std;
- int main( )
- {
- /* request autodetection */
- int gdriver = DETECT, gmode, errorcode;
- int midx, midy;
- /* initialize graphics and local variables */
- initgraph(&gdriver, &gmode, "");
- /* read result of initialization */
- errorcode = graphresult();
- if (errorcode != grOk) { /* an error occurred */
- printf("Graphics error: %s\n", grapherrormsg(errorcode));
- printf("Press any key to halt:");
- getch();
- exit(1); /* terminate with an error code */
- }
- initwindow( 800 , 800 , "Norbi face sah" );
- settextstyle(0, 0, 1);
- //setusercharsize(3,2,3,2);
- int posX=0;
- int linie=1;
- int posY=0;
- int coloana=1;
- int x,y;
- char xClick[3];
- char yClick[3];
- char posxCh[3];
- char posyCh[3];
- char pozitia[2];
- for(int i=0; i<64; i++){
- //determin posX in fct de i
- linie=i%8;
- posX=linie*50; //determin inceputul pe x
- //determin posY in fct de i
- coloana=i/8;
- posY=coloana*50; //determin inceputul pe y
- sprintf(posxCh,"%d",posX);
- sprintf(posyCh,"%d",posY);
- sprintf(pozitia,"%d",i);
- //in functie de pozitie colorez
- if(linie%2==0 && coloana%2==0){
- setfillstyle(SOLID_FILL, WHITE);
- }else if(linie%2==1 && coloana%2==1){
- setfillstyle(SOLID_FILL, WHITE);
- }else{
- setfillstyle(SOLID_FILL, BLACK);
- }
- //desenez tabla
- bar(posX,posY,posX+50,posY+50);
- //transform int in char
- sprintf(posxCh,"%d",posX);
- sprintf(posyCh,"%d",posY);
- sprintf(pozitia,"%d",i);
- //afisez pozitia si pixeli
- moveto(posX,posY);
- outtext(posyCh);
- }
- while( !kbhit() ){
- if(ismouseclick(WM_LBUTTONDOWN)){
- getmouseclick(WM_LBUTTONDOWN, x, y);
- sprintf(xClick,"%d",x);
- sprintf(yClick,"%d",y);
- }
- }
- closegraph( );
- return( 0 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement