A click it the center = 4 balls


Maybe it would be a good idea to have a short form list of changes from screen to screen. So, here it goes (most of this assumes you're looking at the base JavaScript code):
1 - Deleted all of the commented out code (there was a lot left over from the refactoring) I never delete raw code until after I'm confident the refactoring works. (I use Notepad++ wiht JLint, so if it's a swath of green, it goes.) The only issue with this was that I got too 'greedy' and hit a closing }, so until I found and correct that, the program wouldn't work.
2 - Next up, I wanted to add multiple BouncingBalls (the red balls), so:
     A - First step, refactor BB as an array
     B - add var BBnumber = 4; so I can increase or decrease the number of balls at will in the future
     C - refactor the createBB() function for a variable amount based on BBnumber (any added balls would be stationary at this point)
     D - since VR is the directional component of BB, I need to turn VR into an array (VR[1] for all to start). And sure enough, I missed a 'VR' when I was going through the code, didn't change it to VR[1], and so, introduced a bug.
     E - VR was initialized with a vector ray of (0,-1). All the VR[]'s will need to be initialized, so this initialization is brought into BBcreate method
     F - I put a for 'eachBB' wrapper inside the onFrame function, so it's called for eachBB. It's choppy, and the other BB's don't move, but I got something, which was more than I honestly expected at this step in the process.
     G - And from here down, there are maybe three steps all mixed into one.
         1 - I refactored the onMouseDown() function -- the order of calls inside this turned out to be important
         2 - I removed a placement assignment for the BB[]'s that I had placed in the onMouseDown() function (don't know why it was there. Turns out I didn't need it.)
         3 - Really, I should have paid more attention to what I was doing, so I could recreate it, but fact is I'm sort of lucky I even did it. This sort of refactoring is at the edge of my ability at this time.

Anyhow, I think that's about it for this page.
If you look at the wall hit count, it goes up by 4 at each impact. (There are 4 BB[]'s at this point.) And perhaps more importantly, if one onMouseDown() -- i.e. clicks -- inside the center circle, the 4 BB[]'s path's separate.

So, for today, mission complete.
And I don't know about you, but I think it's time to add a little more interactivity to this project. And perhaps time to start finding a way to bring it to a close.


Previous      Brett Code Index    Next in Series

Octogon Wars
Copyright © 2013 Brett Paufler