A little experiment, it can become hypnotic after a while.
Play with the variables if you want
It's not big nor special, but maybe someone can learn something from it :)
[pbcode]
; PROJECT : dasViech
; AUTHOR : Knieb
; CREATED : 20.11.2009
; EDITED : 20.11.2009
; ---------------------------------------------------------------------
Constant SCREENW = 1280
Constant SCREENH = 1024
Constant PIECES = 50
Constant MOVEAFTER = 50
Constant COLOURSHIFTAFTER = 150
OpenScreen SCREENW, SCREENH, 32, 2
SetFPS 0
Type tVec
x As Float
y As Float
col
EndType
type tPiece
p1 as tVec
p2 as tVec
p3 as tVec
endtype
dim p(PIECES-1) as tPiece
dim pt as tVec
buffer = NewFXImage(SCREENW, SCREENH)
p(0).p1.x = rnd(SCREENW) : p(0).p1.y = rnd(SCREENH)
p(0).p2.x = p(0).p1.x-100+rnd(200) : p(0).p2.y = p(0).p2.y-100+rnd(200)
p(0).p3.x = p(0).p1.x-100+rnd(200) : p(0).p3.y = p(0).p1.y-100+rnd(200)
ink 0x444444
Do
if timer()-movetime > MOVEAFTER
p(0).p3.x = p(0).p2.x : p(0).p3.y = p(0).p2.y
p(0).p3.col = p(0).p2.col
p(0).p2.x = p(0).p1.x : p(0).p2.y = p(0).p1.y
p(0).p2.col = p(0).p1.col
pt.x = p(0).p2.x+(p(0).p3.x-p(0).p2.x)*0.5
pt.y = p(0).p2.y+(p(0).p3.y-p(0).p2.y)*0.5
p(0).p1.x = pt.x-100+rnd(200)//+cos(angle)*dist
p(0).p1.y = pt.y-100+rnd(200)//+sin(angle)*dist
angle = angle-60+rnd(1)*120
dist = rndrange(30,70)
p(0).p1.col = rgb(rnd(1)*255, rnd(1)*255, 0)
if p(0).p1.x <= 0 or p(0).p1.x > SCREENW or p(0).p1.y <= 0 or p(0).p1.y > SCREENH
p(0).p1.x = rnd(SCREENW) : p(0).p1.y = rnd(SCREENH)
endif
for t = PIECES-1 to 1 step -1
p(t).p1.x = p(t-1).p1.x : p(t).p1.y = p(t-1).p1.y : p(t).p1.col = p(t-1).p1.col
p(t).p2.x = p(t-1).p2.x : p(t).p2.y = p(t-1).p2.y : p(t).p2.col = p(t-1).p2.col
p(t).p3.x = p(t-1).p3.x : p(t).p3.y = p(t-1).p3.y : p(t).p3.col = p(t-1).p3.col
next t
movetime = timer()
endif
if timer()-colourtime > COLOURSHIFTAFTER
for t = PIECES-1 to 1 step -1
p(t).p1.col = p(t-1).p1.col
p(t).p2.col = p(t-1).p2.col
p(t).p3.col = p(t-1).p3.col
next t
colourtime = timer()
endif
RenderToImage buffer
cls 0
for t = PIECES-1 to 0 step -1
Tri p(t).p1.x+5, p(t).p1.y+5, p(t).p2.x+5, p(t).p2.y+5, p(t).p3.x+5, p(t).p3.y+5
next t
for t = PIECES-1 to 0 step -1
GouraudTri p(t).p1.x, p(t).p1.y, p(t).p1.col, p(t).p2.x, p(t).p2.y, p(t).p2.col, p(t).p3.x, p(t).p3.y, p(t).p3.col
next t
RenderToScreen
DrawImage buffer, 0, 0, 0
Sync
Loop
[/pbcode]
Hi knieb
colourful origami , very nice indeed , looks great , great bold colours , some kinda snake/player shoot-em-up would look great with this.
mick :)
thanks a lot micky :)
Here's a way shorter and better version which looks quite different and smoother
[pbcode]
; PROJECT : dasViech
; AUTHOR : Knieb
; CREATED : 20.11.2009
; EDITED : 20.11.2009
; ---------------------------------------------------------------------
Constant SCREENW = 1280
Constant SCREENH = 1024
Constant NODES = 150
Constant MOVEAFTER = 20
Constant COLOURSHIFTAFTER = 100
OpenScreen SCREENW, SCREENH, 32, 2
Type tNode
x As Float
y As Float
col
EndType
Dim n(NODES-1) As tNode
buffer = NewFXImage(SCREENW, SCREENH)
Ink 0x444444
Do
If Timer()-movetime > MOVEAFTER And CtrlKeys(1) = 0
For t = NODES-1 To 1 Step -1
n(t).x = n(t-1).x : n(t).y = n(t-1).y : n(t).col = n(t-1).col
//n(t).y = n(t).y-5+t/5
Next t
n(0).x = n(0).x-80+rnd(160)
n(0).y = n(0).y-80+rnd(160)
if n(0).x < 0 then n(0).x = 0
if n(0).x > SCREENW then n(0).x = SCREENW
if n(0).y < 0 then n(0).y = 0
if n(0).y > SCREENH then n(0).y = SCREENH
n(0).col = rgb(rnd(1)*255, rnd(1)*255, rnd(1)*255)
movetime = Timer()
EndIf
If Timer()-colourtime > COLOURSHIFTAFTER
For t = NODES-1 To 1 Step -1
n(t).col = n(t-1).col
Next t
colourtime = Timer()
EndIf
RenderToImage buffer
Cls 0
For t = NODES-1 To 2 Step -1
Tri n(t-2).x+5, n(t-2).y+5, n(t-1).x+5, n(t-1).y+5, n(t).x+5, n(t).y+5
Next t
For t = NODES-1 To 2 Step -1
GouraudTri n(t-2).x, n(t-2).y, n(t-2).col, n(t-1).x, n(t-1).y, n(t-1).col, n(t).x, n(t).y, n(t).col
Next t
RenderToScreen
DrawImage buffer, 0, 0, 0
Sync
Loop
[/pbcode]
Here is another (crazy) version:
[pbcode]
; PROJECT : dasViech
; AUTHOR : Knieb
; CREATED : 20.11.2009
; EDITED : 20.11.2009
; ---------------------------------------------------------------------
Constant SCREENW = 1280
Constant SCREENH = 1024
Constant NODES = 150
Constant MOVEAFTER = 15
Constant COLOURSHIFTAFTER = 50
OpenScreen SCREENW, SCREENH, 32, 2
Type tNode
x As Float
y As Float
col
EndType
Dim n(NODES-1) As tNode
buffer = NewFXImage(SCREENW, SCREENH)
Ink 0x444444
Do
If Timer()-movetime > MOVEAFTER And CtrlKeys(1) = 0
For t = NODES-1 To 1 Step -1
n(t).x = n(t-1).x : n(t).y = n(t-1).y : n(t).col = n(t-1).col
n(t).y = n(t).y-5+t/5
Next t
n(0).x = n(0).x-80+rnd(160)
n(0).y = n(0).y-80+rnd(160)
if n(0).x < 0 then n(0).x = 0
if n(0).x > SCREENW then n(0).x = SCREENW
if n(0).y < 0 then n(0).y = 0
if n(0).y > SCREENH then n(0).y = SCREENH
n(0).col = rgb(rnd(1)*255, rnd(1)*255, rnd(1)*255)
movetime = Timer()
EndIf
If Timer()-colourtime > COLOURSHIFTAFTER
For t = NODES-1 To 1 Step -1
n(t).col = n(t-1).col
Next t
colourtime = Timer()
EndIf
RenderToImage buffer
Cls 0
For t = NODES-1 To 2 Step -1
Tri n(t-2).x+5, n(t-2).y+5, n(t-1).x+5, n(t-1).y+5, n(t).x+5, n(t).y+5
Next t
For t = NODES-1 To 2 Step -1
GouraudTri n(t-2).x, n(t-2).y, n(t-2).col, n(t-1).x, n(t-1).y, n(t-1).col, n(t).x, n(t).y, n(t).col
Next t
RenderToScreen
DrawImage buffer, 0, 0, 0
Sync
Loop
[/pbcode]
Yes, very good examples. You don'y need screen sized FX buffer though, since the code doesn't read from the 'destination' buffer.
[pbcode]
; PROJECT : dasViech
; AUTHOR : Knieb
; CREATED : 20.11.2009
; EDITED : 20.11.2009
; ---------------------------------------------------------------------
Constant SCREENW = 1280
Constant SCREENH = 1024
Constant NODES = 150
Constant MOVEAFTER = 15
Constant COLOURSHIFTAFTER = 50
OpenScreen SCREENW, SCREENH, 32, 2
Type tNode
x As Float
y As Float
col
EndType
Dim n(NODES-1) As tNode
;buffer = NewFXImage(SCREENW, SCREENH)
Ink 0x444444
Do
Cls 0
If Timer()-movetime > MOVEAFTER And CtrlKeys(1) = 0
For t = NODES-1 To 1 Step -1
t2=t-1
n(t).x = n(t2).x
n(t).y = n(t2).y
n(t).col = n(t2).col
n(t).y = n(t).y-5+t/5
Next t
n(0).x = n(0).x-80+rnd(160)
n(0).y = n(0).y-80+rnd(160)
if n(0).x < 0 then n(0).x = 0
if n(0).x > SCREENW then n(0).x = SCREENW
if n(0).y < 0 then n(0).y = 0
if n(0).y > SCREENH then n(0).y = SCREENH
n(0).col = rgb(rnd(1)*255, rnd(1)*255, rnd(1)*255)
movetime = Timer()
EndIf
If Timer()-colourtime > COLOURSHIFTAFTER
For t = NODES-1 To 1 Step -1
n(t).col = n(t-1).col
Next t
colourtime = Timer()
EndIf
lockbuffer
For t = NODES-1 To 2 Step -1
Tri n(t-2).x+5, n(t-2).y+5, n(t-1).x+5, n(t-1).y+5, n(t).x+5, n(t).y+5
Next t
For t = NODES-1 To 2 Step -1
GouraudTri n(t-2).x, n(t-2).y, n(t-2).col, n(t-1).x, n(t-1).y, n(t-1).col, n(t).x, n(t).y, n(t).col
Next t
unlockbuffer
Sync
Loop
[/pbcode]