Edited by CGPM, 21 June 2012 - 11:53 PM.
Collision with path
Posted 21 June 2012 - 11:34 PM
Posted 22 June 2012 - 05:50 AM
Are you simply drawing the path?
Is the path an object?
It is a complex path, right? Not just a line or two? Because if it's only a line or two, you could simply use collision_line(). If it's more complex, but not too large, you could use a repeat() with collision_point(), but that's not a very good solution.
Could you provide a little more information about your path?
Posted 22 June 2012 - 08:57 AM
Otherwise, you'll probably need to do the math to make a collision_arc function.
Posted 22 June 2012 - 12:54 PM
drawing the path into a surface
creating a sprite from that surface using sprite_create_from_surface()
assigning the sprite into an object (sprite_index = xxx)
collision checking with that instance.
Take note that this is the slowest method to use every step, but if you are creating the path only once then it might be the fastest method.
Posted 22 June 2012 - 01:08 PM
EDIT: Okay, that's what I'm doing.
Edited by CGPM, 23 June 2012 - 01:44 AM.
Posted 23 June 2012 - 01:16 PM
temp1=surface_create(room_width,room_height) surface_set_target(temp1) draw_clear_alpha(0,0) draw_set_color(c_yellow) draw_path(line1,0,0,true) temp2=sprite_create_from_surface(temp1,0,0,surface_get_width(temp1),surface_get_height(temp1),true,false,0,0) sprite_index=temp2 surface_free(temp1)
Edited by CGPM, 24 June 2012 - 07:34 PM.
Posted 23 June 2012 - 02:19 PM
Plus, you forgot to add draw_clear_alpha(0,0); after setting the drawing target to the surface.
Posted 24 June 2012 - 04:03 PM
EDIT: Wait, that means creating 5 objects per room, and collision checking with each. I can't do that.
Edited by CGPM, 24 June 2012 - 06:32 PM.
Posted 01 July 2012 - 05:20 PM
temp1=surface_create(room_width,room_height); surface_set_target(temp1); draw_clear_alpha(0,0); draw_set_color(c_yellow); draw_path(line1,0,0,true) ; surface_reset_target(); temp2=sprite_create_from_surface(temp1,0,0,surface_get_width(temp1),surface_get_height(temp1),0,false,0,0); sprite_index=temp2;surface_free(temp1);
You shouldn't destroy a surface you are using, it might cause some serious problems.
The reason it wouldn't work is because you set 'remove back' to true.
Remove back cannot recognize alpha channel and in most cases will remove all the image.
The code above should work.
You really should consider splitting the image into ,at least, 3 because most graphic cards won't support such large surface.
As for your collision problem, you should create a parent for those instances/objects and drop your collision code in collision event with that parent, (this way you will have a collision with 1 object instead of 3).
Another thing, do not use a while loop for such cases, while loop is dangerous as it might loop forever. Use a repeat loop or a for loop
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users