Thread: Asteroids

  1. #1
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229

    Asteroids

    What do you think of my asteroids game so far?

    http://www.opticalmusic.net/asteroids.zip

    The ship movement is a little squirrely and the collision isn't perfect.
    There is a 5 second spawn protect encase an asteroid spawns on top of you.
    No scoring or hyperspace yet.

    arrow keys: move
    spacebar: shoot

  2. #2
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    I quite like it.

  3. #3
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    I'm not sure why, but I turn very slowly, and can't thrust at all.

  4. #4
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    It's pretty good methinks. And you got your first bug report

  5. #5
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229
    Quote Originally Posted by Queatrix View Post
    I'm not sure why, but I turn very slowly, and can't thrust at all.
    I think it might have something to do with the screen resolution. I'm on 1024 x 768 and it works fine if you don't resize the window after it opens, but if you hit maximize, then everything goes super slow.

    If you were running it in full screen, then it's probably something completely different.

    Anyhow, thanks for letting me know. I'll try and get it fixed.

    Edit: Ok I tried it at 800x600 and it does exactly what you were explaining. I found that I accidentally left the ship movement based of frames, so if you were getting low frames (Well, lower then 500 xD) The movement was slowed. Everything else was still moving fast because it's time based. Fixing it now.
    Last edited by IdioticCreation; 05-12-2007 at 11:34 AM.

  6. #6
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229

  7. #7
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    It looks good and handles decent enough, though it keeps crashing on me (standard, caused an error in asteriods.exe). Seems to be happening while shooting...

    *I'm using WinMe (if that means anything).

  8. #8
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229
    Yeah, it wasn't happening on my computer, but I tried it on my friends and it did crash. Specifically when you shoot the small asteroids. No idea why at the moment.

  9. #9
    Registered User
    Join Date
    Oct 2006
    Location
    UK/Norway
    Posts
    485
    Haha, cool game. Brings back memory of old ways. I still remember me playing something like this with my brother at my grandpas computer (He had a kickass computer at that time, and than he got old :P)

    Maybe you should try to break up the code a bit? The file is quite long right now. Also, I would be good to have an option to restart the game. Right now it quits when I die (only one life?)

    Anyway, good game

  10. #10
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    I like it, except I'm the worst Asteroids player in the world. I can't even destroy one whole asteroid
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  11. #11
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229
    I'm not sure if this should be a separate thread, but any who.

    In regard to this problem:
    though it keeps crashing on me (standard, caused an error in asteriods.exe). Seems to be happening while shooting...
    It hadn't been happening on my computer, just certain ones. Today I added sound using the irrKlang library and now it is crashing on my computer when I shoot small asteroids. It also happened with FMOD (the c implementation). When you play a sound, does it create a separate thread or something to be processed? I really have no idea why the sound is causing the crash, because they don't appear to be related.

    Basically it's like this:
    I can have this code:
    Code:
    hidden = true; //To kill the asteroid
    or
    Code:
    ISoundEngine* engine = createIrrKlangDevice();
    if (!engine)
    return 0; // error starting up the engine
    engine->play2D("song.mp3", true);
    but not both. And fyi the hidden = true causes a large portion of the code for that particular asteroid not to be executed, that could have something to do with it.

    David

  12. #12
    Amazingly beautiful user.
    Join Date
    Jul 2005
    Location
    If you knew I'd have to kill you
    Posts
    254
    My guess is something along the lines of incorrect memory managment (haven't gotten a chance to look at the code yet), which would cause it to run on some computers but crash on others, simply because on those computers the memory you try to access is luckily within your programs address space, while on others it is not, causing the crash.

    Loading the mp3 file, and linking to the sound library would shuffle around your programs memory some, possibly pushing an incorrect address out of bounds.

    IE, if you do
    Code:
    int *bob = new int[10];
    int *jon = new int[10];
    bob[13] = 5;
    There is a relatively good chance that jon will get allocated directly after bob, and therefore bob[13] is still within your programs address space (just, within jon). On some computers, you might not be so lucky (and an additional library could destory the balance too).
    Programming Your Mom. http://www.dandongs.com/

  13. #13
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229
    Thanks, it sounds like a mess.

    EDIT: Well I got pretty lucky and found it quickly. All the collision is calculated in my asteroid::calculate() function, including collision for the ship. That function is supposed to return an int saying which bullet hit the asteroid, that way the ship class can hide that shot. In the calculate function I said if the asteroid is hidden, then do nothing, not even return an integer. So the ship class was trying to hide the number of a shot that wasn't even returned.

    Thanks for helping getting me started, Norman.
    Last edited by IdioticCreation; 05-14-2007 at 03:20 PM.

  14. #14
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158
    Sometimes the triangle goes offscreen and won't come back.

  15. #15
    Amazingly beautiful user.
    Join Date
    Jul 2005
    Location
    If you knew I'd have to kill you
    Posts
    254
    Glad that worked out.
    Programming Your Mom. http://www.dandongs.com/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. First screenie of 2d asteroids
    By VirtualAce in forum Game Programming
    Replies: 17
    Last Post: 12-06-2004, 05:20 PM
  2. Asteroids 1.0
    By GaPe in forum Game Programming
    Replies: 3
    Last Post: 04-30-2003, 10:11 AM
  3. ai for enemy ships in asteroids
    By ichijoji in forum Game Programming
    Replies: 7
    Last Post: 04-09-2003, 04:09 PM
  4. msdos asteroids
    By seditee in forum Game Programming
    Replies: 3
    Last Post: 04-29-2002, 11:31 PM
  5. Anybody have the source code to asteroids?
    By Fool in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 09-02-2001, 06:21 PM