From 558f1f6a704a82a084061ab76c10197de0ca0605 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Tue, 2 May 2017 13:41:26 +0200 Subject: [PATCH] Simplify loops in checkCollisionsWith() method --- src/ui/components/glimmeroids-app/component.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/ui/components/glimmeroids-app/component.ts b/src/ui/components/glimmeroids-app/component.ts index 07e92a4..49a9daa 100644 --- a/src/ui/components/glimmeroids-app/component.ts +++ b/src/ui/components/glimmeroids-app/component.ts @@ -269,12 +269,9 @@ export default class Glimmeroids extends Component { } checkCollisionsWith(items1: Entity[], items2: Entity[]) { - let a = items1.length - 1; - let b; - for (a; a > -1; --a) { - b = items2.length - 1; - for (b; b > -1; --b) { - let item1 = items1[a]; + for (let a = 0; a < items1.length; a++) { + let item1 = items1[a]; + for (let b = 0; b < items2.length; b++) { let item2 = items2[b]; if (this.checkCollision(item1, item2)) { item1.destroy();