Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

bioagentX

The conio library

This topic is 5651 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using the Bloodshed Dev C++ compiler and for some reason, certain functions that I thought were the standard are not compiling correctly. Such functions are getch() and randomize(); If anyone knows anything about either of these functions and the correct syntax for them, please reply. Thanks, -BioagentX

Share this post


Link to post
Share on other sites
Advertisement
I don''t thibnk randomize() is standart, use rand.

As for getch(), its just that

char bleh;
bleh = getch()

or plainly getch() for "press any key" stuff






website coming soon

Share this post


Link to post
Share on other sites
I did that, but it doesn''t seem to be compiling still. I am wondering if it something with my compiler. Maybe because it has some incorrect function definitions or something.

Share this post


Link to post
Share on other sites
Actually, let me just tell you what I''m trying to do, and you can help me. I''m creating a program that let''s you draw characters. Here is my code so far



#include <iostream.h>
#include <conio.h>
#include <stdlib.h>

int main()
{

cout<<"Doodler! Press/J/I/K/L to move, Q to quit"< char keyPressed;

int x=40; int y=10; //Establish an initial cursor position
kbhit();
do
{
//Plot a point
gotoxy(x,y);
cout<< ''*'';
gotoxy(x,y);

keyPressed== getch();

if((keyPressed==''I'')||(keyPressed==''i''))
y--;

else
if((keyPressed==''k'')||(keyPressed==''K''))
y++;

else
if((keyPressed==''j'')||(keyPressed==''J''))
x--;

else
if((keyPressed==''l'')||(keyPressed==''L''))
x++;

else
if((keyPressed==''q'')||(keyPressed==''Q''))
;//Do nothing

else
cout<<"\a"; //Beep for bad command

}while((keyPressed!=''q'')||(keyPressed=''Q''));


gotoxy(1,1);
clreol();
cout<<"Random stars! Press any key to stop."< while(!kbhit())
{

gotoxy(1+rand(60), 2+rand(20));
cout<<"\a "; //A star and a blank to draw and erase
}

return 0;
}


I get errors that relate to the kbhit() function and the getch() function in the compiler.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
gotoxy and clrscr don''t work in vc++... maybe the same problem?

Share this post


Link to post
Share on other sites
like I said, getch is not ansi.. use fgetc(stdin) instead of it... And i wouldnt know what the hell kbhit() is...

BTW, your random star displayer.... will just be hellishly too quick.... try using sleep() inside the loop.






website coming soon

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!