Thread: Asteroids 1.0

  1. #1
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669

    Question Asteroids 1.0

    Hi!

    I made this little game in C (VS C++ .NET) just beacuse I'm going to recreate it in assembler for M68HC11 processor for my school project.

    Can anyone please tell me how can I make 10 asteroids at once and that they are all moving from right to left?

    Please take a look at the code.

    Thanks.
    Last edited by GaPe; 04-29-2003 at 08:20 AM.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  2. #2
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    Controls are:
    8 - up
    5 - down
    4 - left
    6 - right

    S - shift (start)
    ESC - escape (end game)
    1,2,3 - select speed
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  3. #3
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    Does really no one knows how to make 10 asteroids at once??

    Help me!!

    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  4. #4
    school goten
    Guest

    Generally....

    // you would probably have a struct of asteriod type
    // an array of 10 asteroid types would be sufficient for 10 asteriod sprites
    sAsteroid asprite = new sAsteroid[10];




    // some where in update and or Init function
    for(int i = 0; i < 10; i++) {
    if(!asprite[i].active) {
    // reinitalize asteriod var values
    // for speed, position and vector etc.
    // I suggest having an id var so you can
    // grab asteroid id's for collision checks etc.
    }
    }

    // some where in collision detection
    for(int i = 0; i < 10; i++) {
    if(collidesWithMe(asprite[i])) {
    asprite[i].state = "explode";
    }
    }

    // some where in your graphics method
    for(int i = 0; i < 10; i++) {
    if(asprite[i].state == "normal")
    drawSprite();
    if(asprite[i].state == "explode")
    drawExplosion();
    }


    etc. etc., you should get the idea by now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL question
    By WinteRx182 in forum C++ Programming
    Replies: 4
    Last Post: 04-22-2009, 08:51 AM
  2. Creating pop up menus
    By Ti22 in forum C++ Programming
    Replies: 22
    Last Post: 01-18-2005, 09:27 PM
  3. geometry won't display!?
    By psychopath in forum Game Programming
    Replies: 17
    Last Post: 09-21-2004, 10:10 AM
  4. render OpenGL geomatry on dialog box button press
    By psychopath in forum Windows Programming
    Replies: 0
    Last Post: 08-20-2004, 08:49 PM
  5. Trouble using Wife 1.0
    By bookworm in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 07-11-2003, 10:41 AM