1
C / C++ /C# / Re: C++ form events in microsoft visual c++ 2010 express
« on: January 25, 2012 »
Use the form designer to delete buttons etc. This deletes the auto-generated code too.
Kris
Kris
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
' Particle FX test
'
'
'-------------------------------------------------------------------------------
option Static
option Explicit
'-------------------------------------------------------------------------------
Const XRES = 800
Const YRES = 600
Const HALFXRES = XRES / 2
Const HALFYRES = YRES / 2
Const MYFPS = 60 'PPS
'-------------------------------------------------------------------------------
#Define Ptc_win
#Include "tinyptc_ext.bi"
'-------------------------------------------------------------------------------
' OPEN THE SCREEN;
'-------------------------------------------------------------------------------
'PTC_ALLOWCLOSE(0)
PTC_SETDIALOG(1,"Particles"+CHR$(13)+"FULL SCREEN?",0,1)
if (ptc_open("Particles", XRES, YRES) = 0) then end -1
'-------------------------------------------------------------------------------
' VARIABLES DEFINITION
'-------------------------------------------------------------------------------
dim shared ScreenBuffer(XRES*YRES) As UInteger
dim Shared as integer x, y
Dim Shared As Integer LP
Dim Shared As Integer Particles
Particles = 5000
DIM SHARED speedx (1 TO Particles) AS DOUBLE
DIM SHARED speedy (1 TO Particles) AS Double
Dim SHARED ptx (1 TO Particles) AS DOUBLE
DIM SHARED pty (1 TO Particles) AS Double
'Timei is TIMER var
Dim Shared Timei As Double
'-------------------------------------------------------------------------------
' SUBS DEFINITION
'-------------------------------------------------------------------------------
Declare Sub PutPixels( Buffer() as integer, ByVal x As Integer,_
ByVal y As Integer, ByVal col As Integer)
Declare Sub InitParticles()
Declare Sub Explode()
Declare Sub SyncScr()
Declare Sub MILLISECS()
'-------------------------------------------------------------------------------
' MAIN LOOP
'-------------------------------------------------------------------------------
DIM SHARED AS DOUBLE M ,oldtime,newtime
dim shared tst as string
dim shared as Integer ticks,t
ticks=0
oldtime=Timer
InitParticles() ' Init sys BEFORE mainloop !
While(GETASYNCKEYSTATE(VK_ESCAPE)<> -32767 and PTC_GETLEFTBUTTON=FALSE)
Timei = Timer()
Explode()
MILLISECS()
ScreenLock()
Ptc_Update @ScreenBuffer(0)
ScreenUnLock()
Erase ScreenBuffer
ticks=ticks+1
'SyncScr()
Wend
ptc_close
end 0
Sub InitParticles()
Dim As Double spd, w
For LP = 1 To Particles
w = Rnd(1)*359
spd = 1 + Rnd(1)
speedx(LP) = (cos(w) * spd)
speedy(LP) = (-Sin(w) * spd)
ptx(LP) = HALFXRES
pty(LP) = HALFYRES
Next
End Sub
Sub PutPixel( Buffer() as integer, ByVal x As Integer, ByVal y As Integer, ByVal col As UInteger)
If X>0 And X<XRES-1 And Y>0 And Y<YRES-1 Then
Buffer(Y * XRES + X) = col
End If
End Sub
Sub Explode()
For LP = 1 To Particles
ptx(LP) += speedx(LP) 'remember to update particle states!
pty(LP) += speedy(LP)
PutPixel(ScreenBuffer(), ptx(LP), pty(LP), RGB(255,255,255))
Next
End Sub
' ---------------------------------------------------------
' FPS counter taken from Shockwave's code
' --------------------------------------------------------
SUB Millisecs()
t=timer
if t-oldtime >=1 then
newtime = ticks
ticks=0
oldtime=timer
TST = str( (newtime) )
TST = "FPS "+TST
print tst
end if
end Sub
Sub SyncScr()
Dim As Double SecondsPerFrame
'How long each frame should take to be rendered
SecondsPerFrame = 1 / MYFPS
Print "FPS"
Do: Sleep 1: Loop While Timer - Timei <= SecondsPerFrame
End Sub