im trying to get an array of events in the maps screen for update purposes but for some reason its not working properly here the script by the way its VX so Graphics.width & Graphics.height are the screen sizes
def in_screen?
x,y = (@display_x/32),(@display_y/32)
w,h = x+(Graphics.width/32),y+(Graphics.height/32)
return @events.values.collect{|value| value if (x..w).include?(value.x) &&
(y..h).include?(value.y)}
end
Try this. The mistake you made is fixed, and it works properly if you're and/or events are moving.
def in_screen? # a display/real value is actually pixels * 4
x = @display_x + Graphics.width * 4 - 1
y = @display_y + Graphics.height * 4 - 1
return @events.values.find_all {|event| event.real_x.between?(@display_x, x) && event.real_y.between?(@display_y, y)}
end
Keep in mind that this doesn't take into account graphic size of the event so events with graphics bigger than 32x32 pixels won't be in the result even if the graphic is visible on the screen, but the event is outside of the screen.
that wasn't working right either this works good tho
def in_screen?
return @events.values.find_all {|event| event.screen_x.between?(0, Graphics.width) &&
event.screen_y.between?(0, Graphics.height)}
end
I probably messed up something trivial. In any case, you got it working. That's what counts.