G
Guest User
Guest
recently I wrote a code for reloading the machine for my game Ghost team in gml:
in create obj_player: reload=0 time_reload=0 bullets=32 ammo=96 patrons=0
when you hold down the R key: if reload=0 reload=1
in step:
if reload=1{time_reload+=1 if time_reload=90{patrons=32-bullets if ammo<patrons{patrons=ammo ammo=0}
if ammo>=patrons ammo-=patrons bullets+=patrons time_reload=0reload=0patrons=0}
if time_reload=1 audio_play_sound(sound_reload,0,0)}
in create obj_player: reload=0 time_reload=0 bullets=32 ammo=96 patrons=0
when you hold down the R key: if reload=0 reload=1
in step:
if reload=1{time_reload+=1 if time_reload=90{patrons=32-bullets if ammo<patrons{patrons=ammo ammo=0}
if ammo>=patrons ammo-=patrons bullets+=patrons time_reload=0reload=0patrons=0}
if time_reload=1 audio_play_sound(sound_reload,0,0)}