2011-11-24

Find the treasure

My girlfriend is making  treasure lists all the time in the etsy.com, art shop. I made a treasure hunting game... in the Python, as the third step learning it.
The aim is to get the treasure with no going on the same cells second time. There are three intuitive parts how this game is structured. The first part is - to generate the 2D grid and put the player and the treasure somewhere on it. And here comes the first "but" - as the placements are generated randomly, it is possible, that as game starts, it ends because of possibility that the start locations of the treasure and the player are identical. To avoid it, the coordinates has to be checked, and if they are identical, the player placement is regenerated and again checked in while loop.
The next part is - moves. As the grid is discrete with it`s borders, the player generated moves has to be verified - are they allowed. There are four possible movements - wasd - and each are verified.
And the last part is to verify does the player get the treasure or - are the coordinates not used before.

Check the source code here

Nav komentāru:

Komentāra publicēšana