Million rabbit Program

In the spring festival holiday,I write a million rabbit program because this year is rabbit year ,I came up the idea from a fast food restaurant there is hundreds of chickens on the tablecloth. I want to do like this:

firstly I want to make it all different and colorful, second

the rabbit will covered the whole screen,and last I made every rabbit covers the feet that was on the top of it.

Fastly I make the first version the good thing is there’s all different and very colorful,the bad news is there’s many space and it could only draw two rabbit at once .

After thinking I recognize it’s because of the ear’s is irregular pattern it’s to big,so I make a new one the ear’s is smaller and there is more kind of eye’s and mouth but all program have their flaw,sometime the rabbit can covered the last rabbit face,and it will randomly appear in the same place so if you want to make the rabbit to cover the whole screen than you need to wait it for a long time.

Well,I took a different tack the last program I made the rabbits randomly appear on the screen but this time I think about it if you want to cover the last one feet you need to make it stagger

Like this:

the first loop is for drawing the first row if it come to 240 pixel it will come down a little bit, and the x coordinate will reinitialize to -214 and it just right covers the last rabbit feet

As you can see on the first row there is a rabbit that has only body

So I made a latest program at first there is only body,but if you run the program very fast you will realize it wasn’t didn’t draw it because of the body is slower and it cover the five senses,so I add a waiting then the body will appear first at the screen and a second later five senses(every sense is correspond to a acter) begin to draw out.

After writing the program I recognize that there are two ways to program.The first way is multithreading every acter have a program and it have priority I time it and it’s very fast it only take up 5 second.

The second one is single thread every acter work together like a teem it take up 20 second it because the fist acter finish drawing the body and it send a message to the others and wait for them to finish drawing the other part of the rabbit

So I learn a thing is that when you write a program or something you need to first organize the structure and it’s multithreading or single thread.

And know I will show the result of all version of the million rabbit program.

The first version

the second version

million rabbit program3

million rabbit final edition

million rabbit final edition(plus)

Leave a comment