Your Ad Here Your Ad Here
Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: C Programmers Come Here

  1. #1
    BANNED
    Join Date
    Jul 2003
    Location
    Guatemala
    Posts
    4,097
    Hey what up. Well if you didn't read before, I'm learning C right now (and should have learned it in 1 week lol). Anyways, the only C project the teachers are leaving is either making a Galaga-type of game or a text editor. I went for the game, since it looks easier (specially since the text editor has to be a notepad wannabe).

    Here's my code for the game

    Code:
    #include <stdio.h>
    #include <conio.h>
    #include <stdlib.h>
    #include <dos.h>
    
    int x = 37;
    int y = 25;
    char b;
    
    
    void ship (int x, int y);
    void shoot (int x, int y);
    void menu ();
    void salida ();
    
    void salida(){
    	clrscr();
    	delay(1000);
    	printf("Gracias por jugar\n");
    	exit(0);
    }
    
    
    void shoot(int x, int y){
    	int i=21;
    	while (i>0){
      int ejex = x;
      gotoxy(ejex+3, i);
      printf("|");
      delay (10);
      i--;
    	
    	}
    	ship(x, y);
    
    }
    
    void ship(int x, int y){
    	clrscr();
    	gotoxy(x,y);
    	printf("*-----*");
    	gotoxy(x,y-1);
    	printf(" *---* ");
    	gotoxy(x,y-2);
    	printf("  *-*  ");
    	gotoxy(x,y-3);
    	printf("   *   ");
    
    
    	b = getch();
    
    	switch (b){
    
      case 'a':
      	ship(x-7,y);
      	break;
      
      case 'd':
      	ship(x+7,y);
      	break;
      
      case 's':
      	shoot(x, y);
      	break;
      
      case 'm':
      	menu();
      	break;
    
      case 'z':
      	salida();
      	break;
    
      default:
      	ship(x, y);
    	}
    	
    }
    
    void menu(){
    
    	clrscr();
    	gotoxy(22,10);
    	printf("Izquierda  	A\n");
    	gotoxy(22,11);
    	printf("Disparar  	S\n");
    	gotoxy(22,12);
    	printf("Derecha    D\n");
    	gotoxy(22,13);
    	printf("Menu    M\n");
    	gotoxy(22,14);
    	printf("Salir    Z\n");
    	gotoxy(22,16);
    	printf("Para empezar a jugar, presione E\n");
    	gotoxy(22,17);
    	printf("Para salir, presione Z\n");
    
    	b = getch();
    
    	switch (b){
    
      case 'e':
      	ship(x, y);
      	break;
    	
      case 'z':
      	salida();
      	break;
    
      default:
      	menu();
        	
    	}
    
    }
    
    
    void main(){
    
    	menu();
    
    }
    The menu and stuff is in spanish. Just press E to go playing or Z to exit. While playing, you use A and D to move left and right, S to shoot, M to return to the menu, and Z to exit.

    As you would obviously see, the game is at no point done. The only thing the ship can do now is move and shoot. However my question would be this:

    1. Try moving to the far right or far left, beyond the screen. Any ideas on how to set the limits? I have an idea of putting an if statement in the switch in the ship function, but if you have any more ideas, please share.

    2. Any ideas on how to create random evil ships? And as well, how to actually make em die?

    Thanks, it's all in the name of knowledge

    By the way, compile with Borland 3.1, cuz I don't think the other compilers will work (since it's not an ANSI program, it contains other functions and libs).

    Bye B)

  2. Software & Hardware   -   #2
    h1
    Guest
    DWk, I believe you said your course was ANSI C...

  3. Software & Hardware   -   #3
    abu_has_the_power's Avatar I have cool stars
    Join Date
    Apr 2003
    Posts
    6,503
    C is a bit old. at least C++ man

  4. Software & Hardware   -   #4
    BANNED
    Join Date
    Jul 2003
    Location
    Guatemala
    Posts
    4,097
    Originally posted by haxor41789@25 January 2004 - 19:30
    DWk, I believe you said your course was ANSI C...
    That noob-ass teacher really confused us. They explained a lot about ANSI (well not really), and didn't explain there was MORE to ANSI.

    And I was trying to compile my program with DJGPP (GCC for windows), then a friend told me that I had to compile with TurboC or BorlandC. Pissed me off.

    But nothing I can do anymore, just shut up and do it.

    EDIT - Abu, I can't go with the university teacher and tell him to change it

  5. Software & Hardware   -   #5
    shn's Avatar 3μ|\|(7
    Join Date
    May 2003
    Posts
    3,585
    Originally posted by abu_has_the_power@25 January 2004 - 20:35
    C is a bit old. at least C++ man
    It may be old but its one the best languages around

  6. Software & Hardware   -   #6
    h1
    Guest
    Originally posted by shn+26 January 2004 - 04:51--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (shn @ 26 January 2004 - 04:51)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin-abu_has_the_power@25 January 2004 - 20:35
    C is a bit old. at least C++ man
    It may be old but its one the best languages around [/b][/quote]
    True that.

  7. Software & Hardware   -   #7
    cselik's Avatar Poster
    Join Date
    Jan 2004
    Location
    Srbija
    Posts
    85
    Originally posted by DWk@26 January 2004 - 02:35
    And I was trying to compile my program with DJGPP (GCC for windows), then a friend told me that I had to compile with TurboC or BorlandC. Pissed me off.

    But nothing I can do anymore, just shut up and do it.
    yes there is something u can do, is write programs properly in the start by saying what to do on different platforms
    Code:
    #ifdef &nbsp;WIN32
    #include &#60;winsock.h&#62;
    #else
    #include &#60;netdb.h&#62;
    #include &#60;sys/types.h&#62;
    #include &#60;sys/socket.h&#62;
    #include &#60;netinet/in.h&#62;
    #include &#60;netinet/protocols.h&#62;
    #include &#60;arpa/inet.h&#62;
    #endif
    in exams i took one would fail if his programs didn&#39;t compile on any random compiler (yea and do whats it defined to do)

  8. Software & Hardware   -   #8
    BANNED
    Join Date
    Jul 2003
    Location
    Guatemala
    Posts
    4,097
    But I&#39;m actually compiling in Windows, so that&#39;s not the problem.

    In the university, I have to do so as well (not SHH and use Putty and GCC), I&#39;ll ask today why do we have to. I think it is because TC and BC include some libraries that GCC doesn&#39;t. Let me ask and I&#39;ll get back at you

    BTW anyone tried the program?

  9. Software & Hardware   -   #9
    cselik's Avatar Poster
    Join Date
    Jan 2004
    Location
    Srbija
    Posts
    85
    Originally posted by DWk@26 January 2004 - 11:03
    But I&#39;m actually compiling in Windows, so that&#39;s not the problem.

    In the university, I have to do so as well (not SHH and use Putty and GCC), I&#39;ll ask today why do we have to. I think it is because TC and BC include some libraries that GCC doesn&#39;t. Let me ask and I&#39;ll get back at you
    not TC and BC you did.
    Code:
    &#60;dos.h&#62;

    BTW anyone tried the program?
    where&#39;s the enemies?

    Try my game :
    arkanoid II

    what u think?

  10. Software & Hardware   -   #10
    BANNED
    Join Date
    Jul 2003
    Location
    Guatemala
    Posts
    4,097
    Originally posted by cselik+26 January 2004 - 05:44--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (cselik @ 26 January 2004 - 05:44)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin-DWk@26 January 2004 - 11:03
    But I&#39;m actually compiling in Windows, so that&#39;s not the problem.

    In the university, I have to do so as well (not SHH and use Putty and GCC), I&#39;ll ask today why do we have to. I think it is because TC and BC include some libraries that GCC doesn&#39;t. Let me ask and I&#39;ll get back at you
    not TC and BC you did.
    Code:
    &#60;dos.h&#62;

    BTW anyone tried the program?
    where&#39;s the enemies?

    Try my game :
    arkanoid II

    what u think? [/b][/quote]
    Enemies, bleh I said I only did the moving and shooting part.

    That&#39;s why I&#39;m asking help here

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •