you will probably end up making a function DrawXY(char) that draws the specified charactor at the XY location on the screen. Just remember in graphics, location 0,0 is the upper left, not the bottom left as it is in math. Going down increases your Y, going right increases X.
As said, the console window is 80x25.
If you would like, I could provide you with a GotoXY function that moves the screen cursor to that console position. This would be necessary for a DrawXY() function, unless you drew your whole screen at once, but that looks crappy =P.
Also, make sure to remove the console cursor (the white blinky thing) with a call to SetConsoleCursorInfo at the start... although I forgot how to get the console handles... I will post them here if you show interest later, when I have access to them, just ask if you want them ^^.
You can also change console text colors with that last function as well. Like I said, if you are interested, ask later ^^. .sen
Pong, the CPU paddle
Yes, please tell me the stuff....and how would you go about the SetConsoleInfo thing?
I''m still not at the computer that I wrote my console header on, but here is a little help...
I assume your using VC++.
#include <wincon.h>
#include <conio.h>
wincon has some usefull functions in it, these include SetConsoleCursorInfo, SetConsoleCursorPos, and a few others. I had functions for changing the color of output and moving the cursor and hiding the cursor etc, I will post their source later ^^ .sen
I assume your using VC++.
#include <wincon.h>
#include <conio.h>
wincon has some usefull functions in it, these include SetConsoleCursorInfo, SetConsoleCursorPos, and a few others. I had functions for changing the color of output and moving the cursor and hiding the cursor etc, I will post their source later ^^ .sen
"I want to make a simple MMORPG first" - Fenryl
rar, I couldn''t get them for you (I forgot to put them on disk =P), but I can still help you out a little...
include those two libraries, wincon, and conio, and then you can do some interesting stuff.
the usefull functions would be SetConsoleCursorPos, SetConsoleCursorInfo, and a couple others. The only problem is that these functions require a handle to your console input... I''m not sure what the function to obtain this handle is but it is similar to GetStdInputHandle or something somewhat similar to that. Anyone know?
I orrigionally found out how to do this by looking at dev-cpp''s conio.h file which has GotoXY and stuff, which I first ported to MSVC++ but then realized they sucked and remade them all together in my own console file... Go get dev-cpp at their web site and then look in the conio.c or conio.cpp file that will have the function implementations. .sen
include those two libraries, wincon, and conio, and then you can do some interesting stuff.
the usefull functions would be SetConsoleCursorPos, SetConsoleCursorInfo, and a couple others. The only problem is that these functions require a handle to your console input... I''m not sure what the function to obtain this handle is but it is similar to GetStdInputHandle or something somewhat similar to that. Anyone know?
I orrigionally found out how to do this by looking at dev-cpp''s conio.h file which has GotoXY and stuff, which I first ported to MSVC++ but then realized they sucked and remade them all together in my own console file... Go get dev-cpp at their web site and then look in the conio.c or conio.cpp file that will have the function implementations. .sen
"I want to make a simple MMORPG first" - Fenryl
ah, cool, then you already have a couple usefull console commands!
You should have a gotoxy function of some sort in the conio.h file. Open it up and see what you have, I remember Dev-CPP coming with a function to set the color and make the blinking cursor go away, though I dont remember how easy they were to use.
Just check out the conio.h file and see if ya cant mess with a few of those functions.
One warning though, when using console functions like gethc(), gotoxy, setcursorinfo or whatnot, it may lock up your cout object (from iostream). Just make sure that you flush your cout buffer before you use those functions.
Flush cout either by inserting flush in there, like
cout<<"This string will go straight to the screen after it is inserted and the buffer will be cleared"<the second way is explicity calling it by using cout.flush()
and the third way is to use endl. all endl really is is ''\n''<<flush, so it will call flush for you and end the line ^^. Hope this helps! .sen
You should have a gotoxy function of some sort in the conio.h file. Open it up and see what you have, I remember Dev-CPP coming with a function to set the color and make the blinking cursor go away, though I dont remember how easy they were to use.
Just check out the conio.h file and see if ya cant mess with a few of those functions.
One warning though, when using console functions like gethc(), gotoxy, setcursorinfo or whatnot, it may lock up your cout object (from iostream). Just make sure that you flush your cout buffer before you use those functions.
Flush cout either by inserting flush in there, like
cout<<"This string will go straight to the screen after it is inserted and the buffer will be cleared"<the second way is explicity calling it by using cout.flush()
and the third way is to use endl. all endl really is is ''\n''<<flush, so it will call flush for you and end the line ^^. Hope this helps! .sen
"I want to make a simple MMORPG first" - Fenryl
Ok, these seem interesting.......here's the cursor stuff and all:
This is all from conio.c from beta 5 version 1 (4.9.1.0)
[edit]Sorry, i was looking in the conio.c file, here's all of the stuff from the conio.h file:
[edited by - Quantrizi on April 24, 2002 5:33:46 PM]
//I think this is the setcursorinfo anyhowvoid _setcursortype(int _type) { CONSOLE_CURSOR_INFO Info; Info.bVisible = TRUE; if (_type == _NOCURSOR) Info.bVisible = FALSE; else if (_type == _SOLIDCURSOR) Info.dwSize = 100; else if (_type == _NORMALCURSOR) Info.dwSize = 1; SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &Info);}//Goto XYvoid gotoxy(int x, int y) { COORD c; c.X = x - 1; c.Y = y - 1; SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);}//Text Backgroundvoid textbackground(int _color) { if (_color == BLINK) _color = WHITE; __BACKGROUND = _color; textattr (__FOREGROUND | (_color + 29));}//Text Colorvoid textcolor(int _color) { if (_color == BLINK) _color = WHITE; __FOREGROUND = _color; textattr(_color | __BACKGROUND);}
This is all from conio.c from beta 5 version 1 (4.9.1.0)
[edit]Sorry, i was looking in the conio.c file, here's all of the stuff from the conio.h file:
#ifndef _CONIO_H_#define _CONIO_H_#ifdef __cplusplusextern "C" {#endifstruct text_info { unsigned char winleft; unsigned char wintop; unsigned char winright; unsigned char winbottom; unsigned char attribute; unsigned char normattr; unsigned char currmode; unsigned char screenheight; unsigned char screenwidth; unsigned char curx; unsigned char cury;};enum COLORS { /* dark colors */ BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, /* light colors */ DARKGRAY, /* "light black" */ LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE};#define BLINK 0x80 /* blink bit; doesn't work yet */#define _NOCURSOR 0#define _SOLIDCURSOR 1#define _NORMALCURSOR 2/* 19 of 31 functions implemented, 62% */int _conio_kbhit();void _set_screen_lines(int nlines);void _setcursortype(int _type); /* done */void blinkvideo();char *cgets(char *_str); /* how does it work? */void clreol(); /* what does it do? */void clrscr(); /* done */#define cprintf printf /* done */int cputs(const char *_str); /* done */#define cscanf scanf /* done */void delline();#define getch getchar /* done */int getche(); /* done */int gettext(int _left, int _top, int _right, int _bottom, void *_destin);void gettextinfo(struct text_info *_r); /* done */void gotoxy(int x, int y); /* done */void gppconio_init(); /* done; does nothing */void highvideo(); /* maybe */void insline(); /* done */void intensevideo();void lowvideo();int movetext(int _left, int _top, int _right, int _bottom, int _destleft, int _desttop);void normvideo();int putch(int _c); /* done */int puttext(int _left, int _top, int _right, int _bottom, void *_source);void textattr(int _attr); /* done */void textbackground(int _color); /* done */void textcolor(int _color); /* done */void textmode(int _mode);int ungetch(int);int wherex(); /* done */int wherey(); /* done */void window(int _left, int _top, int _right, int _bottom); /* done */#ifdef __cplusplus}#endif#endif _CONIO_H_
[edited by - Quantrizi on April 24, 2002 5:33:46 PM]
those are them ^^. I dont think their colors are right, but they are close =P. Anyways the call to get the handle was GetStdHandle (STD_OUTPUT_HANDLE), silly me!
You should do good with that. And it is good practice too.
you could now go about making the game in a few ways, good luck! Any posts about help with the game should probably be in the game programming forum. .sen
You should do good with that. And it is good practice too.
you could now go about making the game in a few ways, good luck! Any posts about help with the game should probably be in the game programming forum. .sen
"I want to make a simple MMORPG first" - Fenryl
Ok, but on the lines of the handle, how would i go about using that (I never used advanced stuff so to speak before)?
you dont even need to mess with it. You can just use those functions that came with dev-cpp. their not perfect, but their nice and quick ^^.
just look in the header, conio.h, as you saw, there is a list of the functions and their parameters.
Those functions handle the handles for you ()
Most of the parameters are self explanator... gotoxy(int x, int y), I think you can guess what they do ^^.
just look in the header, conio.h, as you saw, there is a list of the functions and their parameters.
Those functions handle the handles for you ()
Most of the parameters are self explanator... gotoxy(int x, int y), I think you can guess what they do ^^.
"I want to make a simple MMORPG first" - Fenryl
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement