Coder Social home page Coder Social logo

directx-game-engine's People

Contributors

ksideris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

directx-game-engine's Issues

Vector Iteration

The asteroid iteration loop

for (auto asteroid = m_asteroidData.begin(); asteroid != m_asteroidData.end(); asteroid++)

can have some problems with the iterator asteroid being invalidated. Specifically while adding asteroids with

m_asteroidData.push_back(data);

If the adding of the additional data results in vector reallocation, all iterators are invalidated, and an exception can be triggered by next access of asteroid.

I ran into this problem when firing a lot of bullets and when keeping the asteroids created when hit with a bullet around.

I solved this problem by adding new asteroids to a separate vector, which is then safely dumped into the main vector after the entire asteroid loop is complete.

I also changed the standard iteration to a while loop form

auto asteroid = m_asteroidData.begin();
while(asteroid != m_asteroidData.end())

To avoid checking

if (asteroid == m_asteroidData.end())
break;

on each erasure (only checked on the end of the loop where I do asteroid++), though I don't think that should have any affect on this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.