Essentially the way I have map generation setup is the game will generate a series of random numbers, and based on those numbers It will turn certain holes or monsters on or off. So lets say the first number it generates is 14.
It will then go through a series of if statements to pick which hole tile to turn on, and since the number is less than 20 it will turn on a hole at 205, 105.
So in order to get the player to not be able to walk through the hole, I had a collision detection code setup like this
Code: Select all
private void btnDown_Click(object sender, EventArgs e)
{
if (HeroLocation.Y != 455)
{
if (HeroLocation.Y == 55 & HeroLocation.X == 205 & HoleX205Y105.Visible == true)
{
}
else
{
HeroLocation.Y = HeroLocation.Y + 50;
Hero.Location = new Point(HeroLocation.X, HeroLocation.Y);
}
}
That code worked perfectly until I added another if statement to check for a different hole.
Code: Select all
private void btnDown_Click(object sender, EventArgs e)
{
if (HeroLocation.Y != 455)
{
if (HeroLocation.Y == 55 & HeroLocation.X == 205 & HoleX205Y105.Visible == true)
{
}
if(HoleX505Y205.Visible == true & HeroLocation.X == 505 & HeroLocation.Y == 155)
{
}
else
{
HeroLocation.Y = HeroLocation.Y + 50;
Hero.Location = new Point(HeroLocation.X, HeroLocation.Y);
}
}
This is a screenshot of the game thus far if it helps
