Seguinte, no meu jogo Android terá um sistema de vidas que terá um tempo de 5 minutos regressivos para acrescentar +1 vida
Porém, eu quero que o relógio fique rodando com o jogo fechado, por exemplo, quando eu sair do jogo tava faltando 3 minutos para acrescentar +1 vida,
dai quando eu sai do jogo o tempo foi salvo num arquivo, dai por exemplo entrei no jogo 2 minutos depois e era pra estar em 1 minuto pra acrescentar vida
COMO FAZ ESSE SISTEMA???
>>Minha tentativa<<
>>>
CREATE:
if file_exists("time.txt")
{
_TimeToAdd=2 //minuto
_tts=59 //segundo
_ttm=60 //milesimo
_ff=file_text_open_read("time.txt")
L_a=file_text_read_real(_ff)
L_s=file_text_read_real(_ff)
L_m=file_text_read_real(_ff)
file_text_close(_ff)
TimeToAdd=_TimeToAdd-L_a //minuto
tts=_tts-L_s //segundo
ttm=_ttm-L_m //milesimo
}
else
{
TimeToAdd=2 //minuto
tts=59 //segundo
ttm=60 //milesimo
}
lives=3
STEP:
ttm-=1
if ttm<=0 {tts-=1 ttm=60}//60 fps
if tts<=0 {TimeToAdd-=1 tts=59}
if TimeToAdd<=0 {lives+=1 TimeToAdd=2} //Tempo para add vidas
GAME END:
//Ao sair do jogo
TT_a=TimeToAdd
TT_s=tts
TT_m=ttm
_ff=file_text_open_write("time.txt")
file_text_write_real(_ff,TT_a)
file_text_write_real(_ff,TT_s)
file_text_write_real(_ff,TT_m)
file_text_close(_ff)
DRAW:
draw_text(10,10,"Min: "+string(TimeToAdd))
draw_text(10,30,"Seg: "+string(tts))
draw_text(10,50,"Mil: "+string(ttm))
draw_text(10,90,"Lives: "+string(lives))
EXEMPLO DO ARQUIVO SALVO:
2 57 13
(minuto, segundo, milésimo)
AJUDA POR FAVOR SE PUDER FAZER O CÓDIGO QUE FUNCIONE!!