Favorite Listed Projects, Part I

I absolutely enjoy the project that has been assigned to me, which is Audio Loop Station.  It was my 2nd choice, and I hope to discuss this in my next blog.  However, the first choice that I gravitated towards was Doodle Amazing.  I posted on the Project Discussion Group on the 3rd day after opening, that I was interested, and hoped that others would comment and want to form a group.  I indicated that I am not an experienced programmer, but Doodle Amazing was the project I wanted to do.  No one connected with me, and that is fine.

Since I do lack experience, I tried to get an early start on how I would implement Doodle Amazing.  The project allows someone to take a picture of a maze, and then based on the picture determine where the walls, open rolling areas, entrance hole, obstacle holes, and exit hole(s) are.  I imagined the steps that would need to be taken and how I would complete them.  I even started blogging about them to myself to ensure I did not forget anything and have to look up things twice.  An edited version follows…

Need a Pure Monochrome Picture

The first bridge to cross in my mind was to process a potentially dirty picture and find the walls.  We would need to work with black or white pixels only for the puzzle.  No grey or other colors should be allowed.

What if a picture is taken for uploading, but the picture is splotchy, or dirty?  We would need a way to filter out the slightly off-white pixels and set them to pure white.  We also need a way to set the almost-black pixels to pure black.  Hence – we need a totally monochrome image for processing where pixels are 1’s or 0’s.

Need a JPG / PNG to BMP API

First off, if the uploaded puzzle is a JPG or PNG, we need to convert it to a monochrome BMP.  The matrix format (row, column, and color) of a BMP will be very handy.  We can open the BMP file and READ in the BMP image into a matrix.  Also, the simple binary choice of color, black or white, will simplify our algorithms. 

Below is a monochrome image of a 4×2 pixel drawing.  Look at the Properties data.  This was done in Paint.exe.

We can READ the BMP image into a matrix by understanding BMP file format.  After Googling BMP file format spec, I found the following image.  It clearly shows that in the header, Bytes 11~14, tell me where the BMP image is found.  We would still have to examine a file to determine how they define black and white color pixels.

Rollable Areas for Ball

After the walls are determined in a minimal black-and-white grid, the grid should be expanded by about 1.5 * Diameter of a ball in all directions.  This will allow a ball to roll around the perimeter of a puzzle as needed.  An algorithm that determines the ball’s rollable area can then be determined.  The ball must stay within the rollable area regardless of where it goes.  This area can be found by providing a clearance equal to the ball’s radius around all walls (shown in black in the picture below).

By generating another matrix from the original maze matrix, the center of the ball can be forced to remain within the designated area.  As it rolls in one direction or another, it must be verified each time that the ball’s center is contained within the rollable area.

The game could also allow for a placement of an exit hole and mark it with a hollow hole.  If the ball’s center ever enters the exit hole, the game is won.

Speed and Trajectory of the Ball

Newton’s Law of Motion will be applied to the ball.  The ball will change direction and speed based on the tilt of the plane and it’s current velocity.  Initially, arrow buttons (→, ←, ↓, ↑) can be used to work out and verify the physics of rolling.  All answers must be worked out in pixel units.  Equations must be determined.

Walls will be Sticky, not Bouncy

When a ball hits a wall, it will not bounce off of it.  The ball will just roll in the direction of tilt along the wall and continue to follow Newton’s Laws to determine speed increases, or reversal of direction.

Graphics Engine

I did not figure out what graphics engine I would use.  Maybe a very simple one like Canvas (if that is even possible), or another one with sophisticated libraries.

That is about as far as I got in my pre-emptive preparation …

Leave a comment

Your email address will not be published. Required fields are marked *