Page 1 sur 1

La TNT pour certains, se sera ça

Publié : mar. 22/févr./2011 22:58
par falsam

Code : Tout sélectionner

#filter=0.2       ; Filter parameter for the FPS-calculation
#UpdateFreq=100   ; How often to update the FPS-display
 
OpenWindow(0,400,300,320,240,"PureBasic")
Define w=WindowWidth(0), h=WindowHeight(0)
Define x, y, T, TOld, FloatingMedium.f, cnt
InitSprite()
OpenWindowedScreen(WindowID(0),0,0,w,h,1,0,0,#PB_Screen_NoSynchronization)
Repeat
  Event=WindowEvent()
  If Event=#PB_Event_CloseWindow
        End
  EndIf
  StartDrawing(ScreenOutput())
  For y=0 To h-1
    For x=0 To w-1
      If Random(1)
        Plot(x,y,#Black)
      Else
        Plot(x,y,#White)
      EndIf
    Next
  Next
  StopDrawing()
  FlipBuffers()
  cnt+1
  If cnt>=#UpdateFreq
    cnt =0
    TOld=T
    T=ElapsedMilliseconds()
    FloatingMedium*(1-#filter)+1000*#filter/(T-TOld)
    SetWindowTitle(0,"PureBasic: "+StrF(#UpdateFreq*FloatingMedium,2)+" FPS")
  EndIf
ForEver
Source : http://rosettacode.org/wiki/Image_noise#PureBasic
J'ai effectué une légère modification car le mode de sortie initiale étais pas génial.

Re: La TNT pour certains, se sera ça

Publié : mer. 23/févr./2011 0:46
par Ar-S
J'aime ! Image

64fps en 800x600

Re: La TNT pour certains, se sera ça

Publié : mer. 23/févr./2011 1:00
par Backup
pour info :

Code : Tout sélectionner

Define w=WindowWidth(0), h=WindowHeight(0)
Define x, y, T, TOld, FloatingMedium.f, cnt
Define ne sert pas a déclarer une variable , on est en basic, et dans ce language
on ne declare pas les variables

Define sert a déclarer un type , et dans ces 2 lignes , je n'en vois pas ! ;)

si tu ecris

Code : Tout sélectionner

define x, y, T, TOld
il te faut ecrire
define.l x, y, T, TOld
par exemple ;)

ça sert juste a éviter de préciser le type par la suite :)
mais a mon avis ça sert a rien, pour la lisibilité, il vaut mieux préciser le type
des qu'on le peux . :)

Re: La TNT pour certains, se sera ça

Publié : ven. 25/févr./2011 19:02
par SPH
RIEN compris

Re: La TNT pour certains, se sera ça

Publié : ven. 25/févr./2011 19:36
par Backup
SPH a écrit :RIEN compris
a partir d'ou ?