Dears,
I am new to this Forum.
Thanks a lot to Chilli for his great C++ programming tutorial series. I have been following it for almost a year now (currently mid of intermediate) and learned so much.
As a practicing project I made a version of "Asteroids", which I played a lot as a kid on my Atari.
It's pretty much complete now, only sound is missing.
Please check it out and tell me what you think!
Move the rocket with arrow keys (left and right rotate, up starts engine). To slow down rocket you must apply reverse thrust. Space to fire. Collect power ups if you can.
The game needs quite some ressources (especially in higher levels with many asteroids). Best run in release mode.
https://github.com/ChristianOhm/Asteroids
Best
Christian
My version of classic Asteroids game
My version of classic Asteroids game
- Attachments
-
- Asteroids.zip
- (1.4 MiB) Downloaded 148 times
Last edited by Christian on May 17th, 2019, 8:22 pm, edited 2 times in total.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: My version of classic Asteroids game
Crashed when about to show scores.
This is never a good idea because the end will move as the vector grows and shrinks and iterators are based on the address of the element after the last in a vector. So, the end ( newEntry ) is not going to be the same in the beginning of the program as opposed to the point where the scores are shown.
Anyway, the error was that the iterators are not compatible, and I'm thinking this is the reason why.
Oh, also when the vector grows, all previous iterators are invalidated so storing an iterator in general is never a good idea.
Code: Select all
std::vector<Entry> entries;
std::vector<Entry>::iterator newEntry = entries.end();
Anyway, the error was that the iterators are not compatible, and I'm thinking this is the reason why.
Oh, also when the vector grows, all previous iterators are invalidated so storing an iterator in general is never a good idea.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: My version of classic Asteroids game
Strange, why does it work on my computer but not on yours? This makes bugfixing complicated...
newEntry is used to store the player's name while it is typed in. It defaults to entries.end() but is set to new value once new Highscore achieved.
Will look into this tomorrow…
Thanks
Christian
newEntry is used to store the player's name while it is typed in. It defaults to entries.end() but is set to new value once new Highscore achieved.
Will look into this tomorrow…
Thanks
Christian
Re: My version of classic Asteroids game
Ok, I fixed it.
The error only occured in debug mode, not in release.
Problem was when displaying highscores with no new entry.
Please try again.
The error only occured in debug mode, not in release.
Problem was when displaying highscores with no new entry.
Please try again.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: My version of classic Asteroids game
Yeah, I should have given that information and I kind of figured the debug vs release was going to be what confused the issue. Debug has checks for bounds and such whereas Release does not.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com