help starting a game.

This is a discussion on help starting a game. within the Game Programming forums, part of the General Programming Boards category; ok, i am trying to make a basic game, like an overhead action game, with basic ascii graphics. I want ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    85

    help starting a game.

    ok, i am trying to make a basic game, like an overhead action game, with basic ascii graphics. I want to set up the game in some sort of time loop, so I can move the enimies around every 1 sec, or whatever. I used the getch() function to get keyboard input, for moveing the player, but the problem is that when the program executed the getch(), it pauses and waits for the user input. this means that everything else can only move when the player moves. does this make any sense? how would I go about doing this?

  2. #2
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    I would like to know as well

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    88
    can you tell what kind of enemies you do

    what size


    and more about the game
    ??

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    85
    there just basic enemies, represented on the screen with 1 character, (for ex: 'o') starting out, all I want to do is have the enemies chase after the player, and let the player be able to move at the same time. If the enemy touches the play, he dies. Once I get that to work I can add to it.

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    57
    Hmm.. I am not really sure either but this might work. Create another function for the computer like
    void MoveComputer(hOutput, STRUCT computer);
    or something. Make it so it moves randomly about or something in a certain area, and if the player moves, make it so it moves towards the player. I am not sure if thats what your wanting or not though... I kind of confused myself.
    Language: C++
    Compiler: Visual C++ 6.0
    Currently Working On: Simple OpenGL aspects

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Here's some sample code from a game I wrote a long time ago. I understand why you don't want the game to wait for the getch( ), so basically you just want to be informed when someone DOES hit a key. Try this. Also you must include the header file CONIO.H NOTE: This is only a code snippet

    Code:
    int keycode;
    // If a key is hit do something!
    		if( kbhit() )
    		{
    			keyCode = getch();
    			
    			// Left movement
    			if( keyCode == 49 )
    			{
    				pBoss->Move( keyCode );
    			}
    			
    			// Down movement
    			else if( keyCode == 50 )
    			{
    				pBoss->Move( keyCode );
    			}
    			
    			// Right movement
    			else if( keyCode == 51 )
    			{
    				pBoss->Move( keyCode );
    			}
    			
    			// Up movement
    			else if( keyCode == 53 )
    			{
    				pBoss->Move( keyCode );
    			}
    			else if( keyCode == 109 )
    			{
    				if( !bRandom )
    				{
    					bRandom = true;
    					pBoss->Move( keyCode );
    				}
    				else
    				{
    					bRandom = false;
    				}
    			}
    		}

  7. #7
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    yeah but it looks to me like that code would stop or atleast slow down the other moving sprites when you move your character

  8. #8
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Yes, most likely for a fraction of a second

  9. #9
    Aran
    Guest
    um.. i'd highly consider going to http://www.gametutorials.com and check out the console tutorials to get a decent idea of how to do this stuff..

    *sigh* if only C++ could use true multithreading like Java.

  10. #10
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Originally posted by Xterria
    yeah but it looks to me like that code would stop or atleast slow down the other moving sprites when you move your character
    No noticeable slow down for me. It worked fine and I had a decent amount of stuff on the screen.

  11. #11
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    C++ can do multithreading, you just have to find the right 3rd party libraries or OS support. I know you can download a Win32/Dos port of the POSIX pthreads, heres a link: http://sources.redhat.com/pthreads-win32/ ,enjoy.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  12. #12
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169

    this may help

    im making a game like you are qwertiop
    im using a two dimensional character array to hold the background
    then vaiables to hold the top and left positions of the enemies
    and a set of variables to hold the position of the guy

    use the code mr wizard gave you, but modify it and call a make screen function at the end of it
    in the make screen code clear the screen and then show the 2 d array
    the hardest part is collision detection

    Actually here is the game i have partially finished. It might help you. It is poorly commented and pretty ridiculous at points but it should help you. Enemies are not programmed yet, and your keys are up down left right and escape to end. Walls fall randomly and will eventually block your way. Unfortunetly its only 40% finished, but its only my second game and I think it's pretty good so far. (The death animation may have some glitches, I haven't looked at it in awhile)
    Attached Files Attached Files

  13. #13
    Aran
    Guest
    i would suggest using COORD type structs to hold the cursor position and the positions of the players and enemies, so that way you don't have to keep making calls to the setConsoleCursorPosition...

  14. #14
    Registered User
    Join Date
    Sep 2001
    Posts
    85
    thanks everyone, your responses were a big help. i got the main stuff working now.

  15. #15
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    I like how Allegro handles the keyboard. It's very easy to use.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Starting 2D Game Programming...
    By Junior89 in forum Game Programming
    Replies: 8
    Last Post: 06-20-2006, 08:47 PM
  2. PC Game project requires c++ programmers
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 02-21-2006, 11:23 PM
  3. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-25-2006, 11:14 PM
  4. Game structure, any thoughts?
    By Vorok in forum Game Programming
    Replies: 2
    Last Post: 06-07-2003, 01:47 PM
  5. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21