+ 1

what to do help in the code on C

Hello, I started making a game on C I have included the library <conio.h> and after that I don't get fields. HERE CODE #include <stdio.h> #include <stdlib.h> #include <conio.h> int main() { char mas[10][21]; int i; int x = 10, y = 5; char key; do { sprintf(mas[0], "####################"); for(i = 9; i < 9; i++) { sprintf(mas[i], "# #"); } sprintf(mas[9], "####################"); mas[y][x] = '*'; system("cls"); for(int i = 0; i < 10; i++) { printf("%s\n", mas[i]); } key = getch(); if(key == 'w')y--; if(key == 's')y++; if(key == 'a')x--; if(key == 'd')x++; } while(key != 'e'); return 0; }

1st Mar 2022, 8:01 PM
Bondarenko Emir
Bondarenko Emir - avatar
4 odpowiedzi
+ 2
conio is depreciated.
1st Mar 2022, 8:45 PM
Slick
Slick - avatar
+ 1
conio.h and system("cls") and getch() don't work here on SoloLearn.
1st Mar 2022, 9:39 PM
HungryTradie
HungryTradie - avatar
0
You don't have a time delay between loops, your game speed is going to change depending on the speed of the computer, eg blindingly fast! I see what you created, code looks simple yet amazing. After you get the delay working, you could do some collision detection, eg if (y==0 || y==10)
1st Mar 2022, 9:43 PM
HungryTradie
HungryTradie - avatar
0
G'day Bondarenko Emir I hope I have included enough acknowledgement for your code, it's amazing! It doesn't work in SoloLearn code playground, but is good in CodeBlocks. Compiled into a .exe nicely too. https://code.sololearn.com/c0g8261UI9nc/?ref=app
2nd Mar 2022, 1:48 AM
HungryTradie
HungryTradie - avatar