The problem is when I try to draw the path. I originally started trying to draw a circle in code at each point but the circles would start deleting themselves in the middle of the path instead of the end as the rewind system over wrote the old entires. Say these "*" are the circles and this ">" is the player ship: ******* *******>. I would prefer that the circles delete themselves at the END of the path not the MIDDLE.
I decided to simplify the problem but now I cant get the code to delete the instance it pulls from a list, it just creates another marker and stores the values. I used show message() to check inside the "with" statement and it appears the "posdel" varible isn't caring it over to the instance_destroy() because it shows up in the show_message() as a 0.
See the code here:
if isrewinding=0
{
if time2<alarm2
{time2+=1}
else
{
pos+=1
if pos>max_pos
{pos=0}
//store and draw rewind lines
**This is the part where the code takes a previously stored value from the list and deletes it before creating and storing another value**
posdel=ds_list_find_value(marker,pos)
show_message(posdel)
with (posdel){instance_destroy()} **the instance is not destroyed!**
posnum=instance_create(x,y,obj_marker)
ds_list_insert(marker,pos,posnum)
//store cordinates
ds_list_insert(xrewind,pos,x)
ds_list_insert(yrewind,pos,y)
time2=0
}
}
if keyboard_check(ord("X"))
{
isrewinding=1
if ismoving=0
{
pos-=1
if pos=-1
{pos=max_pos}
if pos=(cur_pos+1)
{show_message("stop")}
xx=ds_list_find_value(xrewind,pos)
yy=ds_list_find_value(yrewind,pos)
move_towards_point(xx,yy,max_vspeed*2)
ismoving=1
}
if distance_to_point(xx,yy)<=5
{ismoving=0}
}
if keyboard_check_pressed(ord("X"))
{cur_pos=pos}
if keyboard_check_released(ord("X"))
{isrewinding=0;ismoving=0}I know...this method isn't very reasonable, that's why I'm asking for a better way to do this or fix what I have going. Preferably a new way.
edit: Actually i just realized i could create a path for this. I was browsing the manual and found some functions. Don't let this stop suggestions though!
edit2: Okay! I played with the new path functions I found and it made everything so much easier!
if isrewinding=0
{
path_add_point(path_rewind,object_index.x,object_index.y,100)
}
if keyboard_check_pressed(ord("X"))
{
isrewinding=1
path_reverse(path_rewind)
path_start(path_rewind,8,0,true)
}
if keyboard_check_released(ord("X"))
{
path_end()
path_reverse(path_rewind)
//path_position=0
isrewinding=0
}This code adds points the the objects path every step of the way (No hit in fps!) and when the player wants to rewind, the path is reversed!Now I have a new problem; after the player has reversed along the path and let go of the key, the code links the last point...oh here to hard to explain:
The recorded path:
http://img251.imageshack.us/content_round.php?page=done&l=img251/1522/screenshot000080.png
After rewind:
]http://img808.images...nshot000081.png
I can't seem to find a way to trim the path from the player's new position to the last point before the rewind. I was trying to combine both the list function and the paths but I haven't turned a result yet.
Edited by SHiLLySiT, 23 September 2010 - 05:10 AM.












