Semster Project Help

As a semester project students are required to develop an application using C++ programming
language which is similar with PACMAN (game) in behavior. In this game a character will be
moving on the screen inside a box but cannot escape the boundary of box. If it touches any of
fruit placed (which would have different points assigned), the player gets points and the mark /
fruit is removed from display giving affect as it has been consumed/eaten by actor (moving
character). If the moving character reaches any wall, it automatically changes its direction and
tries to find a path.
________________________________________________
I've now made the game, but the problem is that it always blinks after every move of pacman.... How can i come over this ??

closed account (E3Uiz8AR)
Is this CLI or OpenGL / Qt / etc?

EDIT: I mean I haven't programmed any real graphics yet, but maybe a little more information might help someone understand your predicament! :)
Last edited on
I've to made this in win32 console application, which look likes a dos application...
I've now made the game, but the problem is that it always blinks after every move of pacman.... How can i come over this ??


I'm going to assume the "blinking" is actually "flickering" which is caused by the act of redrawing being visible to the user due to drawing being done in multiple steps... rather than all at once.


For example... say you have the entire map visible and you want to redraw it. You might do the following:
1) clear the screen
2) redraw the map in full with pacman in a new position


Doing this will cause heavy flickering because:

- The user will see the screen being cleared
- The user will see each line of the map being drawn

This is a multiple step process, and doing it like the above is going to make each step visible to the user. You do not want that... you only want the final result visible.



Typically accomplishing this is done through the use of double buffering. That is... You have one "on screen" buffer which is what the user actually sees. Then you have an "off screen" or "memory" or "back" buffer which you can draw to whenever you want and nothing on it is seen by the user.

So with doublebuffering, you would clear your back buffer, draw your new map to it... then once it has the final generated image, you do a "swap" and switch the back buffer out with the on-screen buffer. So the new image becomes immediately visible with no flickering.

The problem is... doing this in the console is difficult because the console is not designed to work this way. This is much easier to accomplish with a graphic lib. Quite frankly... I don't even know how you would do this in the Windows console. Libs like ncurses might have some API for it.... are you using any lib like that or are you just using WinAPI or standard C++ library functions?



If you're not using a lib like ncurses, you can try looking around on google for a way to double buffer the windows console. I really don't expect it to be easy.


If it turns out to be too much.. an alternative is to minimize the flicker by only redrawing what needs to be redrawn. So when pacman moves, rather than redrawing the entire screen.. you'd only need to redraw the areas where pacman was and where he moved to (since those are the only two areas that changed). This will still cause those 2 areas to flicker, but it'll be less noticeable than the entire screen flickering.
Topic archived. No new replies allowed.