Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Farm : Drawable
- {
- int size_x;
- int size_y;
- Ground[,] grounds;
- public Farm(int size_x, int size_y)
- :base(drawable_type.farm)
- {
- int i,j ;
- i = 0;
- j = 0;
- Random rand;
- rand = new Random();
- this.size_y=size_y;
- this.size_x=size_x;
- this.grounds=new myFarm.Ground[size_x,size_y];
- while (j<=this.size_y-1)
- {
- while (i <=this.size_x-1)
- {
- if(rand.Next(2)==0)
- this.grounds[i, j] = new Ground(new Vector2(i, j), groundType.grass, drawable_type.grass);
- else
- this.grounds[i,j] = new Ground(new Vector2(i,j),groundType.dirt,drawable_type.dirt);
- i++;
- }
- j++;
- i=0;
- }
- }
- public void addAnimal()
- {
- int x;
- int y;
- Random rand = new Random();
- x = rand.Next(size_x);
- y = rand.Next(size_y);
- if (!this.grounds[x, y].occupied)
- {
- this.grounds[x, y].occupied = true;
- if (rand.Next(1) == 1)
- this.grounds[x, y].containing = new Pony(x, y);
- else
- this.grounds[x, y].containing = new Hen(x, y);
- }
- }
- public void display(SpriteBatch sb)
- {
- int i = 0;
- int j = 0;
- while (j <= this.size_y - 1 )
- {
- while (i <= this.size_x - 1)
- {
- if (this.grounds[i, j].occupied)
- {
- this.grounds[i, j].containing.Draw(sb);
- }
- this.grounds[i, j].Draw(sb);
- i++;
- }
- j++;
- i = 0;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment