Based on https://github.com/polarkac/JavaGameTutorial.