Hi i am very new to c++ and and this forum and i am trying to make an ASCII space invaders game while i learn. i have got a main menu function and am able to create a grid and the player but i cant get the bullet to work properly.can any one help please?
Yup. Streams aren't designed for games. They are designed to input and output data in a manner as generic as possible. That's why there are no functions to position the cursor on the console. The console's presence is incidental. Output could be going to a file.
Anyway, the library you need is ncurses or PDcurses: http://www.gnu.org/software/ncurses/ (GPLed) http://pdcurses.sourceforge.net/ (public domain)
If you have something against weird bearded men telling you what to do with your source code, you might want to try out PDcurses first. I know I will.
it looks to complicated for me i have only been programing for 3 weeks is there any other tutorial or any easier way to sort my program(im not trying to sound lazy).
My suggestion, and I'm not trying to be rude, but I would start out with an easier program until you get a bit more fluent... Those library definitions can be pretty tough to decipher, even if you've been coding for 20 years...
The main tricks are 1. initialization, 2. refresh, 3. finalization.
1. Initialization. You probably want the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// Start curses
initscr();
// Direct key input
raw();
(void)noecho();
nonl();
intrflush( stdscr, FALSE );
(void)keypad( stdscr, TRUE );
// I want colors!
// (You may actually want to check has_color() first)
start_color();
// Make the cursor invisible (hopefully)
curs_set( 0 );
2. Refresh. Every time you want do display changes you must refresh the display.
1 2 3 4 5 6 7 8 9 10 11 12
// Main event loop
while (...)
{
// check for and act on user input
...
// draw the current display (using mvaddch() and the like)
...
// show the changes
wrefresh( stdscr );
}
3. Finalization. Always do this before terminating your program.
If you are using MinGW, you can download and unzip the pdcurses file directly into your C:\MinGW directory and you are all set. For other's you might as well just download the source archive (it is small) and execute the makefile appropriate for your compiler. For example, if you are using MS VC++, change to the ~\win32 directory and execute make -f vcwin32.mak from the command prompt (or load and execute it directly from the IDE).
Using system("cls") is really a bad idea, for a lot of reasons. Unfortunately, I've tired of explaining them at the moment.
thanks for your help.
i know system("cls") isnt good but i cant find any other way
please could you post a link to a better way thanks :}
i have got pdcurses working it compiles correctly but when i run the program that was created it says :
this application has failed to start because SDL.dll was not found.
What? Impossible. You didn't leave any .libs attached to the default configuration of the compiler, did you?
You can download SDL.dll from http://www.libsdl.org/