Skip to content

Commit

Permalink
Simplify loop in updateObjects() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed May 2, 2017
1 parent 558f1f6 commit e63ad7c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/ui/components/glimmeroids-app/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,13 @@ export default class Glimmeroids extends Component {
}

updateObjects(items: Entity[], group: 'asteroids' | 'ship' | 'particles' | 'bullets') {
let index = 0;
for (let item of items) {
for (let i = 0; i < items.length; i++) {
let item = items[i];
if (item.delete) {
this[group].splice(index, 1);
this[group].splice(i, 1);
} else {
items[index].render(this.state);
item.render(this.state);
}
index++;
}
}

Expand Down

0 comments on commit e63ad7c

Please sign in to comment.