Anyway, my problem: I have this script that checks if a specific (x,y) coordinate is inside a designated view.
/*
outside_view(x,y,view#)
function: tests if a coordinate is outside the given view
returns: yes (1) or no (0)
*/
if view_xview[argument2]<0 {view_xview[argument2]=0}
if view_xview[argument2]+view_wview[argument2]>room_width {view_xview[argument2]=room_width-view_hview[argument2]}
if view_yview[argument2]<0 {view_yview[argument2]=0}
if view_yview[argument2]+view_hview[argument2]>room_height {view_yview[argument2]=room_height-view_wview[argument2]}
if argument0<view_xview[argument2]
or argument0>view_xview[argument2]+view_wview[argument2]
or argument1<view_yview[argument2]
or argument1>view_yview[argument2]+view_hview[argument2]
{return true} else {return false}-In my current platformer game, I use this script to check which enemies are currently inside the view when the player targets available enemies.
-I also have a view running that follows the player object through the room.
Here is the code that runs through all objects and checks if it is visible (view is unobstructed) and inside the view:
while (run)
{
var halfhyp;
halfhyp=hypo(view_wview,view_hview)/2 //hypo() finds the hypotenuse of a width and a length
ins=instance_nearest_visible(view_xview+view_wview/2,view_yview+view_hview/2,obj_trox,obj_block,halfhyp,1)
//obj_trox is the enemy object, halfhyp is the range to look from the center of the view to scan for enemies
if !ins break;
with (ins)
{
if !outside_view(x,y,view_current)
{
ds_list_add(other.listx,x)
ds_list_add(other.listy,y)
instance_deactivate_object(id)
}
else
{
run=false
}
}
}And here's a picture of the problem. As you can see, it doesn't select all the available enemies inside the view, just within a certain distance. I'm not sure what is causing this..

[EDIT]
If I remove the !outside_view if statement, then it works great, except it can still find enemies outside the borders of the room if they are within the halfhyp range.
Thank you for any help you can give!
Edited by JishHD, 16 January 2010 - 08:32 PM.











