Jump to content
  • Advertisement
Sign in to follow this  
Eric Poitras

Rogue-like Game Help

This topic is 4914 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

Hey all I'm making a little rogue-like game to pass the time and I was wondering if anyone knows a better way to clear the screen and redraw other than the clrscr() function. I'm wondering this because when I redraw the screen it gives me this flickering thing with my screen. It's not that big of a deal but i would like to find a way for getting rid of this flickering effect.

Share this post


Link to post
Share on other sites
Advertisement
i don't know it it helps but:

system ('clear');

appears to do the trick in my applications ;-)

Share this post


Link to post
Share on other sites
hmmm oddly enough that made it worse... it didn't work the syntax you gave me so I had to do it like: system("cls");
not sure if that makes a difference or not.... system ('clear'); crashed the program.

Share this post


Link to post
Share on other sites
Warning! This is not a C++ builtin or library function. The system() function itself is, but what it does is look up a program by the provided name and execute it. This relies on the program (a) existing, (b) being where it needs to be and (c) doing what you expect it to. (It's also quite inefficient, although that's unlikely to matter for clearing the screen in a console application).

To solve the general problem of dealing with roguelike-style "graphics", you really should invest the effort to look into a console graphics library such as 'ncurses'.

Share this post


Link to post
Share on other sites
I thought Conio2.h could preety much do the same thing as ncurses? I'll look into it again but are you sure that it would fix the refreshing problem in a console game... maybe I should just move on and not worry about this....

Share this post


Link to post
Share on other sites
Kudos on Making a Rogue like game btw, that's a deceptively simple game but a worthy task. If you don't believe me take a look at nethack (a great game btw).

I hope oneday to see your game up there in the halls with Angband, Rogue, and all the other fun games that have stolen a couple years of my life so far.

Share this post


Link to post
Share on other sites
heh yeah I've tried them all, my fav is actually ADOM but Nethack is up there too as my second choice. For the past 5 years I've been from DirectDraw to SDL to Direct3D to OpenGL, I've been bouncing around creating a lot of graphical stuff but now I rather just program something more complete.

Anyway, I got pdcurses set up and running and I'm still getting some flickering going on... sigh maybe I'm just doing something wrong. pdcurses is cool but the arrow keys don't seem to work I got it set up like this:


c = getch(); // Get Input
/* Act depending on the last key received. */
switch (c)
{
case KEY_LEFT: //Right arrow key
x++;
break;
}


EDIT: OK I got the flickering problem fixed!! :D Only thing left is the arrow key problem.

Share this post


Link to post
Share on other sites
The text device should be considered a single-buffer device. That means instead of clearing the screen and then drawing everything, one should try to simply draw everything on top (or mantain your own "backbuffer"). Basic idea:

char buffer[80][25];

void clear_buffer( void )
{
for ( int x = 0 ; x < 80 ; ++x )
for ( int y = 0 ; y < 25 ; ++y )
buffer[x][y] = ' ';
}

void update_screen( void )
{
gotoxy( 0 , 0 );
for ( int x = 0 ; x < 80 ; ++x )
for ( int y = 0 ; y < 25 ; ++y )
putchar( buffer[x][y] );
}

//...

void CPlayer::Render( void )
{
//was gotoxy(x,y); putchar( '@' );
buffer[x][y] = '@';
}

void main_loop( void )
{
//was system("clear");
clear_buffer();
//this was the same:
player.Render();
//this was added:
update_screen();
}

Share this post


Link to post
Share on other sites
gosh, dumb me, surely system ('clear') works under linux. i've been programming under taht os for a while and this is why used clear. sorry, my mistake. ;-)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!