From 2dcc8d222b9fda68f22e0c276f031b465779d109 Mon Sep 17 00:00:00 2001 From: Siamak Date: Fri, 10 Feb 2023 16:09:44 +0100 Subject: [PATCH] Richting oben --- src/Spiellogik.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/Spiellogik.c b/src/Spiellogik.c index 4824d4a..3959fee 100644 --- a/src/Spiellogik.c +++ b/src/Spiellogik.c @@ -85,32 +85,36 @@ int update(int realU[N][N],char richtung) { } } } -if(richtung == 'u') { - if(ii == 0) { - return 1; - } - if(realU[ii + 1] [jj] == (N * N) + 1) { - realU[ii + 1] [jj] = groesste + 1; - apple(realU); - speed = speed + 20; - } - else { - if(!lose(realU, richtung)) { + if(richtung == 'u') { + if(ii == 0) { + return 1; + } + if(realU[ii + 1] [jj] == (N * N) + 1) { + realU[ii + 1] [jj] = groesste + 1; + apple(realU); + speed = speed + 20; + } + else { + if(!lose(realU, richtung)) { realU[ii - 1][jj] = groesste + 1; - for (int i = 0; i < N; i++) { - for (int j = 0; j < N; j++) { - if (realb[i][j] != 0 && realb[i][j] != (N * N) + 1) { - realb[i][j]--; + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (realb[i][j] != 0 && realb[i][j] != (N * N) + 1) { + realb[i][j]--; + } } } } + else { + return 1; + } } - else { + } + else if (richtung == 'd') { + if (ii == N - 1) { return 1; - } + } } -} - int probe(int input){ return input;