| | |
how to make maze game using "gotoxy" & getch?
![]() |
Greetings,
Writing your own version of gotoxy() and clrscr() would probably be for the best. They can be found all over the place, but the best ones I've found were:
Doing the rest is quite simple. Here's a simple layout of how this can be accomplished:
That should get you to a good start, and good luck.
- Stack Overflow
Writing your own version of gotoxy() and clrscr() would probably be for the best. They can be found all over the place, but the best ones I've found were:
#include <iostream.h> #include <windows.h> void gotoxy(short x, short y) { HANDLE hConsoleOutput; COORD Cursor_Pos = {x, y}; hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hConsoleOutput, Cursor_Pos); } void clrscr(void) { CONSOLE_SCREEN_BUFFER_INFO csbi; HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); COORD coord = {0, 0}; DWORD count; GetConsoleScreenBufferInfo(hStdOut, &csbi); FillConsoleOutputCharacter(hStdOut, ' ', csbi.dwSize.X * csbi.dwSize.Y, coord, &count); SetConsoleCursorPosition(hStdOut, coord); }
Doing the rest is quite simple. Here's a simple layout of how this can be accomplished:
- Create a function to update the player's position. Have it clear the screen everytime this is called
- Use an infinite while loop and get the key pressed using getch()
- Call a switch case and find out which key was pressed and where to update the players position
That should get you to a good start, and good luck.
- Stack Overflow
Following the rules will ensure you get a prompt answer to your question. If posting code, please include BB [code][/code] tags. Your question may have been asked before, try the search facility.
IRC
Channel: irc.daniweb.com
Room: #c, #shell
IRC
Channel: irc.daniweb.com
Room: #c, #shell
![]() |
Similar Threads
- Help with making a maze game with MASM (Assembly)
- maze game (C++)
Other Threads in the C++ Forum
- Previous Thread: Visual C++ graphics
- Next Thread: ebcdic to decimal function
| Thread Tools | Search this Thread |
ada api array backup based binary bitmap c++ c/c++ char class classes code coding compile console conversion count delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file fileread forms fstream function functions game givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer pong prime problem program programming project python random read recursion reference rpg set string strings symbian temperature template test text text-file tree url variable vector video visual win32 windows winsock word wordfrequency wxwidgets





