hello, im trying to make a simple 2d game and i have some questions, first how can i make that the person who plays the game doesnt hit enter, another question, how can make that i the game plays normally i mean that i dont have to output the screen more then once... also how to first output the text then color it?
how can make that i the game plays normally i mean that i dont have to output the screen more then once..
Athar wrote:
What's that supposed to mean?
I guess he is having a misconception that a game's screen (Board, map, whatever you want to call it) is only output only once and every time else it is just changed!
You do that by clearing the whole screen (I assume you are using the console?), make the changes on the map, and the output it again
first how can i make that the person who plays the game doesnt hit enter,
Eh... ask the user nicely?
lolz, i mean to how to get input without the user hitting enter
Begginer wrote:
how can make that i the game plays normally i mean that i dont have to output the screen more then once..
Athar wrote:
What's that supposed to mean?
I guess he is having a misconception that a game's screen (Board, map, whatever you want to call it) is only output only once and every time else it is just changed!
You do that by clearing the whole screen (I assume you are using the console?), make the changes on the map, and the output it again
well thats what i am asking, example: pacman, they dont clean the whole screen and edit and print it again.... also in pacman user doesnt hit enter after every,w,a,s,d move. i want that too...
also how to first output the text then color it?
Print the text again, this time with the right color. Either that or change the color of the pixels afterwards.
what im asking,how to make a change in the already existing text, i dont want to print it more then once...
You'll have to use a graphics package that allows an event loop to be running and provides for blitting sprites onto the screen to do what you want. If you don't know what those things are, you'll need to learn it all (and more) before you can code a 2-D game like you described. There are near infinite websites that teach all this stuff. Start googling and reading because there are no easy answers to the questions you asked. You have to learn it from the bottom up...
You may be interested in SFML (http://www.sfml-dev.org/). It has everything cnoeval described, and more. It is very easy to install, learn and use. The documentation and tutorials on the website have everything you will need to know:)
i dont want sprites i will use something like this " O- " a man with a gun or something so if u could just tell me some command i said i am a beginner....
----
also i know that it is possible because my friend that is better then me made a game, he made a menu and using w,a,s,d you could choose start, help, quit....
in menu he made that he first couts letters then colors it, i want to know how, he wont tell me...
also in the game, he doesnt couts the whole screen more then once... he makes changes within the screen, i think he is using some coords...
If you are programming in the console, then there is no way to do so.
You need SFML, or any other graphics library.
There is no direct function to add a sprite and make it move and so on.
Using GetAsyncKeyState is definitely more complex than you think.
It works by checking if any key is pressed down on the keyboard.
To use it you will have to use call it four times and check for the four character codes.
You can use the above function as:
1 2
char x;
x = readkey();
This will that input of any key you press and return its ASCII code, which will be converted into a character for x.
Then you can check for whether x is "w" or "s" or "a" or "d".
thanks for that :D and yes i know its complex i tried to find it several times, maybe in the future i will understand it
---
can u just give me some includes about that?
Also, I know you've been told it a million times already, but using a multimedia/graphics package really is a lot easier than Windows (or any other OS) programming, not to mention the fact that it means it isn't platform specific.