c# - rectangle list what is the syntax check for collision using intersect -


i how detect collision lists of rectangles.

    rectanlge player;     list<rectangle> blockhitbox =  new list<rectangle>(); 

i don't know proper syntax for.

blockhitbox.intersect<>(); 

the code should detect if rectangle hit boxes collide player hit box.

my goal make room small rectangles player cant pass through them need detect more 1 collision @ time ( corners)

you can use intersectswith method of rectangle object so:

var commonsize = new size(100, 100); var player = new rectangle(new point(0,0), commonsize); var blockhitbox = new list<rectangle> {     new rectangle(new point(0, 100), commonsize), // 1 not collide     new rectangle(new point(100, 0), commonsize), // 1 not collide     new rectangle(new point(0, 99), commonsize) // 1 collide };  bool collision = blockhitbox.any(item => item.intersectswith(player)); 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -