game estadistics functions

Started by Santiago, May 03, 2020, 17:30:34

Previous topic - Next topic

Santiago

Hi, this is my new way to save stadistics of any game.

Before, I used to save variables for statistics, if I destroyed a ship, then towards player_ship_Detroy = player_ship_destroy + 1

Now implement this new idea, where I can tell when I kill a ship.

new_est (a \ pivot, a \ flag, "player_ship_kill", 1)


it doesn't matter if that value or statistic exists or not, just create it.

then, when we want to know our score, we simply use the Get_est () function

where we request, the data we want.

It can be improved, but the idea solves the problem of having ::) loose variables to store all kinds of data.

It can also be used to save any type of data, start of the game, accumulated hours of play, average fps, memory, etc.


; PACK ESTADISTICAS

;! El pack de estadisticas es un nuevo pack, funciona como PACK COMBATE.
;! Uno envia a guardar datos, en bruto, el pack los almacena y luego los ordena y luego uno puede solicitar datos...
;! A futuro deberia pasar estas funciones a un include, para poder usarlos en otros programas.

Type est
Field tipo$
Field val#
Field flag
Field unidad
End Type


Function new_est(unidad,flag,tipo$,val#)

e.est = New est
e\tipo$ = tipo$
e\val = val
e\flag = flag
e\unidad = unidad

End Function

Function get_est#(unidad,tipo$)

For e.est = Each est
If e\tipo = tipo$ And e\unidad = unidad Then
valor = valor + e\val
End If
Next
Return valor

End Function

Function reset_est()

For e.est = Each est
Delete e
Next

End Function