![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Haris Šemić, Emina Šarić
Revision 3:27c6c5d1fe5f, committed 2014-06-12
- Comitter:
- tim008
- Date:
- Thu Jun 12 13:57:57 2014 +0000
- Parent:
- 2:f923d0ef12ec
- Commit message:
- Haris ?emi?, Emina ?ari?
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f923d0ef12ec -r 27c6c5d1fe5f main.cpp --- a/main.cpp Thu Jun 12 13:09:51 2014 +0000 +++ b/main.cpp Thu Jun 12 13:57:57 2014 +0000 @@ -13,8 +13,8 @@ DigitalIn SW(dp9); -char detektirajPozadinu(int x, int y) -{ +int detektirajPozadinu(int x, int y) +{/* if(x>83 || x<0 || y>47 || y<0) return 'x'; int brRubnih(0), brCrnih(0); unsigned char gore,dole,lijevo,desno; @@ -36,7 +36,41 @@ else if(dole == 'x') brRubnih++; int brBijelih(4-brCrnih-brRubnih); if(brBijelih < brCrnih) return 'c'; - return 'b'; + return 'b';*/ + + if(x>83 || x<0 || y<0 || y>47) return -1; + int gore,dole,desno,lijevo; + + if(x == 0) lijevo = -1; + else { + lijevo = displej.getPixel(x-1,y); + if(lijevo != 0) lijevo=1; + } + if(x == 83) desno = -1; + else { + desno = displej.getPixel(x+1,y); + if(desno !=0) desno=1; + } + if(y == 0) dole = -1; + else { + dole = displej.getPixel(x,y-1); + if(dole!=0) dole=1; + } + if(y == 47) gore = -1; + else { + gore = displej.getPixel(x,y+1); + if(gore!=0) gore=1; + } + int okolo[4]={gore,dole,lijevo,desno}; + int clear(0),set(0),rub(0); + for(int i=0;i<4;i++) { + if(okolo[i]==1) set++; + if(okolo[i]==0) clear++; + if(okolo[i]==-1) rub++; + } + if(set>clear) return 1; + if(clear>set) return 0; + return -1; } void postaviKursor(int x, int y) @@ -79,11 +113,6 @@ } } while(1) { - /* if(pc.readable() == 1) { - if(pc.getc() != 'x') { - - } - } */ if(VRx<1.0/3.0) { if (x>0) { x--;