First, note that
ItDoesntWorkIsUseless(←click). You need to
TellTheDetails(←click).
Aside from that, two things jump out at me:
1. The one that works has different code than the one that doesn't. In the working one, you always repaint, and then conditionally update y. In the one that doesn't work, you only repaint conditionally, and you do so after updating y.
2. I don't see you ever calling that walls() method, so from the code you posted, there's no way the second if will ever even be executed, so "working" or "not working" is not even an issue.