Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Console buffers and learner's permits

Sign in to follow this  


Cripes! - The Snipes clone

After doing a little more reasearch, I tried using CreateConsoleScreenBuffer() to create a separate buffer for Cripes to draw to. It turns out that separate screen buffers keep separate state, so I don't really need to worry about saving the old state. My Game class constructor handles the set-up of the console window, and here's the source code:

world(40, 25)
throw std::exception("Unable to create new console buffer.");
throw std::exception("Unable to access console input buffer.");

if (!SetConsoleActiveScreenBuffer(hOut))
throw std::exception("Unable to set the active console buffer.");

SMALL_RECT win_size = {0, 0, 39, 24};
SetConsoleWindowInfo(hOut, true, &win_size);
COORD buff_size = {40, 25};
SetConsoleScreenBufferSize(hOut, buff_size);

SetConsoleTitle("Cripes 2.0 - A Snipes Clone");

GetConsoleCursorInfo(hOut, &cci);
cci.bVisible = false;
SetConsoleCursorInfo(hOut, &cci);

It's actually more simple than I expected. The initializer list sets up the handles and gives our World its dimensions, and the block of if-statements makes sure they're all valid. The next block of code sets the window size, then the buffer size. You actually have to do it in that order here, otherwise we'd set a buffer smaller than the window, which Win32 doesn't like. Then we set the title, and I make the cursor invisible. Take a look:

It actually looks like a normal window filled with a solid blue color. Or it would if the icon didn't scream "CONSOLE!!" I made it that color via a world.FillColor() function I'm using for testing purposes only, so I can see if this stuff is working properly. It is.

Day-to-day Life

I just got my driver's permit. The written test I took allowed a maximum of eight mistakes. I made seven. At least I passed. I'm just a little nervous about driving for my first time... make that really nervous. :|


EDIT: I don't know what happened here, but it sure looks interesting!

EDIT 2: Ah, I botched my conversion from 2D coordinates to 1D indices.
Sign in to follow this  

1 Comment

Recommended Comments

Hey, that might be really simple to you but I'd be chuffed to get a different coloured pixel on the screen! I'm not going to try and jump ahead like last time though so I'll keep it as a future goal.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 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!