| zoldri (34) | |||
|
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? it is on windpows xp and compiled in dev c++. here is my code:
| |||
|
|
|||
| helios (9442) | |
|
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. | |
|
|
|
| zoldri (34) | |
| hi thanks for fast responce. i have downloaded pdcurses, could you point me to a tutorial on how to use it please. | |
|
|
|
| Sathed (41) | |
|
It appears as though there is documentation on the website... http://pdcurses.sourceforge.net/doc/index.html | |
|
|
|
| zoldri (34) | |
| 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). | |
|
|
|
| Sathed (41) | |
| 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... | |
|
|
|
| zoldri (34) | |
| ok, thank you for helping :) | |
|
|
|
| Sathed (41) | |
| Sorry I couldn't help you any more than that. Keep working at it though, you'll get there. :) | |
|
|
|
| Duoas (6333) | |||||||
|
It does look scary at first, but you can do it without too much difficulty. Take a read through the http://www.faqs.org/docs/Linux-HOWTO/NCURSES-Programming-HOWTO.html The main tricks are 1. initialization, 2. refresh, 3. finalization. 1. Initialization. You probably want the following:
2. Refresh. Every time you want do display changes you must refresh the display.
3. Finalization. Always do this before terminating your program.
Hope this helps. | |||||||
|
|
|||||||
| zoldri (34) | |
|
thanks for the advice i will take a look at them and keep you informed if i make any progress :) when i try to compile the code it comes up with error messages saying curses.h: no such file or directory ? | |
|
Last edited on
|
|
| zoldri (34) | |||
hi i cant get the pdcurses library working but i have solved my problem by adding this:
at the end of the second for loop within pshoot(); thanks for the help :} | |||
|
|
|||
| egregory314 (8) | |
|
Hi, I just looked at your question and would like to offer this little tidbit to your pshoot function: void pshoot() //shoot { int pbullet = '.'; int bpos; for(int x = 1;x < 16;x++) { grid [ypos-x][xpos+1] = pbullet; if (x > 1) grid [ypos-x+1][xpos+1] = ' '; printgrid(grid,20,30); system("cls"); } } Nice little program :) | |
|
|
|
| Duoas (6333) | |
|
> when i try to compile the code it comes up with error messages saying > curses.h: no such file or directory ? > system("cls");To use NCurses on Windows you need to get and install PDCurses http://pdcurses.sourceforge.net/ 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. Good luck! | |
|
|
|
| zoldri (34) | |
|
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. | |
|
Last edited on
|
|
| helios (9442) | |
|
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/ | |
|
|
|
| zoldri (34) | |
| thanks its working now :} | |
|
|
|
| Sathed (41) | |
| You got the program to run correctly? You should consider posting the code for it if you did. I would like to play this :) | |
|
|
|
| zoldri (34) | |
|
i haven't fineshd it yet, i have to learn alot of new stuff with pdcurses but when i finish i'll post the code :} edited: i have put the code so far here just scroll down i will update the code when i have fineshed writing it; http://crazykid-14.piczo.com/cppprograming?cr=3&linkvar=000044 | |
|
Last edited on
|
|
| zoldri (34) | |||
|
i cnat figure out how to kill the bad guys; when they get shot they just re appear and cary on moving can somone help; this is my bad guy function;
| |||
|
Last edited on
|
|||