I'm going to focus on two items from that list today:
- A function to determine the player has 'selected' a gem and chosen to move it to a nearby cell. This would then swap the values of cell A and Cell B but only permit this swap if it aligned a 3 in a row combo or more.
- Mouse Clicking / Swapping Code
So I came up with another list of things to try and achieve these goals ...
- How do I capture mouse input?
- How do I tell I clicked the button?
- How do I tell where on the screen / or which button I just clicked?
I decided that was actually enough; I would separate the goals of 3 in a row detection and swapping game pieces for later. After all if I don't even know where I'm clicking how do I swap what is there?
So I decided to program a 'visual debugging tool' to help me meet those goals and came up with this:
![]() |
Click to Zoom In |
This sounded easier to me than trying to program actual bitmap based graphics, and worked very well for me.
So I took 2 days to figure out how to program the colorful grid, another 2 days to figure out how to detect the mouse position and when it was being clicked.
I added the white strip at the button to inform me the Mouse X/Y Position's coordinates and to tell me just to the left of that if I clicked on a button (where you see the text "Mouse Not Over Exit Button") which for some reason I felt was important at first so I could get out of my program if I couldn't see my mouse - a concern which quickly became clear was not really necessary but I never took it out.
In retrospect, about one month after this was done, I am extremely glad I took this approach. The "on-screen" debugging information has been critical in informing me what is going on with my game because the DarkBasicPro IDE's debugger seem's to be either insanely hard to figure out or perhaps it just does not function well.
I find that a little bit of a let down ; but having to program in all my own debug information has actually caused me to dive a lot deeper into my programming and this is exactly what I needed to be doing anyways so I do not regret it at all.
In the end this was a really motivational experience. It actually looks sort of vivid and exciting. It serves several functional purposes and as I moved forward I decided to continue using this program as a stepping point towards meeting my next goal which I'll write about next time.
No comments:
Post a Comment