# Draw_sight

4 replies to this topic

### #1 _202389

_202389

GMC Member

• New Member
• 16 posts

Posted 06 February 2012 - 03:47 PM

its simple sigth drawing. very useful but not very fast when you decrease distance between points.

draw_sight(x,y,sight view,angle, distance between points,sight range,color,outline width,alpha)

```for(i=0 i<argument2 i+=argument4)
{var uzaklik,uzaklik2;
uzaklik=0
uzaklik2=0
do{uzaklik+=2    }
until(collision_line(x,y,x+lengthdir_x(uzaklik,i-argument2/2+argument3),y+lengthdir_y(uzaklik,i-argument2/2+argument3),argument6,1,0) or uzaklik>argument5)
do{uzaklik2+=2    }
until(collision_line(x,y,x+lengthdir_x(uzaklik2,i-(argument2/2-argument4)+argument3),y+lengthdir_y(uzaklik2,i-(argument2/2-argument4)+argument3),argument6,1,0) or uzaklik2>argument5)

draw_line_width_color(x+lengthdir_x(min(argument5,uzaklik-3),i-argument2/2+argument3),y+lengthdir_y(min(argument5,uzaklik-3),i-argument2/2+argument3),x+lengthdir_x(min(argument5,uzaklik2-3),i-(argument2/2-argument4)+argument3),y+lengthdir_y(min(argument5,uzaklik2-3),i-(argument2/2-argument4)+argument3),argument8,argument7,argument7)
draw_set_alpha(argument9)
draw_triangle_color(x,y,x+lengthdir_x(min(argument5,uzaklik),i-argument2/2+argument3),y+lengthdir_y(min(argument5,uzaklik),i-argument2/2+argument3),x+lengthdir_x(min(argument5,uzaklik2),i-(argument2/2-argument4)+argument3),y+lengthdir_y(min(argument5,uzaklik2),i-(argument2/2-argument4)+argument3),argument7,argument7,argument7,0)
draw_set_alpha(1)
if i=0
{draw_line_width_color(x,y,x+lengthdir_x(uzaklik-3,-argument2/2+argument3),y+lengthdir_y(uzaklik-3,-argument2/2+argument3),argument8,argument7,argument7)
}
if i=argument2-argument4
{
draw_line_width_color(x,y,x+lengthdir_x(uzaklik2-3,+argument2/2+argument3),y+lengthdir_y(uzaklik2-3,+argument2/2+argument3),argument8,argument7,argument7) }
}
```

example
draw_sight(x,y,80,direction,5,150,obj_wall,c_red,0,0.8)

---

http://speedy.sh/8b73e/draw-sight.gmk
• 2

### #2 Anzkji

Anzkji

Seer of Space

• GMC Member
• 443 posts
• Version:GM8

Posted 06 February 2012 - 03:54 PM

Wow, this looks awesome! This is a really wonderful engine that you have made - combined with collision_line() and point_distance(), you could create some awesome AI. I hope to see some games with this in it. (Maybe from me, even) Thank you taking the time to make this.
• 0

### #3 wnsrn3436

wnsrn3436

GMC Member

• GMC Member
• 133 posts
• Version:GM8

Posted 23 February 2012 - 02:27 PM

Oh, my God. This seems to be pretty good.
Only, Speed ​​only a little bad.

Edited by wnsrn3436, 23 February 2012 - 02:29 PM.

• 0

### #4 Pigdug Gaming

Pigdug Gaming

GMC Member

• GMC Member
• 52 posts
• Version:GM8

Posted 26 February 2012 - 06:50 PM

this is pretty cool but it runs really slow
• 0

### #5 iam1me

iam1me

GMC Member

• GMC Member
• 380 posts
• Version:GM8

Posted 26 February 2012 - 10:37 PM

I think you could get this to run faster if you started off by drawing the entire range (on to a surface) and then grab all of the instances in the area and subtract their "shadows." You could have a fast version that runs off of the bounding boxes and a slower one that is pixel precise.

Cool idea though

Edited by iam1me, 26 February 2012 - 10:37 PM.

• 0

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users