|
@ -17,8 +17,8 @@ int windForce = 0; |
|
|
int ScorePoints = 0; |
|
|
int ScorePoints = 0; |
|
|
|
|
|
|
|
|
int lifeCount = 3; |
|
|
int lifeCount = 3; |
|
|
int Ballx = -1; |
|
|
|
|
|
int Bally = 27; |
|
|
|
|
|
|
|
|
int ballX = -1; |
|
|
|
|
|
int ballY = 27; |
|
|
int windIntervall = 0; |
|
|
int windIntervall = 0; |
|
|
int lvlnumber = 1; |
|
|
int lvlnumber = 1; |
|
|
|
|
|
|
|
@ -52,8 +52,8 @@ void buildBin(int width, int heigth){ |
|
|
|
|
|
|
|
|
void loadLevel(int lvlnum){ |
|
|
void loadLevel(int lvlnum){ |
|
|
clearField(); |
|
|
clearField(); |
|
|
Ballx = -1; |
|
|
|
|
|
Bally = 27; |
|
|
|
|
|
|
|
|
ballX = -1; |
|
|
|
|
|
ballY = 27; |
|
|
|
|
|
|
|
|
int tmpX,tmpY; |
|
|
int tmpX,tmpY; |
|
|
|
|
|
|
|
@ -135,7 +135,7 @@ int main() |
|
|
while (1) |
|
|
while (1) |
|
|
{ |
|
|
{ |
|
|
clearField(); |
|
|
clearField(); |
|
|
field[Ballx][Bally -= 1] = 'O'; |
|
|
|
|
|
|
|
|
field[ballX][ballY -= 1] = 'O'; |
|
|
Generatefield(); |
|
|
Generatefield(); |
|
|
|
|
|
|
|
|
int Ball_In_Bin = checkBallPosition(); |
|
|
int Ball_In_Bin = checkBallPosition(); |
|
@ -180,24 +180,24 @@ int main() |
|
|
void getStartPosition() |
|
|
void getStartPosition() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
while (Ballx == -1) |
|
|
|
|
|
|
|
|
while (ballX == -1) |
|
|
{ |
|
|
{ |
|
|
for (int i = 2, j = 0; i <= 20; i += 2, j++) |
|
|
for (int i = 2, j = 0; i <= 20; i += 2, j++) |
|
|
{ |
|
|
{ |
|
|
field[i][Bally] = j + '0'; |
|
|
|
|
|
|
|
|
field[i][ballY] = j + '0'; |
|
|
} |
|
|
} |
|
|
Generatefield(); |
|
|
Generatefield(); |
|
|
//printf("W\x84\hle die position des Balls (0-9):\n"); |
|
|
//printf("W\x84\hle die position des Balls (0-9):\n"); |
|
|
printf("Wähle die position des Balls (0-9):\n"); |
|
|
printf("Wähle die position des Balls (0-9):\n"); |
|
|
|
|
|
|
|
|
scanf("%d", &Ballx); |
|
|
|
|
|
|
|
|
scanf("%d", &ballX); |
|
|
|
|
|
|
|
|
if (Ballx < 0 || 9 < Ballx) |
|
|
|
|
|
|
|
|
if (ballX < 0 || 9 < ballX) |
|
|
{ |
|
|
{ |
|
|
Ballx = -1; |
|
|
|
|
|
|
|
|
ballX = -1; |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
Ballx = (Ballx + 1)*2; |
|
|
|
|
|
|
|
|
ballX = (ballX + 1)*2; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -250,7 +250,7 @@ void Generatefield() { |
|
|
} |
|
|
} |
|
|
if (lvlnumber > 6 && windIntervall % 2 == 0) |
|
|
if (lvlnumber > 6 && windIntervall % 2 == 0) |
|
|
{ |
|
|
{ |
|
|
windForce < 0 ? (Ballx -= windForce * -1) : (Ballx += windForce); |
|
|
|
|
|
|
|
|
windForce < 0 ? (ballX -= windForce * -1) : (ballX += windForce); |
|
|
} |
|
|
} |
|
|
windIntervall++; |
|
|
windIntervall++; |
|
|
|
|
|
|
|
@ -285,11 +285,11 @@ void addScoreboard() |
|
|
|
|
|
|
|
|
int checkBallPosition() |
|
|
int checkBallPosition() |
|
|
{ |
|
|
{ |
|
|
if (binY + 2 == Bally && (Ballx == binX || Ballx == binX + 1 || Ballx == binX - 1)) |
|
|
|
|
|
|
|
|
if (binY + 2 == ballY && (ballX == binX || ballX == binX + 1 || ballX == binX - 1)) |
|
|
{ |
|
|
{ |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
else if (binY + 1 >= Bally || field[Ballx][Bally - 1] == '_' || Ballx >= fieldWidth || Ballx <= 0) |
|
|
|
|
|
|
|
|
else if (binY + 1 >= ballY || field[ballX][ballY - 1] == '_' || ballX >= fieldWidth || ballX <= 0) |
|
|
{ |
|
|
{ |
|
|
return 2; |
|
|
return 2; |
|
|
} |
|
|
} |
|
|