In this section of code the big dots are being created exclusivly in the C# code, first a Rect is created so that we can check to see if Pacman intercepts the dots, the width and fill of the big dot is then configured and finally the positoning is specified using the Ellipse.setValue() method.
These rects and dots have then been added to an array so that the rect in the rect array corresponds to the ellipse in the bigdots array so that when an intersect happens we can get rid of the dots.
The bigdots array is then added to the canvas, so that they can be seen on screen.
Straight away you can see that this method reduces the ammount of code needed, and creates 158 dots compared to the 4 big dots.
The code loops through each of the ellipses on the canvas using canvasname.children.oftype
A small section of code is then also generated so that Pacman can eat up the dots, this uses a very similar approach to checking the boundarys by creating a rect in the direction pacman is moving and then see if it intersects the dot.One the dots have been intersepted the visibility of the ellipse is set to collapsed so that it cant be seen anymore. And the player score is then incremented and displayed.
A problem that did occour is that originally when the ellipse disapeared the rect was still there in the background and would rack up the score each time pacman intersected with the rect, and high scores of a couple of thousand were attainable in a second.
This was solved by creating a new Rect in place of the one which had just been intersected. Im sure there must be a nicer way of doing this, however there dosnt seem to be a destructor for Rect, ~Rect() doestnt want to work for me.
The current version of the game can be found at the bottom of the main page of this blog. Go test it out and give some feed back.