Pfap
Member
[SOLVED]Ok, so I have a really nice mp_grid system where I blocked off cells based on whether or not a wall tile was in them. I didn't really plan on what an issue enemies being able to see through walls would be though.
The collision_line() function only works with objects.
I'm trying to find a way to check each step whether there is a wall tile between the player and the enemy.
The below solution doesn't work and I feel doesn't come close. I'm way off track here...
Does anybody know of a solution or can point me in the direction of a tutorial or work around.
I think this may be a possible case where an "intermediate value theorem" type solution would work, but really don't want to have to bust out the calculus books. I'm not even sure how you would iterate through that... I'm thinking get the players coordinates and the enemies coordinates and check every position between for a tile. Or since I know the tiles cell position just get it's x and y and then get the players coordinates and enemies coordinates, and if the tiles coordinates are inbetween then I know theres a wall there....
TL;DR
Is there a way to get some collision_line() like functionality with tiles???
The collision_line() function only works with objects.
I'm trying to find a way to check each step whether there is a wall tile between the player and the enemy.
The below solution doesn't work and I feel doesn't come close. I'm way off track here...
Code:
var i,j;
for(i = 0; i < 512;){
for(j = 0; j < 288; j += 32;)
if tilemap_get_at_pixel(path_collision,i,j) != 0{//if it doesn't == 0 it means theres a tile there
//wall_block = true;
if point_in_rectangle(i, j, x -256, y - 10, x + 10, y + 10) == true{//if true then there is a wall there and we can't //see
//this checks to see if the given point is in the rectangle!!!!
//run checking code
show_debug_message("walls");
}
//set the below to varibales that change sign based off direction!!!!!!!!!!!!!
if point_in_rectangle(i, j, x -10, y - 10, x + 10, y + 10) == false{//if true then there is a wall there and we can't //see
//this checks to see if the given point is in the rectangle!!!!
//run checking code
show_debug_message("no walls");
}
}
i += 32;
//j += 32;
}
Does anybody know of a solution or can point me in the direction of a tutorial or work around.
I think this may be a possible case where an "intermediate value theorem" type solution would work, but really don't want to have to bust out the calculus books. I'm not even sure how you would iterate through that... I'm thinking get the players coordinates and the enemies coordinates and check every position between for a tile. Or since I know the tiles cell position just get it's x and y and then get the players coordinates and enemies coordinates, and if the tiles coordinates are inbetween then I know theres a wall there....
TL;DR
Is there a way to get some collision_line() like functionality with tiles???
Last edited: