Jump to content

  • Log In with Google      Sign In   
  • Create Account


VSC++ Console Game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 Tszafran   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 December 2001 - 03:03 PM

Hi, Im in a computer science class and for a final project our teacher wants us to create a DOS game, we are using Visual C++ 6.0 and I was wondering what could I use to make a semi-decent game. I could use textcolor(2); cprintf("Hello"); to make different text colors, but what could I do to create some DOS graphics? Im still pretty new. Also I have tried installing Allegro with no success (no clue why either, followed instructions also).

Sponsor:

#2 Null and Void   Moderators   -  Reputation: 1087

Like
Likes
Like

Posted 17 December 2001 - 03:12 PM

quote:
Original post by Tszafran
I could use ... to make different text colors.

In MSVC? Not you can''t, those are Borland specific functions.
quote:
Original post by Tszafran
Also I have tried installing Allegro with no success (no clue why either, followed instructions also).

Obviously it works for other people, maybe you should try again or ask about any steps that you aren''t sure about. You can try SDL also, if you''re already planning on learning an new library. There''s just about no way to screw up SDL''s installation .

[Resist Windows XP''s Invasive Production Activation Technology!]

#3 Floppy   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 December 2001 - 03:16 PM

You could make a guess the number game in less than 15 lines of code, and that would qualify as a game. Does your teacher have any type of expectation?

#4 GoofProg   Members   -  Reputation: 127

Like
Likes
Like

Posted 17 December 2001 - 03:18 PM

A console window is completely different than DOS.
You cannot directly access video or text memory in a Win32 console.

If it is DOS, then use a compile that creates DOS applications not console ones.

THE TEXT AREA IS AT B800H
and VIDEO IS AT A000H

good luck.

you could use a window & use textout functions and set the text and background colors.. you could come up with something interesting.




#5 Tszafran   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 December 2001 - 03:26 PM

Sorry, I have VSC++ at home and Borland, but use Borland at school. I followed that SDL installation guide a couple weeks ago on GameDev and it installed correctly. Does anyone have any good sites for basic tutorials (not just documentation)? Or anymore information/sites about DOS related graphics or something? I got a somewhat short time frame so I'm not looking towards anything too complex at the moment.

Also I am new to C++ like 3 months, but learned alot in that time and am passed the basic Guessing Game, and made a Snake Game using Borlands gotoxy() function.
PS.
Thanks for all the replies, they are greatly appreciated.

Edited by - tszafran on December 17, 2001 10:29:15 PM

#6 Null and Void   Moderators   -  Reputation: 1087

Like
Likes
Like

Posted 17 December 2001 - 03:44 PM

quote:
Original post by Tszafran
I followed that SDL installation guide a couple weeks ago on GameDev and it installed correctly. Does anyone have any good sites for basic tutorials (not just documentation)?

You can try Cone3D, he''s started writing some basic SDL tutorials. I personally found the SDL Doc. Project to be more than enough to get me started with SDL. Of course, I don''t use the sound or video portions of SDL (OpenGL and OpenAL do fine for those ), so I''m not sure of the coverage they give to those sections.

[Resist Windows XP''s Invasive Production Activation Technology!]

#7 Tszafran   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 December 2001 - 04:16 PM

I tried the basic SDL application at http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut1

but when I compile this...
#include
#include

#include
...
(Excluded to save room).
...
DrawScene(screen)
}

return 0;
}

I get the missing '';'' at DrawScene(screen)
So I add the comma then I try to compile and get all these errors

MSVC++
--------------------Configuration: SDLMain - Win32 Debug--------------------
Linking...
SDLMain.obj : error LNK2001: unresolved external symbol _SDL_LockSurface
SDLMain.obj : error LNK2001: unresolved external symbol _SDL_UnlockSurface
SDLMain.obj : error LNK2001: unresolved external symbol _SDL_MapRGB
SDLMain.obj : error LNK2001: unresolved external symbol _SDL_Flip
SDLMain.obj : error LNK2001: unresolved external symbol _SDL_PollEvent
SDLMain.obj : error LNK2001: unresolved external symbol _SDL_SetVideoMode
SDLMain.obj : error LNK2001: unresolved external symbol _SDL_Quit
SDLMain.obj : error LNK2001: unresolved external symbol _SDL_GetError
SDLMain.obj : error LNK2001: unresolved external symbol _SDL_Init
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/SDLMain.exe : fatal error LNK1120: 10 unresolved externals
Error executing link.exe.

SDLMain.exe - 11 error(s), 0 warning(s)



PS. I have bad luck with libraries, and I followed the SDL installation at GameDev and tested it with that small test program it had and it worked.


#8 Null and Void   Moderators   -  Reputation: 1087

Like
Likes
Like

Posted 17 December 2001 - 05:26 PM

Are you linking the libraries? Did you set up your project correctly? Do you know what you have to do (if you want me to tell you, tell me what compiler you''re using at the moment. MSVC?). Also: There should be a semicolon (not a comma) there, it isn''t lying to you. There should be semicolons almost everywhere in C/C++ .

[Resist Windows XP''s Invasive Production Activation Technology!]

#9 Tszafran   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 December 2001 - 05:37 PM

Sorry guys, my fault like Null and Void pointed out I was not setting my project properly (linking Libs, etc..) They now compile properly. Thanks alot for your help. Now I am off to code :-)

#10 Jonus   Members   -  Reputation: 170

Like
Likes
Like

Posted 17 December 2001 - 10:24 PM

You can make text in differnet colors in VC and also use the x-y thing:

///////////////////////////////////////////////////////////////////
//
// this is the header for VC_conio
// these are functions to imitate conio.h
// under Visual C++
//
/////////////////////////////////////////////////////////////////
#ifndef VC_CONIO
#define VC_CONIO


#include
#include
#include
#include

#define getch _getch
#define clreol clrol

enum COLORS {
BLACK, /* dark colors */
BLUE,
GREEN,
CYAN,
RED,
MAGENTA,
BROWN,
LIGHTGRAY,
DARKGRAY, /* light colors */
LIGHTBLUE,
LIGHTGREEN,
LIGHTCYAN,
LIGHTRED,
LIGHTMAGENTA,
YELLOW,
WHITE
};

void textcolor(COLORS a);
void textbackground(COLORS a);
void textcolor(int a);
void textbackground(int a);
void clrscr();
void gotoxy(short x, short y);
void clrol();
void window(int x, int y, int x1, int y1);

static HANDLE winHan;
static WORD ForeGroundColor = 0;
static WORD BackGroundColor = 0;


#endif


//////////////////////////////////////////////////////////////////
//
// this is the implementation file for VC_conio
// these are functions to imitate conio.h
// under Visual c++
//
/////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
#include "VC_conio.h"
//Variablen für den Window Befehl
int global_x; //links
int global_y; //oben
int global_x1; // rechts
int global_y1; // unten
WORD global_color; // Farbe

void textcolor(int a)
{textcolor(COLORS(a));}

void textbackground(int a)
{textbackground(COLORS(a));}

void textcolor(COLORS a)
{
winHan = GetStdHandle(STD_OUTPUT_HANDLE);

WORD _;
switch(a)
{
case BLACK :
_ = 0;
break;
case BLUE : // dark blue text
_ = FOREGROUND_BLUE;
break;
case GREEN : // dark green text
_ = FOREGROUND_GREEN;
break;
case CYAN : // dark cyan text
_ = FOREGROUND_GREEN | FOREGROUND_BLUE;
break;
case RED : // dark red text
_ = FOREGROUND_RED;
break;
case MAGENTA : // dark magenta text
_ = FOREGROUND_RED | FOREGROUND_BLUE;
break;
case BROWN : //dark brown text
_ = FOREGROUND_RED | FOREGROUND_GREEN;
break;
case LIGHTGRAY : //light grey text
_ = FOREGROUND_RED | FOREGROUND_BLUE |FOREGROUND_GREEN;
break;
case DARKGRAY :
_ = FOREGROUND_INTENSITY;
break;
case LIGHTBLUE : // light blue text
_ = FOREGROUND_BLUE |FOREGROUND_INTENSITY;
break;
case LIGHTGREEN : // light green text
_ = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
break;
case LIGHTCYAN : // light cyan text
_ = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
break;
case LIGHTRED : // light red text
_ = FOREGROUND_RED | FOREGROUND_INTENSITY;
break;
case LIGHTMAGENTA : // light magenta text
_ = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
break;
case YELLOW : // yellow text
_ = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
break;
case WHITE : //white text
_ = FOREGROUND_BLUE | FOREGROUND_RED| FOREGROUND_GREEN
| FOREGROUND_INTENSITY;
break;
default : //white text
_ = FOREGROUND_BLUE | FOREGROUND_RED| FOREGROUND_GREEN
| FOREGROUND_INTENSITY;
break;
}
ForeGroundColor = _;
_ += BackGroundColor;
global_color = _; //Modulglobale Variable setzen
SetConsoleTextAttribute(winHan, _);
}
//=======================================================================
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//=======================================================================
void textbackground(COLORS a)
{
winHan = GetStdHandle(STD_OUTPUT_HANDLE);
WORD _;
switch(a)
{
case BLACK ://balck background
_ = 0;
break;
case BLUE ://blue background
_ = BACKGROUND_BLUE;
break;
case GREEN : // dark green background
_ = BACKGROUND_GREEN;
break;
case CYAN : // dark cyan background
_ = BACKGROUND_GREEN | BACKGROUND_BLUE;
break;
case RED : // dark red background
_ = BACKGROUND_RED;
break;
case MAGENTA : // dark magenta background
_ = BACKGROUND_RED | BACKGROUND_BLUE;
break;
case BROWN : //dark brown background
_ = BACKGROUND_GREEN | BACKGROUND_RED;
break;
case LIGHTGRAY: // light grey background
_ = BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN;
break;
case DARKGRAY :
_ = BACKGROUND_INTENSITY;
break;
case LIGHTBLUE : // light blue background
_ = BACKGROUND_BLUE | BACKGROUND_INTENSITY;
break;
case LIGHTGREEN : // light green background
_ = BACKGROUND_GREEN | BACKGROUND_INTENSITY;
break;
case LIGHTCYAN : // light cyan background
_ = BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY;
break;
case LIGHTRED : // light red background
_ = BACKGROUND_RED | BACKGROUND_INTENSITY;
break;
case LIGHTMAGENTA : // light magenta background
_ = BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY;
break;
case YELLOW : // yellow background
_ = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY;
break;
case WHITE : //white background
_ = BACKGROUND_BLUE | BACKGROUND_RED| BACKGROUND_GREEN
| BACKGROUND_INTENSITY;
break;
default :
_ = 0;
}
BackGroundColor = _;
_ += ForeGroundColor;
global_color = _;//Modulglobale Variable setzen
SetConsoleTextAttribute(winHan, _);
}
//=======================================================================
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//=======================================================================
inline void gotoxy (short x, short y)
{
winHan = GetStdHandle(STD_OUTPUT_HANDLE);

COORD _ = { x+global_x-1, y+global_y-1 };//Modulglobale Variable verwenden
//In Borland ist (1,1) links oben,
//In VC++ ist (0,0) links oben
//darum -1 !!!!!!

SetConsoleCursorPosition (winHan, _);

}

//=================================================================
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//=================================================================
void clrscr ()
{
winHan = GetStdHandle(STD_OUTPUT_HANDLE);
//Dumme Microsoft Befehle beginnen bei 0,0
//---> (x-1)
//weil Borland mit 1,1 beginnt !!!
DWORD len = (global_x1-(global_x))*(global_y1-(global_y)); //laenge*breite
COORD _ = { global_x,global_y };
FillConsoleOutputCharacter(winHan, '' '', len, _, &len);



FillConsoleOutputAttribute(winHan, global_color,len,_,&len);
gotoxy (1, 1);
}
//=====================================================================
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//=====================================================================
void clrol()
{
winHan = GetStdHandle(STD_OUTPUT_HANDLE);

CONSOLE_SCREEN_BUFFER_INFO
sInfo;

GetConsoleScreenBufferInfo(winHan, &sInfo);

DWORD len = sInfo.dwSize.X - sInfo.dwCursorPosition.X + 1;

FillConsoleOutputCharacter(winHan, '' '', len,
sInfo.dwCursorPosition, &len);
}


//=====================================================================
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//=====================================================================
void window(int x, int y, int x1, int y1)
{
//globale Variablen setzen !!
global_x = x-1; // Window (1,1,....) definiert ab linker oberer Ecke
global_y = y-1;
global_x1 = x1;
global_y1 = y1;
gotoxy (1,1);
}





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS