ID:98708
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
RayCast(atom/movable, angle, rgba)

This would draw a single pixel line from the bottom left corner of the movable atom provided, based on the movable atom's location and pixel offsets, in the direction of the angle (in degrees), with an optional visible color set by the rgba. If the movable atom provided is dense, this would take into account and return a param string of the first atom "bumped", and the pixel coordinates where.
If possible, it could take into account actual pixels in icon_states, not colliding with empty space.

http://pagesperso-orange.fr/josh83/demoz/raycast2.jpg

EDIT: There should probably be a parameter for distance too
EDIT 2: And probably some way to clear it o.O or just a parameter for how long it should display
Isn't this possible with code?
Ripiz wrote:
Isn't this possible with code?

Sure, pretty much anything is. This would be incredibly complex and inefficient to write myself though.
Complex - not really
Inefficient - yes

This is probably the most inefficient way you can do this.
mob/proc/new_line(length, angle)
var
xStep = cos(angle)
yStep = sin(angle)
xNow = 0
yNow = 0
while(length > 1)
length--
var/obj/dot/d = new(loc)
d.pixel_x = xNow
d.pixel_y = yNow
xNow += xStep
yNow += yStep


Used this verb to test it:
verb
draw_sun()
for(var/angle = 0; angle < 360; angle += 15)
new_line(280, angle)

It takes 1 or 2 seconds on my system to appear, but that's probably rendering lag; 24 lines * 280 pixels = 6,720 objects. That's how it looks like: http://dl.dropbox.com/u/2637453/aasd.PNG
But DM is also an engine that a lot of beginners use, and who'd rather use a raycast proc.

Hell, we have procs for things like walking randomly and step size, I think a raycasting proc is long overdue.
To be honest I have trouble seeing how casting a ray would be used in a lot of games. Drawing lines I can see, but the bumping thing you described doesn't sound practical. (If anyone really, really needed to do the bumping, they could just create an obj with the desired bounds, give it a huge step_size, and then try to move it to the destination and let the built-in Move() code take over.)
That's pretty much what I do in this (and drawing lines is pretty easy too):
http://www.byond.com/forum/?post=1376026#comment6558383