dos game help

This is a discussion on dos game help within the Game Programming forums, part of the General Programming Boards category; i am working on a very simple dos game that can run even on xp here is the code Code: ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    44

    dos game help

    i am working on a very simple dos game that can run even on xp here is the code
    Code:
    // mover.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    
    int winarray[20][12];
    int move(int where);
    
    enum
    {
      KEY_ESC     = 27,
      ARROW_UP    = 256 + 72,
      ARROW_DOWN  = 256 + 80,
      ARROW_LEFT  = 256 + 75,
      ARROW_RIGHT = 256 + 77
    };
    
    static int get_code ( void )
    {
      int ch = getch();
    
      if ( ch == 0 || ch == 224 )
        ch = 256 + getch();
    
      return ch;
    }
    
    
    int main(int argc, char* argv[])
    {
    	char ch;
    	int count,count2,mover;
    	for(count=0;count<20;count++)
    		winarray[count][0]=1;
    	for(count=0;count<12;count++){
    		winarray[1][count]=1;
    		winarray[20][count]=1;
    	}
    mover=2;
    winarray[1][1]=mover;
    winarray[1][2]=mover;
    winarray[2][1]=mover;
    winarray[2][2]=mover;
    
    	for(count=0;count<20;count++){
    		if(count<12){
    			switch(winarray[count][count]){
    			case 0:{
    				printf(" ");
    				   break;
    				   }
    			case 1:{
    				printf(".");
    				   break;
    				   }
    			case 2:{
    				printf("[]");
    				   }
    			}
    		}
    		if(count<=20){
    			switch(winarray[count][12]){
    			case 0:{
    				printf(" ");
    				break;
    				   }
    			case 1:{
    				printf(".");
    				   }
    			case 2:{
    				printf("[]");
    			}
    		}
    		if(count==20){
    			printf("\n");
    		}
    	}
    while ( ( ch = get_code() ) != KEY_ESC ) {
        switch ( ch ) {
    	case ARROW_UP:{
    system("cls");
    move(1);
    break;
    }
    	case ARROW_DOWN:{
    system("cls");
    move(2);
    break;
    }
    	case ARROW_LEFT{
    system("cls");
    move(3);
    break;
    	}
    	case ARROW_RIGHT{
    system("cls");
    move(4);
    break;
    	}
    }
    					
    
    	return 0;
    }
    
    
    int move(int where){
    	switch(where){
    	case 1:{}		/*move up*/
    	case 2:{}		/*move down*/
    	case 3:{}		/*move left*/
    	case 4:{}		/*move right*/
    	}
    
    return 0;
    }
    i am going to continue working on this but before i start can you guys give me suggestions on what to add to these cases in the move function i would also apprietiate tips to make thi code more effiecient i am only using the knowledge that i have gained inthe past couple of days to create this.this is my first kinda major project

  2. #2
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    Formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting formatting.

    - SirCrono6
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    44

    formatting???

    what the hell do you mean by formmatting?? no really i dont know what you are talking about please explain

  4. #4
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    Well, formatted code:

    Code:
    #include <iostream>
    
    int main( void )
    {
      std::cout << "Hello!!!";
      return 0;
    }
    Unformatted code:

    Code:
    #include <iostream>
    
    int main(void)
    {
    std::cout<<"Hello!!!";
    return 0;
    }
    Semi-formatted code (looks bad):

    Code:
    #include <iostream>
    
    int main(void)
    {
      std::cout<< "Hello!";
    return 0;
    }
    So, having spaces and sort of a "standard" spacing. So, my rule is after every brace there should be a new line and two spaces. Yours could be a tab, three spaces, four etc., etc. See, your code has spaces and then goes done to the next line, no spaces and stuff like that. Although, this may not happen in your compiler and only on the board.

    - SirCrono6
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    44

    ??

    i dont see any difference

  6. #6
    Registered User
    Join Date
    Mar 2004
    Posts
    44

    do you see anything anything wrong

    do you see anything anything wrong with this code

  7. #7
    Registered User
    Join Date
    Mar 2004
    Posts
    44

    this is tougher then i expected

    ok i am having a problem with the above code when i want to move something up or left it will have already chose what to put there and will be filled with what ever it is supposed to be but i need to somehow get around this problem should i just abandon the concept that i am using by using for loops or is there a function that will do that for me i hate wasting peoples time because i know that there are people out there that are using this for more important reasons

  8. #8
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>I don't see any difference
    The difference is, some have proper tabs and some don't. Maybe I can make it more clear:
    Code:
    #include <iostream>
    int main() { std::cout <<
    "Hello world!"
            ;
                                            for(int i = 0;
      i < 5; ++i)
                            {
              std::cout << i;
           }
    return 0;
       }
    That is bad formatting. Bad formatting hard to read. Bad formatting is bad.

    And I can't understand your question, because
    1) you didn't punctuate your sentences and so its hard to figure out what youre talking about and stuff how about you add some periods to your post that will make it easier to understand that way we can figure out where one thought ends and another begins ok sound good?
    2) "it will have already chose what to put there and will be filled with whatever it is supposed to be" doesn't make sense to me. Rephrase your question please.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 02:46 PM
  2. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  3. Help needed with Dos Game!
    By marCplusplus in forum C++ Programming
    Replies: 8
    Last Post: 09-01-2002, 03:19 AM
  4. DOS program versus DOS console program
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2002, 12:42 PM
  5. My next 'dos console' game...
    By Leeman_s in forum C++ Programming
    Replies: 5
    Last Post: 11-09-2001, 05:08 AM

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