Show Posts

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.


Messages - krisp

Pages: [1]
1
Use the form designer to delete buttons etc. This deletes the auto-generated code too.

Kris 

2
Hi! Neriakx - I've looked at your code and found some mistakes. I assume that you've figured it out by now, as this thread is a little old. But maybe others will have some benefit from this debug.

1. Initialise the particles _before_ the main loop, not INSIDE!
2. This is quite wrong:
     PutPixel(ScreenBuffer(), (ptx(LP) + HALFXRES)  * speedx(LP), (pty(LP) + HALFYRES ) * speedy(LP), RGB(255,255,255)),
so I've changed that too.

Code: [Select]
'   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

I haven't cleaned anything up (unused vars etc.) in your code.

Kris.


3
General chat / Re: The Welcoming Committee
« on: January 11, 2012 »

Thank you all for the warm welcome, guys (and girls - perhaps?) - much appreciated!

4
General chat / Re: The Welcoming Committee
« on: January 09, 2012 »
Hi there - Nice forum!

I started out as a BASIC program on the VIC-20 (+ 16kb expansion[!]) in '82/'83, then got converted to 8502 asm and booted up on the c128 via its built-in ML monitor. I soon after became a mc68000 program on the Amiga 1000. It was on the A1000 I had my first illness - a bootblock virus (write protect those floppies, please). I felt invincible on the A1200 w/mc68030 + 8 mb and life was good. Alas, one day it was all over. As it hurts me too much to tell you all the long and sad story, I will only say one thing here. i80x86.

Today I feel a little bit better, even though this dual core gives me a split personality.

kris.

Pages: [1]