In my last post, I talked about some of the things about being an “Aspie” that can be depressing. In this one, I want to talk about one of the things that’s awesome about it– and that is the enjoyment I get out of doing something related to my “special interest.”
For example, the code will create this image…
… if you enter this data:
[[“kick”, 30, “S.Hauschka”], “pit”, 14, “G.Russell”, 34, 84, 7, “3:38”, [“FG”, 34, “good”, “J.Reed”]]
The image represents a kickoff from the Baltimore 30 to the Pittsburgh 14, returned to the Pittsburgh 34. Pittsburgh drives 50 yards in 7 plays to the Baltimore 16 using 3:38 on the game clock. Finally, Pittsburgh tries a 34-yard field goal, which is good.
All of the data comes from the list of numbers and names. (In case you’re wondering, the player names would show up in info boxes when you move your mouse pointer over one of the lines in the image; I didn’t demonstrate that in this example.)
The script needs to be able to calculate how many little images to connect based on the “beginning” and “end” yard line values the user inputs, and it needs to figure out which way the arrow should point based on whether the team that is driving is the home or away team.
One of the most complicated puzzles was figuring out how to tell the script when to use this piece:
It’s probably hard to tell what that is by itself, but it’s used whenever the line for a return overlaps the line for the drive and extends beyond it, like this:
Most of the time, this won’t happen, but it does happen sometimes, and the script needs to allow for it. The only input the script has to work with is the yard line the return began at (A), the yard line where the return ended and the drive began (B), and the yard line the drive ended at (C).
I had to make some sketches to figure it out, but I found that there were two situations that would require the use of this overlap piece:
1. If C is greater than or equal to A, -and- B is greater than C:
I don’t know if I have explained this in a way that makes sense, but it is so much fun to figure out puzzles like this. This is one reason why I think I might finally be on the right track in looking for a career– the things I am learning about in class bring me a lot of enjoyment rather than just being a source of stress.