Woot Jim! Your mojo is very powerful! hehe. It works like a charm now! Thank you so much .. now I can solve some other (same) riddles in my codes. awesome! karma+
Here is the updated and finally working Sierpinski Carpet in FB!
' Sierpinski Carpet (http://lodev.org/cgtutor/sierpinski.html)
'
' ported to FreeBasic
' by dizphunkt in 2011
'-------------------------------------------------------------------------------
Option Static
Option Explicit
'-------------------------------------------------------------------------------
Const XRES = 729
Const YRES = 729
Const SCR_SIZE = XRES*YRES
Const FPS = 60 'PPS
'-------------------------------------------------------------------------------
'#DEFINE Ptc_win
#Include "tinyptc_ext.bi"
'-------------------------------------------------------------------------------
' OPEN THE SCREEN;
'-------------------------------------------------------------------------------
PTC_ALLOWCLOSE(0)
PTC_SETDIALOG(1,"Sierpinski Fractals"+CHR$(13)+"FULL SCREEN?",0,1)
if (ptc_open("Sierpinski Fractals", XRES, YRES) = 0) then end -1
Sleep 10
'-------------------------------------------------------------------------------
' VARIABLES DEFINITION
'-------------------------------------------------------------------------------
Dim Shared ScreenBuffer(0 To SCR_SIZE-1) As Integer
Dim Shared x, y as Integer
Dim Shared r, g, b As Integer
'Timei is TIMER var
Dim Shared As Double Timei ', SecondsPerFrame
'-------------------------------------------------------------------------------
' SUB DEFINITION
'-------------------------------------------------------------------------------
Declare Sub put_pixel(Buffer() as integer, ByVal x As Integer,_
ByVal y As Integer, ByVal col As Integer)
Declare Sub drawCarpet()
Declare Sub RunIntro()
Declare Sub SyncScr()
Declare Sub ClearScr()
'-------------------------------------------------------------------------------
' MAIN LOOP
'-------------------------------------------------------------------------------
While(GETASYNCKEYSTATE(VK_ESCAPE)<> -32767 and PTC_GETLEFTBUTTON=FALSE)
Timei = Timer()
RunIntro()
ScreenLock()
Ptc_Update @ScreenBuffer(0)
ScreenUnlock()
Erase ScreenBuffer
SyncScr()
Wend
'------------------------------------------------------------------------------
'The End
'------------------------------------------------------------------------------
ptc_close
end 0
Private Sub put_pixel(Buffer() as integer, ByVal x As Integer, ByVal y As Integer, ByVal col As Integer)
If x>0 And x<XRES-1 And y>0 And y<YRES-1 Then
Buffer(x + (y * XRES)) = col
End If
End Sub
Private Sub drawCarpet()
For x = 0 To XRES -1
For y = 0 To YRES -1
If Not ((x\1) Mod 3 = 1 And (y\1) Mod 3 = 1) And _
Not ((x\3) Mod 3 = 1 And (y\3) Mod 3 = 1) And _
Not ((x\9) Mod 3 = 1 And (y\9) Mod 3 = 1) And _
Not ((x\27) Mod 3 = 1 And (y\27) Mod 3 = 1) And _
Not ((x\81) Mod 3 = 1 And (y\81) Mod 3 = 1) And _
Not ((x\243) Mod 3 = 1 And (y\243) Mod 3 = 1) Then
put_pixel(ScreenBuffer(), x, y, RGB(255, 255, 255))
End If
Next
Next
End Sub
Private Sub RunIntro()
drawCarpet()
End Sub
Private Sub SyncScr()
Dim As Double SecondsPerFrame
'How long each frame should take to be rendered
SecondsPerFrame = 1 / FPS
Do: Sleep 1: Loop While Timer - Timei <= SecondsPerFrame
End Sub