Zeichen an gewisser Stelle überprüfen
-
wenn das so simple wäre würde ich net fragen, denn das tut dummerweise so net
-
Warum bist du so unhöflich?
Was heißt das tut nicht?
In welcher Zeile passiert welcher Fehler?
Wie wärs denn mal mit nem Debugger.
Notfalls in dem man an den Stellen sn denen was passiert in ein file einträgt was passiert. Auf dem Bildschirm ausgeben macht bei dir keinen Sinn, da sonst deine Graphik zerstört wird.
-
Entweder
a) Du machst keine direkte Ausgabe sondern bufferst immer alles und gibts es dann über eine Funktion aus. Das wäre eh viel besser weil du dann keine Nicht-Standard-Funktionen benötigst (gotoxy). Dann kannst du in deinem eigenem Buffer "nachlesen".
b) http://www.tutorials.de/tutorials210263.html&highlight=zeichen+konsole
muh
-
Master-of-Scare schrieb:
wenn das so simple wäre würde ich net fragen, denn das tut dummerweise so net
es ist aber so simpel.
anstatt rumzumeckern dass es nicht geht solltest du versuchen, es einzubauen.
abgesehen davon: besorg dir tutorials und lerne. wenn dir die basics fehlen wirst du nämlich sehr bald wieder vor einem ähnlich simplen problem stehen....
-
sorry wenn ich unfreundlich war, mein problem ist das ich wegen dem mist seit knapp 4 wochen net mehr weiter komme da das nicht tut wie es normal tun sollte. ich weiß wo ich das einfügen müsste, was leider net wirklich geht. denk mal das liegt daran das wenn ein neuer stein kommt die neuen veränderten zeichen eben nicht im array gespeichert sind sondern immer noch die standartdeklaration, oder?
-
kA... aber ein guter anfang wäre, das beispiel einzubauen, den neuen code posten und eine exakte beschreibung des problems und/oder fehlers dazuzuschreiben. es macht nämlich keinen bock deinen code groß studieren zu müssen um den sinn und das problem zu kapieren.....
-
hab alles soweit hin bekommen, nur noch ne kurze frage:
wenn ich in ner datei zb
fghj
jhgfhabe, und ich will jetzt genau in der zweiten zeile an der stelle des g ein anderes symbol hinsetzen (g überschreiben) wie mach ich das, das nur diese stelle überschrieben wird?
-
Ich habe den code mal schnell überflogen und kann nirgends finden das das 2dim array pic irgendwo upgedated wird. was du in diesem fall wirklich brauchst ist eine funktion wie getxy() die dir zurückgibt welches zeichen an einer bestimmten stelle am Bildschirm steht. Keine Ahnung ob es so etwas in der library die du da verwendest überhaupt gib. und ausserdem ist der code so aufgebaut dass du diese abfrage an vielen vielen stellen einbauen müsstest. Am besten ist du überlegst dir ein neues konzept für dieses spiel.
Kurt
-
hi kurt, ist auch nicht mehr der aktuelle code, muss nur wissen wie ich an die stelle in ner datei komme ohne das der rest überschrieben wird
-
wenn du in zeile 2 das 3. zeichen zu # haben willst, machst du einfach arrayname[1][2] = '#'..... (oder umgekehrt, bin mir bei mehrdimensionalen arrays nicht sicher)
merke dass die stellennummer in arrays mit 0 anfangen, nicht mit 1.....
-
hi, also neues problem, hab das mal so hin bekommen:
#include <stdlib.h> #include <stdio.h> #include <conio.h> #include <dos.h> #include <time.h> int mywait(int tmx){ struct time t, tneu; int loop; for (loop=0; loop<tmx; loop++){ gettime(&t); gettime(&tneu); while (t.ti_hund == tneu.ti_hund) gettime(&tneu);}} void picer(); void figures(); int figur1 (int, int); //block int figur2 (int, int); //linie int figur2b (int, int); int figur3 (int, int); //Zet1 int figur3b (int, int); int figur4 (int, int); //Zet2 int figur4b (int, int); int figur5 (int, int); //EL1 int figur5b (int, int); int figur5c (int, int); int figur5d (int, int); int figur6 (int, int); //EL2 int figur6b (int, int); int figur6c (int, int); int figur6d (int, int); int figur7 (int, int); //Tee int figur7b (int, int); int figur7c (int, int); int figur7d (int, int); //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\// char pic[23][23]={ {" .................... "}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"|....................|"}, {"¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯"}}; void picer () { int loop; int leep; for (loop=0; loop < 23; loop++) { for (leep=0; leep < 23; leep++) { gotoxy(32+loop,leep+1); printf("%s",& pic[leep][loop]); } } } /////////////////////////////////////////////////////////////////////////////////////////////////////// int figur1(int fx, int fy) { char moveto; //fx=42; //fy=2; gotoxy(fx,fy); while (moveto != '2') { moveto = getch(); gotoxy(fx,fy) ; printf (" "); gotoxy(fx,fy+1) ; printf (" "); if (moveto == '4' && fx >= 34) {fx=fx--;} if (moveto == '6' && fx <= 50) {fx=fx++;} gotoxy(fx,fy) ; printf (""); gotoxy(fx,fy+1) ; printf (""); gotoxy(fx,fy); } return(0); } ////////////////////////////////////////////////////////// Figur 3: Zet1 int figur3(int fx, int fy) { int xscan; int yscan; char moveto; //fx=42; //fy=2; gotoxy(fx,fy); while (moveto != '2') { moveto = getch(); gotoxy(fx ,fy ) ; printf (".."); gotoxy(fx+1,fy+1) ; printf (".."); pic[fx][fy]='..'; pic[fx+1][fy+1]='..'; xscan = fx; yscan = fy; if(pic[fx-2][fy]=='.') { if (moveto == '4' && fx >= 34) {fx=fx--;} } if (fx+2 != '0') { } if (moveto == '6' && fx <= 49) {fx=fx++;} if (moveto == '5' && fy <= 20) {fy=fy++;} pic[fx][fy]='##'; pic[fx+1][fy+1]='##'; gotoxy(fx ,fy ) ; printf ("##"); gotoxy(fx+1,fy+1) ; printf ("##"); gotoxy(fx+1,fy); if (moveto == '8' && fx <= 50 && fy <= 21) { gotoxy(fx ,fy) ; printf (".."); gotoxy(fx+1,fy+1) ; printf (".."); gotoxy(fx+1,fy-1) ; printf ("#"); gotoxy(fx ,fy) ; printf ("##"); gotoxy(fx ,fy+1) ; printf ("#"); figur3b(fx,fy); } if (moveto == '8' ) { fx = 42; fy = 2; gotoxy(fx,fy); figur3(fx,fy); } } return(0); } ///////////////////////////////////// int figur3b(int fx, int fy) { char moveto; //fx=42; //fy=2; gotoxy(fx,fy); while (moveto != '2') { moveto = getch(); gotoxy(fx+1,fy-1) ; printf ("."); gotoxy(fx ,fy) ; printf (".."); gotoxy(fx ,fy+1) ; printf ("."); if (moveto == '4' && fx >= 34) {fx=fx--;} if (moveto == '6' && fx <= 50) {fx=fx++;} if (moveto == '5' && fy <= 20) {fy=fy++;} gotoxy(fx+1,fy-1) ; printf ("#"); gotoxy(fx ,fy) ; printf ("##"); gotoxy(fx ,fy+1) ; printf ("#"); gotoxy(fx+1,fy); if (moveto == '8' && fx <= 50) { gotoxy(fx+1,fy-1) ; printf ("."); gotoxy(fx,fy) ; printf (".."); gotoxy(fx ,fy+1) ; printf ("."); gotoxy(fx ,fy) ; printf ("##"); gotoxy(fx+1,fy+1) ; printf ("##"); figur3(fx,fy); } } return(0); } ///////////////////////////////////////////////////////////////////////////////////////////////////////// int main (void) { picer(); figur3(42,2); return (0); }
So, nun das Problem, wenn man das öffnet, die figur geht nicht mehr nach links, weiß jemand wieso? muss hierran eigentlich liegen, oder?:
if(pic[fx-2][fy]=='.') { if (moveto == '4' && fx >= 34) {fx=fx--;} } if (fx+2 != '0') { } if (moveto == '6' && fx <= 49) {fx=fx++;} if (moveto == '5' && fy <= 20) {fy=fy++;} pic[fx][fy]='##'; pic[fx+1][fy+1]='##'; gotoxy(fx ,fy ) ; printf ("##"); gotoxy(fx+1,fy+1) ; printf ("##"); gotoxy(fx+1,fy); if (moveto == '8' && fx <= 50 && fy <= 21) { gotoxy(fx ,fy) ; printf (".."); gotoxy(fx+1,fy+1) ; printf (".."); gotoxy(fx+1,fy-1) ; printf ("#"); .....
-
Tja, wohl pech gehabt
-
keiner nen rat`?
-
vielleicht sollteste im konsolen-forum fragen. die stehen da mehr auf 'gotoxy()' und so'n zeug. ...und etwas konkreter werden mit den fragen
-
wo ist das konsolenforum bitte?
-
Schau mal da
http://www.c-plusplus.net/forum/viewforum.php?f=13&sid=6edc4192aa34659e14e3226acccf7111
Und es wär fantastisch wenn du langsm mal ein bisschen Eigeninitiative entwickeln würdest.
Das hier ist ein Forum, wenn dir jemand einen Typ gibt mal im Konsolenforum nachzuschauen, würde
ich mal die Maus schubsen und nachgucken ob das vielleicht hier ist.