1
0
forked from s425077/PotatoPlan
PotatoPlan/Game1/Sources/Objects/House.cs

51 lines
1.2 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
class House
{
private Rectangle housePos;
private Vector2 pos;
private Random r = new Random();
2020-05-03 13:05:05 +02:00
//initializes the house
public void init(int tileSize, int Spacing)
{
int x = r.Next(0, 8);
int y = r.Next(0, 8);
pos = new Vector2(x, y);
housePos = new Rectangle((x * tileSize + Spacing), y * (tileSize + Spacing), tileSize, tileSize);
}
2020-05-03 13:05:05 +02:00
//Moves the house if it is currently out of matrix.
public void updateRectangle(Vector2 Size, int tileSize, int Spacing)
{
if (pos.X + 1 > Size.X)
{
pos = new Vector2(pos.X - 1, pos.Y);
}
if (pos.Y + 1 > Size.Y)
{
pos = new Vector2(pos.X, pos.Y - 1);
}
2020-05-03 13:05:05 +02:00
housePos = new Rectangle((int)pos.X * (tileSize + Spacing), (int)pos.Y * (tileSize + Spacing), tileSize, tileSize);
}
2020-05-03 13:05:05 +02:00
public Rectangle GetRectangle()
{
return housePos;
}
public Vector2 getVector()
{
return new Vector2(housePos.X, housePos.Y);
}
}