New Game

This is a discussion on New Game within the Game Programming forums, part of the General Programming Boards category; It would have been if I could have seen the source... and it was a dos app using graphics.h...

  1. #16
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200


    It would have been if I could have seen the source... and it was a dos app using graphics.h

    What is C++?

  2. #17
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    >> How can I make it move faster??

    instead of:
    y--,
    y++,
    x-- AND
    x++

    try:
    y-=5,
    y+=5,
    x-=5 AND
    x+=5
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  3. #18
    Unregistered
    Guest
    here's a link to a pacman game that uses bgi:

    http://www.planet-source-code.com/vb...=3031&lngWId=3

    It's from planet-source-code.com

  4. #19
    Registered User
    Join Date
    Aug 2001
    Posts
    106
    i thought you couldnt use BGI in windows...am i wrong?

  5. #20
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    how can u make it move by itself
    you know like if you hit down key move down untill other direction pressed?!

  6. #21
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Nope BGI is not in windows...

    You have to make your target project a DOS app.

    To make it move by itself just do like this:

    Code:
    x=250;
    y=400;
    
     for (/*your loop stuff here*/){
        circle ( x, y, 10 );
        y++
      }
    its something like that... I cant get to my source right noe though.
    What is C++?

  7. #22
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    I have started a space shooter game (like galaga).
    Its called Sonic Space. I have th "map" and the "players ship" set up... and it moves side to side. (I finally figured out that y += 5 instead of y++ on my own) now I need to make bullets and bad guys... and make the badguys shoot and make stuff blow up when its hit...
    What is C++?

  8. #23
    Registered User JoshG's Avatar
    Join Date
    Mar 2002
    Posts
    326
    I am coding a sniper game using Turbo C++ 3 and BGI. I have alot of it done already, I just need to make it so the crosshair doesn't go off the screen and I need to make targets for you to shoot at. I will gladly share the source when it is more complete.

  9. #24
    Registered User JoshG's Avatar
    Join Date
    Mar 2002
    Posts
    326
    I remember you were having problems with keyboard input earlier, so I will post what I have done:

    You may need to change the initgraph() function so that the BGI part points to the right location, then it should compile. Again I used Turbo C++ 3.0

    [edit]By the way, I know the up and down keys are flipped, that is easily fixed.[/edit]
    Attached Files Attached Files

  10. #25
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Bullets.. this is just a guess.

    Code:
    .
    .
    .
    case 's': bullet(); break;
    .
    .
    .
    void bullet()
    {
        circle ( x, y, 1 );
         
          for() {
             delay(30);
             y++;
          }
    }
    Last edited by Vicious; 05-30-2002 at 03:36 PM.
    What is C++?

  11. #26
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Code:
    #include <iostream.h>
    #include <graphics.h>
    #include <conio.h>
    
    int GraphicsDriver;
    int GraphicsMode;
    
    int x = 300;
    int y = 430;
    int quit = 0;
    int mve;
    
    
    int main()
    {
      initgraph ( &GraphicsDriver, &GraphicsMode, "c:\\bc5\\bgi" );
    
      while ( !quit )
      {
          gotoxy(1,1);
      		cout << "X: " << x << "  Y: " << y;
    
          settextstyle ( 1, HORIZ_DIR, 2 );
          setcolor(RED);
          outtextxy ( 230, -5, "Sonic Space" );
    
          setcolor (BLUE);
          rectangle ( 140, 20, 440, 470 );
    
          mve = getch();
    
          switch ( mve )
          {
             case 'd': if( x != 430 ) x += 5; break;
             case 'a': if( x != 150 ) x -= 5; break;
             case 'q': quit=1; break;
          }
          	cleardevice();
             setfillstyle ( SOLID_FILL, BLUE );
             setcolor (RED);
             pieslice ( x, y, 240, 300, 15 );
       }
    closegraph();
    return 0;
    }
    there is what I have so far
    What is C++?

  12. #27
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    none of the codes move by itself!?

  13. #28
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    what you mean?

    any way after someone tells me bout the bullets.. how about being able to move and shot at the same time?
    What is C++?

  14. #29
    Registered User JoshG's Avatar
    Join Date
    Mar 2002
    Posts
    326
    I added some more to my code, alot of stuff is wrong right now, if you try you can move the cursor off the screen to the right and bottom. The bullets stay of the screen. I think I need to redesign it. I need a linked list of bullets I guess. Then I need a different way to control it. Right now I have processinput() that moves the crosshair and all, but it stays in that function untill you hit escape, I need to code a processinput that gets passed the input and does stuff based on it, so I can use it for more than just moving the crosshair and drawing bullets. I also need to make moving the crosshair less jumpy. I think I should change all the if statements in processinput() to a switch statement.

    Code:
    // sniper.cpp
    // A weak ass sniper game by Josh Grant
    // jrgrant@ciusa.net
    //
    // Compiled using Turbo C++ 3.0
    
    #include <graphics.h>
    #include <conio.h>
    
    #define ESC_KEY 27
    #define SPACE_KEY 32
    #define UP_KEY 72
    #define RIGHT_KEY 77
    #define DOWN_KEY 80
    #define LEFT_KEY 75
    
      void intro();     // Shows the intro to the game
      void setup();     // Sets graphics mode
      void desetup();   // Resets graphics mode and shows game credits
    
      void drawcrosshair(int x, int y);  // WTF do you think? :)
      void erasecrosshair(int x, int y); // This draws the crosshair, but in black, so it erases it
    
      void fire(int x, int y); // Draws a bullet, or a small explosion, well, just some dots
    
      void processinput(); // When you hit a key, the crosshair moves, :)
    
    int main()
    {
      setup();
      intro();
      processinput();
      desetup();
    
      return 0;
    }
    
    void intro()
    {
      setcolor(RED);
      settextstyle(4, 0, 8);
      outtextxy(200, 100, "Sniper");
    
      settextstyle(0, 0, 1);
      outtextxy(200, 250, "Welcome to sniper, ready to hunt?");
      outtextxy(200, 300, "Hit any key to start...");
    
      getch();
      cleardevice();
    }
    
    void setup()
    {
      int graphdriver = 9;
      int graphmode = 2;
      initgraph(&graphdriver, &graphmode, "c:\\tc\\bgi");
    }
    
    void desetup()
    {
      closegraph();
    }
    
    void drawcrosshair(int x, int y)
    {
      // First we draw two lines, to make the + part
      setcolor(RED);
      // vertical line
      line(x, y+50, x, y-50);
      // horizontal line
      line(x-50, y, x+50, y);
      // circle
      circle(x, y, 35);
    }
    
    void erasecrosshair(int x, int y)
    {
      setcolor(BLACK);
      // All we are doing is drawing a cross hair, but making it black so it dissapears
      // First we draw two lines, to make the + part
      // vertical line
      line(x, y+50, x, y-50);
      // horizontal line
      line(x-50, y, x+50, y);
      // circle
      circle(x, y, 35);
    }
    
    void fire(int x, int y)
    {
      setcolor(CYAN);
      circle(x, y, 1);
      circle(x, y, 2);
      circle(x, y, 3);
      circle(x, y, 4);
    }
    
    void processinput()
    {
      int x = 60, y = 60;
      drawcrosshair(x, y);
      int theinkey = 0;
    
      while(theinkey != ESC_KEY)
      {
        if(theinkey == SPACE_KEY)
          fire(x, y);
        if(theinkey == UP_KEY && y > 61)
        {
          erasecrosshair(x, y);
          y -= 25;
          drawcrosshair(x, y);
        }
        if(theinkey == RIGHT_KEY)
        {
          erasecrosshair(x, y);
          x += 25;
          drawcrosshair(x, y);
        }
        if(theinkey == DOWN_KEY)
        {
          erasecrosshair(x, y);
          y += 25;
          drawcrosshair(x, y);
        }
        if(theinkey == LEFT_KEY && x > 61)
        {
          erasecrosshair(x, y);
          x -= 25;
          drawcrosshair(x, y);
        }
        theinkey = getch();
      }
    }

  15. #30
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    wow!

    very nice... i love your comments :P

    can you explain on making bullets?
    What is C++?

Page 2 of 4 FirstFirst 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 11:44 AM
  3. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-25-2002, 12:00 AM

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