Game loop

closed account (42hU7k9E)
Can some1 describe me how does the games main loop look like?
I have a problem with AI for a simple game in cmd.exe, my program waits for user to press a key, and so the AI cant move before he puts in a key, and so on and so on. Here is a pseudocode of my loop

do
getch();
check which button is pressed
move AI
while(input is not escape)

What is wrong? Is there an alternative to getch? Should my loop look different? Im confused and can't continue writing the code.
If you can use Windows API, try reading this input example: http://msdn.microsoft.com/en-us/library/ms685035(VS.85).aspx
That won't make your program waiting
closed account (42hU7k9E)
Is there another way? This is too complicated for a begginer like me.
try something like this:

1
2
if ( GetAsyncKeyState(VK_SPACE) )
//if true is pressed, otherwise it isn't 

GetAsyncKeyState doesn't return the current pressed key but it checks if the key corresponding to the code given is pressed
Topic archived. No new replies allowed.