Skype group , Snake in console

Hello,

I'v created a group for C++ programmers .
Doesn't matter what's your level in C++ ,this group is for easier learning,for everyone.
Moreover ,I've just started Directx,1guy have started to work with opengl.
If you want to learn together,invite me (skype: mantasxxl3).
[I must mention,we are not talking just about it].

Mantas



Also check this http://youtu.be/DBOzkCbdoqQ ,what do you think?
closed account (EwCjE3v7)
Is that senhors game?
Last edited on
Did you mean senhors?
No,he's still working with it.
It's my ^
closed account (jwkNwA7f)
What did you make the game with?
C++ ,console.

closed account (1v5E3TCk)
Hey wait I finished it yesterday -.- not still working on it. But yes it is your code and your game :D
@Foxefde

Is the music built into your game??

Andy
Andy,

No,it's not.
As far as I know,it's impossible to play music without additional library with console.
Ofc you can use some beep sounds,but they are :/ ..

Last edited on
Out of interest, how are you moving your snake about? Are you using struct ANSI C++, or are you using Windows Console API calls? Or even CURSES ??

Andy
closed account (EwCjE3v7)
Sry senhor it's my frickin ipad doing auto corrections
I'm just changing coordinates every frame and redraw snake .
Nothing special,really
Last edited on
But how do you draw the snake? With cout calls?

Andy
Yes
Ah, oh

Which leaves just one last (combined) question. How do you set the color and the cursor postion?

Andy
void clearscreen() //it sets cursor position
{
HANDLE hOut;
COORD Position;

hOut = GetStdHandle(STD_OUTPUT_HANDLE);

Position.X = 0;
Position.Y = 0;
SetConsoleCursorPosition(hOut, Position);
}

void SetColor(int ChooseColorNumber) //example SetColor(512) ,then //write anything you want and it will have diffirent color,but don't forget to //write StopColor() when you don't need it anymore

{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), ChooseColorNumber);
}
void StopColor()
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
}
OK, you are using the Windows Console API, then. Rather than pure C++.

In that case, you could also use the Windows Multimedia (WinMM) API to play your background music, as you're already reliant on another bit of Windows. If your music is in a .wav file, then you can use:

PlaySound("bkgnd.wav", NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);

which plays the sound in the background (without blocking your main thread) and carries on repeating until you stop the sound.

PlaySound(NULL, NULL, 0);

stops the sound.

header: mmsystem.h
lib: winmm.lib

It's the old way of playing sounds, but it still works. And it's the most straightforward to use.

(If you don't want to have a separate .wav file, it's possible to bind the .wav into the executable as a resource. See MSDN for details.)

Andy

PlaySound function
http://msdn.microsoft.com/en-us/library/windows/desktop/dd743680%28v=vs.85%29.aspx

Playing WAVE Resources
http://msdn.microsoft.com/en-us/library/windows/desktop/dd743679%28v=vs.85%29.aspx
Topic archived. No new replies allowed.