I am currently working on the Shmup LFD, as some of you may know.
In this game, I am having a bit of an issue. Specifically, the laser weapon is freezing the game for reasons I am completely unsure of.
As far as we can tell, the issues only occur on the laser's start up, and only when it doesn't hit an enemy. And even then only sometimes. All the relevent code (I believe...) is contained below. If anyone knows how to solve this problem it would be highly appreciated.
As far as I can tell, the lasers are triggering some kind of loop, which can either be infinite, last a few seconds, or never occur.
if extra=false
PCharge=approach(PCharge,210,1)
else
PCharge-=2
/*or keyboard_check_pressed(key_bomb)*/
if (keyboard_check(key_fire)=true) and instance_exists(obj_shotbluesourcefront)=false
instance_create(x,y-24,obj_shotbluesourcefront)
if keyboard_check_pressed(key_extra) and PCharge>=2 and bomb=false and keyboard_check(key_fire)
extra=true
if PCharge<2 or keyboard_check_released(key_extra) or bomb=true or keyboard_check(key_fire)=false
extra=false
if keyboard_check_pressed(key_bomb)
{
if bombs>=1
{
bomb=true
alarm[5]=50+15*floor(bombs)
bombs-=floor(bombs)
}
}
Information about object: obj_shotbluesourcefront
Sprite: spr_shotbluesource
Solid: false
Visible: true
Depth: -4
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
execute code:
if instance_number(obj_shotbluesourcefront)>1
instance_destroy()
a=instance_create(x,y-24,obj_shotbluefront)
a.targ=self.id
sound_loop(snd_fire)
sound_effect_set(snd_fire,se_reverb)
image_yscale=0.1
image_xscale=0.1
Destroy Event:
execute code:
sound_stop(snd_fire)
sound_effect_set(snd_fire,se_none)
Begin Step Event:
execute code:
if obj_player.extra=true
image_blend=c_purple
else if obj_player.bomb=true
image_blend=c_yellow
else
image_blend=c_white
if image_blend=c_yellow
{
image_xscale=approach(image_xscale,2.48,0.248)
image_yscale=approach(image_yscale,2.48,0.248)
}
else
{
image_xscale=approach(image_xscale,1.24,0.248)
image_yscale=approach(image_yscale,1.24,0.248)
}
End Step Event:
execute code:
x=obj_player.x
y=obj_player.y-24
if (keyboard_check_released(key_fire)=true) or obj_player.control=false or obj_player.visible=false //and obj_player.bomb=false
{
instance_destroy()
with obj_shotbluefront
instance_destroy()
}
Information about object: obj_shotbluefront
Sprite: spr_pshot3
Solid: false
Visible: true
Depth: -3
Persistent: false
Parent: obj_shottemplate
Mask: <same as sprite>
Create Event:
execute code:
image_xscale=0
targwidth=1
damage=1.5
Begin Step Event:
execute code:
if obj_player.bomb=true
image_blend=c_yellow
else if obj_player.extra=true
image_blend=c_purple
else
image_blend=c_white
if image_blend=c_white
damage=1.5
if image_blend=c_purple
damage=2
if image_blend=c_yellow
{
targwidth=2
damage=4
}
else targwidth=1
End Step Event:
execute code:
if instance_exists(targ)
{
x=targ.x
y=targ.y-targ.sprite_height/2
image_xscale=approach(image_xscale,targwidth,10)
maxdo=0
image_yscale=0.25
do
{
image_yscale+=0.25
maxdo+=1
}
until place_meeting(x,y+16,obj_enemy) or maxdo=36
if place_meeting(x,y,obj_enemy)
{
repeat(choose(1,2))
instance_create(x,y-sprite_height,obj_laserpart)
a=instance_create(x,y-sprite_height,obj_laserend)
a.image_index=image_index
a.image_xscale=image_xscale*1.5
a.image_yscale=image_xscale*1.5
}
}else
instance_destroy()
Collision Event with object obj_enemyshottemplate:
execute code:
if obj_player.bomb=true
with other
{
bombdeath=true
instance_destroy()
}
Collision Event with object obj_lasersource:
exit this event
Other Event: Outside Room:
exit this event