• Advertisement
Sign in to follow this  

2nd game finished. Please take a look and let me know what you think.

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

Hi people. Just finished my 2nd game. Is a text version of tetris. Would really appreciate some feedback as I'm not too convinced about my overall design, and sometimes felt as if I was just doing things around the design and it didn't quite fit right. For example had to drop a DROP movement coz I couldn't see where I could put it in the design of the game. So all comments glady recieved. The source can be found here. Is C++ done under DEV-C++ v4.9.9.2. EDIT: All source is there now..including textris.cpp Thanks in advance..:) Think I'm going to move on to graphics now. PS. In order to play Textris you'll have to resize the console window manually. Don't know how to do it from within the code, so if anyones got any ideas let me know about that as well. PPS. Apologises for the REALLY naff demo mode included. [Edited by - garyfletcher on March 30, 2005 6:37:52 AM]

Share this post


Link to post
Share on other sites
Advertisement
Tried to run it, but the screen was to jumpy to play the game. Looks like a strobe light. Is it just my computer or are other people noticing this?

-Jake

Share this post


Link to post
Share on other sites
Quote:
Original post by jake2431
Tried to run it, but the screen was to jumpy to play the game. Looks like a strobe light. Is it just my computer or are other people noticing this?

-Jake


Same issue here.

Also had to run .exe from archive because I got an unresolved external when compiling your code in Dev-C++ from scratch. And it also said Textris.cpp wasn't in my Dev-C++ Templates directory when I loaded the project file.

Having said that, nice job!

Share this post


Link to post
Share on other sites
Maximize the screen.

I have to say, that's (almost) the most complex console application I've seen ever (aside from Ben Ryves' ASCII Madness of course).

Share this post


Link to post
Share on other sites
It looks jumpy here too, but I can see what's going on. I think you have a too fast computer, my graphics card only has 4 MB RAM :P


gary: nice work, now switch to graphics cause ascii games will never sell :P

Share this post


Link to post
Share on other sites
Yes maximizing did work better though it still blinked. The keys work fine, but if you start pressing the directional keys randomly it says its paused and to press p to continue playing. If I then press p nothing happens. Why is this? A glitch I assume?

-Jake

Share this post


Link to post
Share on other sites
Oh I agree. Very cool. Be great when it has images to I think. I like the game.

Share this post


Link to post
Share on other sites
Thanks for all the replies.

Am still a little concerned about the overall design. One post said that it was very complex, which makes me think perhaps over compleicated for what it does???? What do you all think.

Sorry about the flicker. Did flicker on mine as well, but not enough to make it difficult to play. I think that it is to do with the fact I'm using a string to draw the screen. Does anyone know of a way to minimise this?

Also sounds like there might be a bug when you randomly press movement keys...will have to take a look.

Have also been wondering about the use of virtual functions and if it woudl have been better just to override the Play() member function in the DemoGameEngine() class. I know that using virtual functions has a performance overhead, so what do you think out there?

Anyhow..please keep all the comments coming.

PS. OMG...can't believe that textris.cpp isn't in teh archive...will have top sort that out later.

Share this post


Link to post
Share on other sites
Yeah, mine is jumping too, but the game does seem pretty good nonetheless. What you can do is add some colors to make it less dull.

Try to Google for 'Avalon' and search for an RPG game. The game uses console same as you do, and yet it has colors (and overall it's awsome), but what's important is that the sources are available, so just download them and check out the technique for using colors.

Share this post


Link to post
Share on other sites
its cool but its imo to wide so you have to play pretty long to get lines away.

for the blinking i suggest you get a terminal librarie with a buffer (i think theres one called ncurses for linux, dont know how about windows), i guess that would work much better.

nice work

Share this post


Link to post
Share on other sites
Quote:
Original post by garyfletcher

Sorry about the flicker. Did flicker on mine as well, but not enough to make it difficult to play. I think that it is to do with the fact I'm using a string to draw the screen. Does anyone know of a way to minimise this?

The flickering is due to the use of system( "cls" );. It may be worth looking for ways of replacing characters in the screen instead of using the system command cls to cleanse the screen. (I do not know if that's possible. I'm just brainstorming here.)

Though the game looks awesome, I never did anything with console graphics that complex. Plus, you did finish a game (menu, scores, configuration screen etc) and learned a lot. I think you did a great job.

Share this post


Link to post
Share on other sites
When I'm writing a windows-specific console app that does a lot of drawing I usually do my drawing to a backbuffer and then present it to the console all in one go with a single API call. This kills flicker completely.

I haven't taken a look at the source so I'll assume that you're not writing windows specific code, but I'd imagine the same is possible across various platforms.

Double buffering is the principle you need here. Good stuff though, keep it up.
-arm.

Share this post


Link to post
Share on other sites
Cheers arm.

What I'm doing is constructing the display to a string and then displaying teh string all at once, I think this is the method you described.

I think the trouble comes with the fact that I'm drawign the screen on every iteration in the game loop (well almost, depending og teh speed at which the game is set). Woudl be great if you looked at the source and see what you think might be causing the flicker and any potential solutions.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Outstanding work!
If you want to eliminate the flicker, have a look at "Reading and Writing Blocks of Characters and Attributes" in the MSDN. I guess its ~20 LOC.


#include

VOID main(void)
{
HANDLE hStdout, hNewScreenBuffer;
SMALL_RECT srctReadRect;
SMALL_RECT srctWriteRect;
CHAR_INFO chiBuffer[160]; // [2][80];
COORD coordBufSize;
COORD coordBufCoord;
BOOL fSuccess;

// Get a handle to the STDOUT screen buffer to copy from and
// create a new screen buffer to copy to.

hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
hNewScreenBuffer = CreateConsoleScreenBuffer(
GENERIC_READ | // read/write access
GENERIC_WRITE,
0, // not shared
NULL, // no security attributes
CONSOLE_TEXTMODE_BUFFER, // must be TEXTMODE
NULL); // reserved; must be NULL
if (hStdout == INVALID_HANDLE_VALUE ||
hNewScreenBuffer == INVALID_HANDLE_VALUE)
{
MyErrorExit("CreateConsoleScreenBuffer");
}

// Make the new screen buffer the active screen buffer.

if (! SetConsoleActiveScreenBuffer(hNewScreenBuffer) )
MyErrorExit("SetConsoleActiveScreenBuffer");

// Set the source rectangle.

srctReadRect.Top = 0; // top left: row 0, col 0
srctReadRect.Left = 0;
srctReadRect.Bottom = 1; // bot. right: row 1, col 79
srctReadRect.Right = 79;

// The temporary buffer size is 2 rows x 80 columns.

coordBufSize.Y = 2;
coordBufSize.X = 80;

// The top left destination cell of the temporary buffer is
// row 0, col 0.

coordBufCoord.X = 0;
coordBufCoord.Y = 0;

// Copy the block from the screen buffer to the temp. buffer.

fSuccess = ReadConsoleOutput(
hStdout, // screen buffer to read from
chiBuffer, // buffer to copy into
coordBufSize, // col-row size of chiBuffer
coordBufCoord, // top left dest. cell in chiBuffer
&srctReadRect); // screen buffer source rectangle
if (! fSuccess)
MyErrorExit("ReadConsoleOutput");

// Set the destination rectangle.

srctWriteRect.Top = 10; // top lt: row 10, col 0
srctWriteRect.Left = 0;
srctWriteRect.Bottom = 11; // bot. rt: row 11, col 79
srctWriteRect.Right = 79;

// Copy from the temporary buffer to the new screen buffer.

fSuccess = WriteConsoleOutput(
hNewScreenBuffer, // screen buffer to write to
chiBuffer, // buffer to copy from
coordBufSize, // col-row size of chiBuffer
coordBufCoord, // top left src cell in chiBuffer
&srctWriteRect); // dest. screen buffer rectangle
if (! fSuccess)
MyErrorExit("WriteConsoleOutput");
Sleep(10000);

// Restore the original active screen buffer.

if (! SetConsoleActiveScreenBuffer(hStdout))
MyErrorExit("SetConsoleActiveScreenBuffer");

}

Share this post


Link to post
Share on other sites
Drawing with a string all in one go is pretty similar to what I propose, its just that your implementation is a little more 'high level' than what I suggest.

I had a quick look at the code - you redraw by clearing the screen and then using a high level string output function to draw with. What I would do is create
a static array the same size as the screen buffer on startup and draw to this internally. Then when you're ready to update the screen, blit the buffer to the console using a call like WriteConsoleOutput (Windows API) without clearing the screen - just overwrite it all.

Ofcourse this probably means using low-level console functions which will sacrafice portability. I'm not familiar with the libraries you are using so I cant give any specific advice.

-arm.

Share this post


Link to post
Share on other sites
Sounds very interesting.

I guess I can use the win32 api as suggested for controlling the console window.

Thanks guys..:)

+ve ratings all around I think;)

Although it looks as if mines fallen today....must have given some duff advice to someone.

Share this post


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

  • Advertisement