Friday, February 28, 2020

Fish Game

Many years ago, probably about twelve to fifteen, I was working on building a custom e-commerce system using Adobe Coldfusion.  I was a young developer and so were the rest of the developers I worked with.  Non of us were really qualified to build such a complex system, but we didn't know that, so we did it anyway.  It ended up working fine for the customers we had.  I'm sure I would not be happy with most of the code if I saw it today.





As part of the project we needed to build in product sorting.  I came up with an idea that looked good, but in the end was not practical.  You could choose to sort the products by name, price etc. and when you chose an option the page would move the products around using javascript.  In the end this was all abandoned for a more practical version of sorting that reloaded the page.

However, from the code I had written for this I created a game.  I called it the Fish Game.  Basically there is a square game area and you can add food and fish.  The food is added at a random location and the fish always start in the upper left corner.  The fish move towards the food and when they get close enough they "eat" the food.

Each fish has a maximum speed and an amount of life energy.  The faster the fish moves the more energy it uses up.  When a fish eats food it gains energy.  When a fish collects enough energy it will spawn a new fish.  The new fish will be randomly a little slower or faster than the parent fish.  As time goes on the fish get faster and faster because the fastest ones always get the food.  Eventually they reach a point where they are using too much energy moving and they cannot get to the next piece of food before running out of energy.

Below is a link to the game if you want to try it out.

https://projects.mattdyer.us/fish/index.html

No comments:

Post a Comment

Coding

  I'm not sure where I heard this, and it wasn't worded this way, but it helps to think about coding this way. Basically, any progra...