{"action":"opened","issue":{"url":"https://api.github.com/repos/JoelLimes/EndlessRunner/issues/2","labels_url":"https://api.github.com/repos/JoelLimes/EndlessRunner/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/JoelLimes/EndlessRunner/issues/2/comments","events_url":"https://api.github.com/repos/JoelLimes/EndlessRunner/issues/2/events","html_url":"https://github.com/JoelLimes/EndlessRunner/issues/2","id":109759044,"number":2,"title":"DRY","user":{"login":"RichardRam87","id":5513037,"avatar_url":"https://avatars.githubusercontent.com/u/5513037?v=3","gravatar_id":"","url":"https://api.github.com/users/RichardRam87","html_url":"https://github.com/RichardRam87","followers_url":"https://api.github.com/users/RichardRam87/followers","following_url":"https://api.github.com/users/RichardRam87/following{/other_user}","gists_url":"https://api.github.com/users/RichardRam87/gists{/gist_id}","starred_url":"https://api.github.com/users/RichardRam87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RichardRam87/subscriptions","organizations_url":"https://api.github.com/users/RichardRam87/orgs","repos_url":"https://api.github.com/users/RichardRam87/repos","events_url":"https://api.github.com/users/RichardRam87/events{/privacy}","received_events_url":"https://api.github.com/users/RichardRam87/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-05T09:23:31Z","updated_at":"2015-10-05T09:23:31Z","closed_at":null,"body":"```c\nswitch(bgNumber)\n            {\n            case 0:\n                if (instantiateBackground != null)\n                {\n                    if (instantiateBackground.transform.position.x <= screenSize.x)\n                    {\n                        Destroy(instantiateBackground.gameObject);\n                    }\n                }\n                instantiateBackground = Instantiate(bgArray[bgNumber].gameObject, transform.position, Quaternion.identity) as GameObject;\n               \n                break;\n\n            case 1:\n                if (instantiateBackground != null)\n                {\n                    if (instantiateBackground.transform.position.x <= screenSize.x)\n                    {\n                        Destroy(instantiateBackground.gameObject);\n                    }\n                }\n                instantiateBackground = Instantiate(bgArray[bgNumber].gameObject, transform.position, Quaternion.identity) as GameObject;\n\n                break;\n\n            case 2:\n                if (instantiateBackground != null)\n                {\n                    if (instantiateBackground.transform.position.x <= screenSize.x)\n                    {\n                        Destroy(instantiateBackground.gameObject);\n                    }\n                }\n                instantiateBackground = Instantiate(bgArray[bgNumber].gameObject, transform.position, Quaternion.identity) as GameObject;\n\n                break;\n        }    \n```\n\nBestand: https://github.com/JoelLimes/EndlessRunner/blob/master/Assets/Scripts/BackgroundScrolling.cs\n\nDeze functie is niet DRY (Don't Repeat Yourself).\nJe herhaalt een zelfde type proces afhankelijk van een bepaalde variabele. Dit kan efficiënter."}}