Why does my game behave like this?