Log in

No account? Create an account
09 November 2013 @ 01:46 pm
Programming Class Week 4  
I don't have as much to report this week. We learned how to use lists and tuples (etymology if, like me, you had no idea what that was), and programmed Pong.

Well, more like pseudo-Pong. See, our implementation doesn't keep track of the ball bouncing off the sides or corners of the paddle by using a "gutter" that's the same width as the paddle. That allows us to avoid having to do complicated math to figure out what direction the ball would have to bounce if it hit the edge, and by going all elementary physics and treating the ball as a spherical object in a vacuum--which, well, it is--we can just reverse the appropriate components of the velocity. It's pretty simplistic, though it was good practice for proper ordering of if-statements and a reminder that copying and pasting code can often be more trouble than just re-writing the same code. I spent ~15 minutes trying to figure out why the paddles were working in one direction but going berzerk in the other until I realized that when I copied the movement code from one paddle to the other, I didn't change all the variables, so the right paddle controlled itself and the left paddle controlled itself and the right paddle. Oops.

If you want to play an awesome version of Pong, don't play my version. Play Plasma Pong.

The overuse of global variables continues, and seems to be completely due to lazy coding for the GUI they're using. As near as I can tell, most UI elements that take player input cannot accept any input other than from the UI itself and can't call other functions, which makes passing variables around among functions difficult at best. It's something I'll have to keep in mind when I try to become a programmer, motherfucker.
Current Mood: refreshedrefreshed
Current Music: Podcastle podcast