|
Title: Very strange (And game freezing) bug. Post by: PureQuestion on October 06, 2010, 02:48:06 PM Okay. So, as some of you may know, my latest endeavor is a Shmup by the name of Last Fighter D. I am having the strangest of bugs.
Basically, I have a last type enemy weapon. For whatever reason, when it fades and erases, if the player is in contact with it, the game freezes. Would anyone be able to say why? Relevent Codes: Player Bullet Collision Code: Code: if death=true exit; if visible=true and other.canhurt=true and invincible=false and instance_exists(obj_bomb)=false { mask_index=spr_corecheck if place_meeting(x,y,other)=true { death=true alarm[2]=1 } else { dir=point_direction(x,y,other.x,other.y) instance_moving(x+cos(degtorad(dir))*12,y-sin(degtorad(dir))*12,obj_grazepart,dir,3) grazecount+=1 bombs=approach(bombs,3,0.01/max(ceil(bombs),1)) } mask_index=sprite_index } Laser Beam: Code: Information about object: obj_laserbeam Sprite: spr_laserbeam Solid: false Visible: true Depth: 0 Persistent: false Parent: obj_enemyshottemplate Mask: <same as sprite> Create Event: execute code: event_inherited() dist=0 dir=0 xnum=0 ynum=0 image_yscale=0.1 canhurt=false widen=false Begin Step Event: execute code: if image_yscale=1 canhurt=true else if image_yscale<0.9 canhurt=false End Step Event: execute code: if instance_exists(master)=false { instance_destroy() exit } image_angle=master.image_angle image_alpha=master.image_alpha image_yscale=master.image_yscale dir=image_angle ynum=(-(sin(degtorad(dir)))*dist) xnum=((cos(degtorad(dir)))*dist) x=master.x+xnum y=master.y+ynum Laser Source: Code: Information about object: obj_lasersource Sprite: spr_enemlasersource Solid: false Visible: true Depth: 0 Persistent: false Parent: obj_enemyshottemplate Mask: <same as sprite> Create Event: execute code: event_inherited() image_yscale=0.1 alarm[0]=15 widen=false alarmnum=15 Alarm Event for alarm 0: execute code: widen=true Alarm Event for alarm 1: execute code: instance_destroy() Alarm Event for alarm 2: execute code: alarm[1]=15 Step Event: execute code: if widen=true image_yscale=approach(image_yscale,1,0.09) if alarm[1]>0 { widen=false image_alpha-=image_alpha/alarm[1] image_yscale-=image_yscale/alarm[1] } if image_yscale=1 and alarm[2]=-1 alarm[2]=alarmnum End Step Event: execute code: if instance_exists(master)=false { instance_destroy() exit } ynumb2=(-(sin(degtorad(master.image_angle)))*xnumb) xnumb2=((cos(degtorad(master.image_angle)))*ynumb) ynum=(-(sin(degtorad(image_angle)))*dist) xnum=((cos(degtorad(image_angle)))*dist) x=master.x+xnum+xnumb2 y=master.y+ynum+xnumb2 For the source object, "master" is the firing enemy. For the beam, "master" is the relevent source. If any more information is required, feel free to ask for it. Title: Re: Very strange (And game freezing) bug. Post by: Desert Dog on October 07, 2010, 07:17:02 PM You call the script instance_moving without posting it. It's really hard to tell, but I suspect that that may be the trouble (I see no infinite loops at all in the code you have currently posted)
Also, I have no idea what obj_grazepart is. I'm going to start by working with the assumption that the freeze is an infinite loop... 99% of all freeze bugs are so. :p So are you calling a function [i.e. instance_moving(), but possibly approach()] recursively? Does that, or another function use a while/for loop? Title: Re: Very strange (And game freezing) bug. Post by: biino on October 08, 2010, 02:25:21 AM I didn't read the code provided :P
Yeah I agree, there's a good chance it's an infinite loop. Probably not due to a recursive call as you'd run out of stack space and crash (maybe... don't really know the language you're writing in but in C++ that's what'd happen). If you can, put a break point and step through where you think the freeze is occuring and it should become self evident quite quickly where the problem is. If you can't use break points use a print statement. If you can't use print statements, play a sound. If you can't... well you get the idea, just find a way to see what your code is doing at a strategic place. Title: Re: Very strange (And game freezing) bug. Post by: Desert Dog on October 08, 2010, 07:58:29 PM He's using GM, but I would agree with what you have to say. Just using show_message would be good for the test.
Title: Re: Very strange (And game freezing) bug. Post by: PureQuestion on October 09, 2010, 04:40:49 AM Instance_moving simply creates the object entered and applies a direction and speed to it.
obj_grazepart is simply a particle effect type thing. It doesn't really do anything. Either way, I sort of fixed this anyway. |