Global mx#,my#,mhl,mhc,mhr,mdc,mdl,mdr,mxs#,mys#,mzs#,mun$,accion$,mx1,my1,mzsv#,mlcv#,mrcv#,mouse_over$,last_mouse_over$,l_mdlFunction update_mouse() log_file "update_mouse" l_mdl = mdl mhl = MouseHit(1) ;Or JoyHit(1,0) mhr = MouseHit(2) ;Or JoyHit(2,0) mhc = MouseHit(3) ;Or JoyHit(1,0) mx# = MouseX() my# = MouseY() mz# = MouseZ() mxs# = MouseXSpeed() mys# = MouseYSpeed() mzs# = MouseZSpeed() mdl = MouseDown(1) ;Or JoyDown(1,0) mdr = MouseDown(2) ;Or JoyDown(2,0) mdc = MouseDown(3) ;Or KeyDown(56); Or JoyDown(3,0) ;pick = CameraPick(cam,mx,my) If g_modo_girar_vista =1 Then ;mdr = 1 Or mdr = 1 And modo = 0 Then MoveMouse gancho*.5,galto*.5 End If End Function
Function pos(origen,destino) log_file "pos " + origen + " - " + destino If origen = 0 Then DebugLog "aqui hay una falla, origen = 0" falla = 1 End If If destino = 0 Then DebugLog "aqui hay una falla, destino = 0" falla = 1 End If If falla = 1 Then DebugLog (" > ERROR - origen: "+origen + " destino: "+destino ) ;If origen <> 0 Then If destino <> 0 Then DebugLog (" > Destino: "+EntityName(destino) + " clase: " + EntityClass(destino)) If origen <> 0 DebugLog (" > Origen: "+EntityName(origen)+ " clase: " + EntityClass(origen) ) ;End If End If If destino <> 0 And origen <> 0 Then PositionEntity origen,EntityX(destino,1),EntityY(destino,1),EntityZ(destino,1),1 End If End FunctionFunction rot(origen,destino) log_file "rot " + origen + " - " + destino RotateEntity origen,EntityPitch(destino,1),EntityYaw(destino,1),EntityRoll(destino,1),1 End Function
;! DEBUGGlobal timerGlobal timers#[30] ;RELOJES QUE MIDEN LOS TIEMPOS DENTRO DEL PROGRAMAGlobal timers_p#[30]Function set_timers(timer_n,stage) log_file "set_timers " + timer_n If stage = 0 Then timers[timer_n] = mimillisecs() End If If stage = 1 Then timers[timer_n] =mimillisecs() - timers[timer_n] ;If Int(Rnd(1,10)) = 3 Then timers_p[timer_n] = (timers_p[timer_n] + timers[timer_n])*.5 ;End If ; If timers[timer_n] > 50 Then; Log = ("TIMER " + timer_n + " Extreme relay : "+ timers[timer_n] + " at " + mimillisecs()); End If End If End FunctionFunction show_timers() log_file "show_timers" setblend 2 setcolor 255,255,255 setalpha 1 x=10 y=80 drawtext "HWTexUnits Availables :" + HWTexUnits() ,x,y : y = y + 15 drawtext "Triangles Rendered : "+TrisRendered() ,x,y : y = y + 15 drawtext "Your available video memory is: " + AvailVidMem()/(1024*1024) + " mb" ,x,y : y = y + 15 If g_show_timers = 1 Then x=10 y=300;galto-(15*13) If Int(timers_p[11]) <> 0 Then ttotal = (1000)/Int(timers_p[11]) Else info "error 226 timer_p[11] = 0" End If setColor 255,0,0 If ttotal > 50 Then setcolor 255,155,0 If ttotal > 60 Then setcolor 0,255,0 setblend 1 setscale 1,1 drawrect x+180,y-5-(15*1),ttotal,10 setcolor 255,255,0 drawrect x+180+ttotal,y-5-(15*1),t_fix*(fps_recomended-fps),10 setcolor 0,0,0 drawrect x+178,y-5-(15*1),62,10,0 setColor 255,255,255 drawText "TOTAL FPS x TIME :" + ttotal , x,y-15*1, 0,1 drawText "T00 RENDER :" + Int(timers_p[0]), x,y+15*0, 0,1 drawText "T01 FLIP :" + Int(timers_p[1]),x,y+15*1,0,1 drawText "T02 FASTIMG :" + Int(timers_p[2]),x,y+15*2,0,1 ; no funciona? drawText "T03 3D GAME :" + Int(timers_p[3]),x,y+15*3,0,1 drawText "T04 UPDATEW.:" + Int(timers_p[4]),x,y+15*4,0,1 drawText "T05 GMode11 :" + Int(timers_p[5]),x,y+15*5,0,1 drawText "T06 UdtW.11 :" + Int(timers_p[6]),x,y+15*6, 0,1 drawText "T07 MENU2D :" + Int(timers_p[7]),x,y+15*7, 0,1 drawText "T08 LINES2D :" + Int(timers_p[8]),x,y+15*8, 0,1 drawText "T09 SPRITES :" + Int(timers_p[9]),x,y+15*9,0,1 drawText "T10 SHADOWS :" + Int(timers_p[10]),x,y+15*10,0,1 drawText "T11 LOOP :" + Int(timers_p[11]),x,y+15*11,0,1 drawText "T12 3DWater :" + Int(timers_p[12]),x,y+15*12,0,1 drawText "T13 gameplay:" + Int(timers_p[13]),x,y+15*13,0,1 drawText "T14 temp 1 :" + Int(timers_p[14]),x,y+15*14,0,1 drawText "T15 temp 2 :" + Int(timers_p[15]),x,y+15*15,0,1 drawText "T16 update_entorno :" + Int(timers_p[16]),x,y+15*16,0,1 drawText "T17 update_objetos :" + Int(timers_p[17]),x,y+15*17,0,1 drawText "T18 update_barcos :" + Int(timers_p[18]),x,y+15*18,0,1 drawText "T19 update_barco_ia :" + Int(timers_p[19]),x,y+15*19,0,1 drawText "T20 update_pajaros :" + Int(timers_p[20]),x,y+15*20,0,1 drawText "T21 update_cabos :" + Int(timers_p[21]),x,y+15*21,0,1 drawText "T22 update_marinero :" + Int(timers_p[22]),x,y+15*22,0,1 drawText "T23 Menu ventanas " + Int(timers_p[23]),x,y+15*23,0,1 ;16 update_entorno ;17 update_objetos ;18 update_barcos ;19 update_barco_ia ;20 update_pajaros ;21 update_cabos ;22 update_marinero x=x+180 For i = 0 To 23 setColor 255,0,0 If timers_p[i] < 30 Then setcolor 255,150,0 If timers_p[i] < 20 Then setcolor 0,0,255 If timers_p[i] < 10 Then setcolor 0,255,0 setscale 1,1 setblend 0 setalpha 0 If i <> 11 Then drawrect x,y-5+(15*i),timers_p[i]*10,10 setblend 2 Next setblend 3 setalpha .05 setcolor 255,255,255 drawimageex efecto1,0,0 End If End Function
;! FUNCTIONES QUE SOLUCIONAL EL PROBLEMA DE LOS FPS BAJOS O ALTOSFunction turn# (entidad,x#,y#,z#,global2) log_file "turn " + entidad If entidad = 0 Then info "Error grave, se esta intentando manipular una entidad que no existe" Stop Else TurnEntity entidad,x#*t_fix,y#*t_fix,z#*t_fix,global2 End If End FunctionFunction rotar# (entidad,x#,y#,z#,global2) log_file "rotar " + entidad If entidad = 0 Then info "Error grave, se esta intentando manipular una entidad que no existe" Stop Else RotateEntity entidad,x#*t_fix,y#*t_fix,z#*t_fix,global2 End If End FunctionFunction move# (entidad,x#,y#,z#) log_file "move " + entidad If entidad = 0 Then info "Error grave, se esta intentando manipular una entidad que no existe" Stop Else MoveEntity entidad,x#*t_fix,y#*t_fix,z#*t_fix End If End FunctionFunction trans# (entidad,x#,y#,z#,global2) log_file "trans " + entidad If entidad = 0 Then info "Error grave, se esta intentando manipular una entidad que no existe" Stop Else TranslateEntity entidad,x#*t_fix,y#*t_fix,z#*t_fix,global2 End If End FunctionFunction mimillisecs() Return ( MilliSecs() And $7FFFFFFF)End Function
i call like this.log_file$("function move " + entity)Function log_file$(texto$) If g_log_file = 1 Then If log_file_archive = 0 Then If g_log_file = 1 Then If FileType("datos\log.txt") = 1 Then CopyFile "datos\log.txt","datos\log_old_"+CurrentDate()+".txt" If FileType("datos\log.txt") = 1 Then DeleteFile("datos\log.txt") End If If FileType("datos\log.txt") = 1 Then log_file_archive = OpenFile("datos\log.txt") SeekFile (log_file_archive,FileSize("datos\log.txt")) Else log_file_archive = WriteFile("datos\log.txt") End If End If log_time = MilliSecs() - last_log_millisec If fps > 0 Then f$ = " fps: "+fps Else f$ = "" WriteLine log_file_archive,frames +"|"+ f$ + " " + log_time + " -> " +texto$ log_lines = log_lines + 1 If log_lines > 1024*1024 Then WriteLine log_file_archive,"Cerrando el archivo por que tiene muchas lineas" CloseFile log_file_archive If FileType("datos\log.txt") = 1 Then CopyFile "datos\log.txt","datos\log_old_"+CurrentDate()+".txt" If FileType("datos\log.txt") = 1 Then DeleteFile("datos\log.txt") log_file_archive = 0 log_lines = 0 Else If texto$ = "end log file" Then CloseFile log_file_archive End If last_log_millisec = mimillisecs() Else If log_file_archivo <> 0 Then WriteLine log_file_archive,"Cerrando el archivo al desactivar el log" CloseFile log_file_archivo End If End If End Function
that's is the idea!, if you improve share here!.regards!!!
Function FILE_LOG( txt$, FileStart = False ) Local Filename$ = "Data\Log.txt" Local File If FileType(Filename) = 1 Then If FileStart DeleteFile Filename File = WriteFile(Filename) Else File = OpenFile(Filename) SeekFile (File,FileSize(Filename)) EndIf Else File = WriteFile(Filename) End If WriteLine File, txt CloseFile File End Function