Dark Bit Factory & Gravity
GENERAL => Projects => Topic started by: zparticle on May 08, 2006
-
Starting on Demo VI now. Playing around with various ideas. Built a new scroller and a water effect for this one check it out.
http://www.scottshaver2000.com/blitz/demo6/demo6.exe
(http://www.scottshaver2000.com/blitz/demo6/demo6.png)
-
Now that is really looking very impressive indeed!
Great one Z! :D
-
Nice water plasma type thing, it's looking good :)
-
Pretty nice start - hope to see something cool come out of this
-
some more fooling around for this demo
http://www.scottshaver2000.com/blitz/effects/julia/julia.exe
(http://www.scottshaver2000.com/blitz/effects/julia/julia1.png)
-
Cool Fractals :D
-
some more fooling around for this demo
http://www.scottshaver2000.com/blitz/effects/mandelbrot/mandelbrot.exe
(http://www.scottshaver2000.com/blitz/effects/mandelbrot/mandelbrot1.png)
-
I like fractals, I hope that you do something unusual with them in the finished demo because they can be really cool if used creatively. I liked the zoom.
Maybe a fractal fly through with a nice light blue colour palette?
-
Yeah not sure yet if I will use them. Just playing around with different ideas, thought I might try to do a sphere mapping of a fractal or something. That's probably a bit over me head though. ;D
-
Prefer the greyscale version myself, perhaps you could colour index it using the 0-255 grey shades and show with a custom 255 palette. And perhaps Alpha Blur it. Might look pretty sweet.
-
Cool fractals!!!
You could try doing what i did with the julia using this algo:
http://www.creativemagazine.com/science/Rings01/index.html
Here's a demo of it in FB:
http://rel.betterwebber.com/junk.php?id=33
-
:o Beautiful fractals Relsoft, props for including the source too.
-
@relsoft: WOW! that Julia animation is beautiful!
-
Thanks! But as you can see, the coloring algo wasn't mine. I just thought I could apply it to the julia because the mandel maps the julia. Prety cool algo to calculate color. It's ironic that I haven't tried to apply it on the mandel itself and zoom. Maybe you could. I llike your demos too. The only problem is that I don't have Blitzmax. :*)
-
Nice stuff, dudes ;)
-
Okay some more experimenting for this demo, this time plasma type stuff. There are 7 different variations on the plasma effect in this program and you can control various parameters at run time. For my life I can't get that wobbly effect everone else uses in their plasmas, guess I'm just dumb. ;D
http://www.scottshaver2000.com/blitz/effects/plasma/plasma.exe
(http://www.scottshaver2000.com/blitz/effects/plasma/plasma.png)
-
Nice colors!!!
For the wobbly effect, it's not as hard as you might think. Hre's my tute on the matter. :*)
http://petesqbsite.com/sections/zines/qbcm/issues/4-1/default.html#plasmas
-
Very pretty colours Zparticle, and a great tut from Relsoft :)
-
new version up that should be faster, take less CPU and let's you go down to 1:1 scale
-
Strict
Framework BRL.GlMax2D
Import BRL.System
Import BRL.Basic
Import BRL.Retro
Import BRL.Max2D
Graphics 640,480,32',60
Global scaleX:Float = 4
Global scaleY:Float = 4
Global angle:Float = 0
Global angleOff:Float = 4
Global plasma:Int = 1
Global factor:Float = 2
While Not KeyHit(KEY_ESCAPE)
Delay 20/scaleX
Cls
' space changes the effect
If KeyHit(KEY_SPACE)
plasma:+1
If plasma>7 Then plasma=1
Select plasma
Case 1
factor=2
Plasma1(factor)
Case 2
factor=2
Plasma2(factor)
Case 3
angle=0
factor=1
Plasma3(factor)
Case 4
angle=0
factor=1
Plasma4(factor)
Case 5
factor=2
Plasma5(factor)
Case 6
factor=2
Plasma6(factor)
Case 7
factor=2
Plasma7(factor)
End Select
End If
' up arrow increases scale
If KeyHit(KEY_UP)
scaleX:+1
scaleY:+1
' down arrow decreases scale
Else If KeyHit(KEY_DOWN) And scaleX>1
scaleX:-1
scaleY:-1
End If
' right arrow increases factor
If KeyDown(KEY_RIGHT)
factor:+.01
' left arrow decreases factor
Else If KeyDown(KEY_LEFT) And scaleX>1
factor:-.01
End If
Select plasma
Case 1
Plasma1(factor)
Case 2
Plasma2(factor)
Case 3
Plasma3(factor)
Case 4
Plasma4(factor)
Case 5
Plasma5(factor)
Case 6
Plasma6(factor)
Case 7
Plasma7(factor)
End Select
DrawStats()
Flip
angle:+angleOff
Wend
End
Function DrawStats()
SetScale(1,1)
SetColor(0,0,0)
DrawText("Â Â Â Plasma (Space): "+plasma,10,10)
DrawText("Â Â Scale (Up/Down) : "+scaleX,10,25)
DrawText("Factor (Left/Right): "+factor,10,40)
SetColor(255,255,255)
DrawText("Â Â Â Plasma (Space): "+plasma,9,9)
DrawText("Â Â Scale (Up/Down) : "+scaleX,9,24)
DrawText("Factor (Left/Right): "+factor,9,39)
End Function
Function Plasma1(factor:Float)
SetScale(scaleX,scaleY)
Local xlimit:Int = GraphicsWidth()/scaleX
Local ylimit:Int = GraphicsHeight()/scaleY
For Local x:Int = 0 To xlimit
For Local y:Int = 0 To ylimit
' nice pulsing
Local sxf:Float = Sin(x*scaleX*factor)
Local syf:Float = Sin(y*scaleY*factor)
Local cyf:Float = Cos(y*scaleY*factor)
Local rindex:Int = Abs(256*( sxf + syf + Sin(angle) ))
Local gindex:Int = Abs(256*( cyf + sxf + Cos(angle) ))
Local bindex:Int = Abs(256*( cyf + sxf ))
SetColor rindex,gindex,bindex
ScaleDrawRect(x,y,1,1)
Next
Next
End Function
Function Plasma2(factor:Float)
SetScale(scaleX,scaleY)
Local xlimit:Int = GraphicsWidth()/scaleX
Local ylimit:Int = GraphicsHeight()/scaleY
For Local x:Int = 0 To xlimit
For Local y:Int = 0 To ylimit
' cool
Local sxf:Float = Sin(x*scaleX*factor)
Local syf:Float = Sin(y*scaleY*factor)
Local cyf:Float = Cos(y*scaleY*factor)
Local cxf:Float = Cos(x*scaleX*factor)
Local sa:Float = Sin(angle)
Local ca:Float = Cos(angle)
Local rindex:Int = Abs(256*( sxf + cyf + sa ))
Local gindex:Int = Abs(256*( syf + cxf + ca ))
Local bindex:Int = Abs(256*( ca + sa ))
SetColor rindex,gindex,bindex
ScaleDrawRect(x,y,1,1)
Next
Next
End Function
Function Plasma3(factor:Float)
SetScale(scaleX,scaleY)
Local xlimit:Int = GraphicsWidth()/scaleX
Local ylimit:Int = GraphicsHeight()/scaleY
For Local x:Int = 0 To xlimit
For Local y:Int = 0 To ylimit
' very cool
Local sxf:Float = Sin(x*scaleX*factor)
Local syf:Float = Sin(y*scaleY*factor)
Local cyf:Float = Cos(y*scaleY*factor)
Local cxf:Float = Cos(x*scaleX*factor)
Local sa:Float = Sin(angle)
Local ca:Float = Cos(angle)
Local rindex:Int = Abs(256*( sxf + cyf + sa ))
Local gindex:Int = Abs(256*( syf + cxf + ca ))
Local bindex:Int = Abs(256*( ca + sa + cyf + sxf ))
SetColor rindex,gindex,bindex
ScaleDrawRect(x,y,1,1)
Next
Next
End Function
Function Plasma4(factor:Float)
SetScale(scaleX,scaleY)
Local xlimit:Int = GraphicsWidth()/scaleX
Local ylimit:Int = GraphicsHeight()/scaleY
For Local x:Int = 0 To xlimit
For Local y:Int = 0 To ylimit
Local sxf:Float = Sin(x*scaleX*factor)
Local syf:Float = Sin(y*scaleY*factor)
Local cyf:Float = Cos(y*scaleY*factor)
Local cxf:Float = Cos(x*scaleX*factor)
Local sa:Float = Sin(angle)
Local ca:Float = Cos(angle)
Local rindex:Int = Abs(256*( sxf + cyf + Sin(angle/45*(x/2)) ))
Local gindex:Int = Abs(256*( syf + cxf + Cos(angle/45*(y/2)) ))
Local bindex:Int = Abs(256*( ca + sa ))
SetColor rindex,gindex,bindex
ScaleDrawRect(x,y,1,1)
Next
Next
End Function
Function Plasma5(factor:Float)
SetScale(scaleX,scaleY)
Local xlimit:Int = GraphicsWidth()/scaleX
Local ylimit:Int = GraphicsHeight()/scaleY
For Local x:Int = 0 To xlimit
For Local y:Int = 0 To ylimit
Local syf:Float = Sin(y*scaleY*factor)
Local cyf:Float = Cos(y*scaleY*factor)
Local cxf:Float = Cos(x*scaleX*factor)
Local sa:Float = Sin(angle)
Local ca:Float = Cos(angle)
Local rindex:Int = Abs(256*( syf + sa ))
Local gindex:Int = Abs(256*( cyf + ca ))
Local bindex:Int = Abs(256*( cxf + sa ))
SetColor rindex,gindex,bindex
ScaleDrawRect(x,y,1,1)
Next
Next
End Function
Function Plasma6(factor:Float)
SetScale(scaleX,scaleY)
Local xlimit:Int = GraphicsWidth()/scaleX
Local ylimit:Int = GraphicsHeight()/scaleY
For Local x:Int = 0 To xlimit
For Local y:Int = 0 To ylimit
Local syf:Float = Sin(y*scaleY*factor)
Local cyf:Float = Cos(y*scaleY*factor)
Local rindex:Int = Abs(256*( cyf + Cos(angle*x/factor) ))
Local gindex:Int = Abs(256*( syf + Cos(angle*x/factor) ))
Local bindex:Int = Abs(256*( cyf + Cos(angle*x/factor) ))
SetColor rindex,gindex,bindex
ScaleDrawRect(x,y,1,1)
Next
Next
End Function
Function Plasma7(factor:Float)
SetScale(scaleX,scaleY)
Local xlimit:Int = GraphicsWidth()/scaleX
Local ylimit:Int = GraphicsHeight()/scaleY
For Local x:Int = 0 To xlimit
For Local y:Int = 0 To ylimit
Local sxf:Float = Sin(x*scaleX*factor)
Local cxf:Float = Cos(x*scaleX*factor)
Local rindex:Int = Abs(256*( cxf + Cos(angle*y/factor) ))
Local gindex:Int = Abs(256*( sxf + Cos(angle*y/factor) ))
Local bindex:Int = Abs(256*( cxf + Cos(angle*y/factor) ))
SetColor rindex,gindex,bindex
ScaleDrawRect(x,y,1,1)
Next
Next
End Function
Function ScaleDrawRect(x:Int,y:Int,w:Int,h:Int)
Local sx:Float,sy:Float
GetScale(sx,sy)
DrawRect(sx*x,sy*y,w,h)
End Function
-
Kudos for posting the source, have some good Karma.
-
;D
-
Very original looking plasma dude!
Can't wait to see the demo in it's entirity.
Cheers and welldone,
Clyde.
-
New test. Now I'm playing with "masked" drawing, this is a total hack to do in blitzmax, animating the inside of a font using only 2D commands. Does anyone know how slow/fast Pixmaps in BMax are? I suspect they are very slow and you don't want to try to do realtime effects using them. This test doesn't modify pixmaps, like i said it's a hack.
http://www.scottshaver2000.com/blitz/demo6/lines.exe
(http://www.scottshaver2000.com/blitz/demo6/lines1.png)
-
Looks quite an interesting technique. It would look a lot nicer with a more traditional type of plasma pattern inside the font, is that possible?
-
Okay try this one on for size.
http://www.scottshaver2000.com/blitz/effects/lineimage/lineimage.exe
(http://www.scottshaver2000.com/blitz/effects/lineimage/lines2.png)
(http://www.scottshaver2000.com/blitz/effects/lineimage/mom_child.png)
(http://www.scottshaver2000.com/blitz/effects/lineimage/hansolo_crisp.png)
'=================================================================
' By: Scott Shaver
'=================================================================
Strict
Framework BRL.GlMax2D
Import BRL.System
Import BRL.Basic
Import BRL.Retro
Import BRL.Max2D
Import BRL.pngloader
Graphics 640,480',32',60
'=================================================================
Incbin "mom_child.png"
Global mom:TImage = LoadImage("incbin::mom_child.png")
Global momImage:LineImage = LineImage.Create(mom)',0,255,255,255)
momImage.SetColorFunction(SetMomDrawColor) ' use this function to set the color when drawing
Incbin "hansolo_crisp.png"
Global font:TImage = LoadAnimImage("incbin::hansolo_crisp.png",32,32,0,128,FILTEREDIMAGE|MASKEDIMAGE|DYNAMICIMAGE)
Global lif:LineImageFont = LineImageFont.Create(font)
lif.SetColorFunction(SetFontDrawColor) ' use this function to set the color when drawing
lif.SetCoordFunction(SetFontCoordOffset) ' use this function to modify the draw coords
Global ang:Double=0
Global ang2:Double=0
Global tilt:Float=0
Global tiltOff:Float=.01
'=================================================================
While Not KeyHit(KEY_ESCAPE)
Cls
SetScale(1,1)
lif.DrawFont(tilt,False)
SetScale(1,1)
momImage.Draw(320+Cos(ang2)*220,240+Sin(ang2)*140,tilt,False)
ang:+4
ang2:+1
'tilt:+tiltOff
'If tiltOff>0 And tilt>1 Then tiltOff=-.01
'If tiltOff<0 And tilt<-1 Then tiltOff=.01
Flip
Wend
End
'=================================================================
Function SetMomDrawColor(x:Int,y:Int)
SetColor(Abs(255*Cos(x+ang2)),Abs(255*Sin(y+ang2)),Abs(255*Cos(y+ang2)))
End Function
'=================================================================
Function SetFontDrawColor(x:Int,y:Int)
SetColor(Abs(255*Cos(y+ang)),Abs(255*Sin(y+ang)),Abs(255*Cos(y+ang)))
End Function
'=================================================================
Function SetFontCoordOffset(x:Double Var,y:Double Var)
x :+ Sin(y/.5+ang)*14
End Function
'=================================================================
' this type holds the coordinates for a line segment
'=================================================================
Type Line
Field x1:Double,y1:Double,x2:Double,y2:Double
Field SetDrawColor(x:Int,y:Int) = Null
Field SetCoordOffset(x:Double Var,y:Double Var) = Null
Method SetColorFunction(SetDrawColor(x:Int,y:Int))
self.SetDrawColor = SetDrawColor
End Method
Method SetCoordFunction(SetCoordOffset(x:Double Var,y:Double Var))
self.SetCoordOffset = SetCoordOffset
End Method
Function Create:Line(x1:Double,y1:Double,x2:Double,y2:Double)
Local rval:Line = New Line
rval.x1=x1
rval.y1=y1
rval.x2=x2
rval.y2=y2
Return rval
End Function
Method Draw(x:Double,y:Double,tilt:Float)
If SetDrawColor<>Null Then
SetDrawColor(x1+x,y1+y)
EndIf
Local dx:Double = x1+x+(tilt*y1)
Local dy:Double = y1+y
If SetCoordOffset<>Null Then SetCoordOffset(dx,dy)
ScaleDrawRect(dx,dy,x2-x1,1)
End Method
Function ScaleDrawRect(x:Double,y:Double,w:Double,h:Double)
Local sx:Float,sy:Float
GetScale(sx,sy)
If sx*x>GraphicsWidth() Or sy*y>GraphicsHeight() Then Return
DrawRect(sx*x,sy*y,w,h)
End Function
Method DrawByPixel(x:Double,y:Double,tilt:Double)
Local deltax:Double= Abs(x2 - x1)Â Â Â Â ' The difference between the x's
Local deltay:Double= Abs(y2 - y1)Â Â Â Â ' The difference between the y's
Local lx:Double= x1Â Â Â Â Â Â Â Â Â Â Â Â ' Start x off at the first pixel
Local ly:Double= y1Â Â Â Â Â Â Â Â Â Â Â Â ' Start y off at the first pixel
Local xinc1:Double= 0
Local yinc1:Double= 0
Local xinc2:Double= 0
Local yinc2:Double= 0
Local numadd:Double= 0
Local numpixels:Double= 0
Local den:Double= 0
Local num:Double= 0
If x2 >= x1 Then         ' The x-values are increasing
 xinc1 = 1
 xinc2 = 1
Else             ' The x-values are decreasing
 xinc1 = -1
 xinc2 = -1
EndIf
If y2 >= y1 Then         ' The y-values are increasing
 yinc1 = 1
 yinc2 = 1
Else             ' The y-values are decreasing
 yinc1 = -1
 yinc2 = -1
EndIf
If deltax >= deltay Then    ' There is at least one x-value For every y-value
 xinc1 = 0         ' Don't change the x when numerator >= denominator
 yinc2 = 0         ' Don't change the y for every iteration
 den = deltax
 num = deltax / 2
 numadd = deltay
 numpixels = deltax     ' There are more x-values than y-values
Else             ' There is at least one y-value For every x-value
 xinc2 = 0         ' Don't change the x for every iteration
 yinc1 = 0         ' Don't change the y when numerator >= denominator
 den = deltay
 num = deltay / 2
 numadd = deltax
 numpixels = deltay     ' There are more y-values than x-values
EndIf
For Local curpixel:Int = 0 To numpixels
If SetDrawColor<>Null Then
SetDrawColor(x1+x,y1+y)
EndIf
Local dx:Double = lx+x-(y1*tilt)
Local dy:Double = ly+y
If SetCoordOffset<>Null Then SetCoordOffset(dx,dy)
ScaleDrawRect(dx,dy,1,1) ' draw the current pixel
num :+ numadd       ' Increase the numerator by the top of the fraction
If num >= den Then       ' Check If numerator >= denominator
num :- den        ' Calculate the New numerator value
lx :+ xinc1Â Â Â Â Â Â Â Â ' Change the x as appropriate
ly :+ yinc1Â Â Â Â Â Â Â Â ' Change the y as appropriate
EndIf
lx :+ xinc2Â Â Â Â Â Â Â Â Â ' Change the x as appropriate
ly :+ yinc2Â Â Â Â Â Â Â Â Â ' Change the y as appropriate
Next
End Method
End Type
'=================================================================
' an image made of line segments
'=================================================================
Type LineImage
Field lines:Line[] = New Line[0]
Field width:Int = 0
Field height:Int = 0
Field lineCount:Int = 0
Method SetColorFunction(SetDrawColor(x:Int,y:Int))
For Local l:Int = 0 Until lineCount
lines[l].SetColorFunction(SetDrawColor)
Next
End Method
Method SetCoordFunction(SetCoordOffset(x:Double Var,y:Double Var))
For Local l:Int = 0 Until lineCount
lines[l].SetCoordFunction(SetCoordOffset)
Next
End Method
Method Draw(x:Double,y:Double,tilt:Double,pixel:Byte=True)
If pixel=True Then
For Local l:Int = 0 Until lineCount
lines[l].DrawByPixel(x,y,tilt)
Next
Else
For Local l:Int = 0 Until lineCount
lines[l].Draw(x,y,tilt)
Next
EndIf
End Method
Function Create:LineImage(image:TImage,frame:Int=0,r:Int=0,g:Int=0,b:Int=0)
Local rval:LineImage = New LineImage
Local pm:TPixmap = LockImage( image,frame)
rval.width = PixmapWidth(pm)
rval.height = PixmapHeight(pm)
Local started:Byte=False
Local sx:Int=-1
Local ex:Int=-1
For Local y:Int = 0 Until rval.height
started=False
sx=-1
ex=-1
For Local x:Int = 0 Until rval.width
Local pix:Int = pm.ReadPixel(x,y)
If started=False And (pix & $FF000000)<>0 And (pix & $00FFFFFF) | (r Shl 16|g Shl 8|b) <> 0 Then ' found SOL
started=True
sx = x
Else If started=True And ((pix & $FF000000)=0 Or (pix & $00FFFFFF) | (r Shl 16|g Shl 8|b) = 0) Then ' found EOL
ex = x-1
EndIf
If started=True And ex<>-1 Then
Local l:Line = Line.Create(sx-(rval.width/2),y-(rval.height/2),ex-(rval.width/2),y-(rval.height/2))
rval.lines = rval.lines[..(rval.lineCount+1)]
rval.lines[rval.lineCount]=l
rval.lineCount:+1
started=False
sx=-1
ex=-1
EndIf
Next
If started=True And ex=-1 Then
ex=rval.width-1
Local l:Line = Line.Create(sx-(rval.width/2),y-(rval.height/2),ex-(rval.width/2),y-(rval.height/2))
rval.lines = rval.lines[..(rval.lineCount+1)]
rval.lines[rval.lineCount]=l
rval.lineCount:+1
EndIf
Next
UnlockImage(image,frame)
Return rval
End Function
End Type
'=================================================================
' a font made of LineImage objects
'=================================================================
Type LineImageFont
Field chars:LineImage[] = New LineImage[256]
Method SetColorFunction(SetDrawColor(x:Int,y:Int))
For Local c:Int = 0 To 127
chars[c].SetColorFunction(SetDrawColor)
Next
End Method
Method SetCoordFunction(SetCoordOffset(x:Double Var,y:Double Var))
For Local l:Int = 0 To 127
chars[l].SetCoordFunction(SetCoordOffset)
Next
End Method
Function Create:LineImageFont(image:TImage,r:Int=0,g:Int=0,b:Int=0)
Local rval:LineImageFont = New LineImageFont
For Local c:Int = 0 To 127
rval.chars[c] = LineImage.Create(image,c,r,g,b)
Next
Return rval
End Function
Method DrawFont(tilt:Float=0,pixel:Byte=True)
For Local y:Int=0 To 15
For Local x:Int = 0 To 15
If chars[(y*16)+x]<>Null Then
chars[(y*16)+x].Draw((x+1)*chars[0].width,(y+1)*chars[0].height,tilt,pixel)
EndIf
Next
Next
End Method
End Type
-
That looks so much nicer, great colours too :)
-
Okay I saw a similar effect in one demo a long time ago and I've always wanted to recreate it so here is my WICKED SCROLLER. aha ahaha aha a haha ::) >:D
It is MUCH cooler that the image below shows
http://www.scottshaver2000.com/blitz/effects/wickedscroller/wickedscroller.exe
(http://www.scottshaver2000.com/blitz/effects/wickedscroller/lines3.png)
(http://www.scottshaver2000.com/blitz/effects/wickedscroller/hansolo_crisp.png)
(http://www.scottshaver2000.com/blitz/effects/wickedscroller/hbar.png)
'=================================================================
' By: Scott Shaver
'=================================================================
Strict
Framework BRL.GlMax2D
Import BRL.System
Import BRL.Basic
Import BRL.Retro
Import BRL.Max2D
Import BRL.pngloader
Graphics 640,480,32',60
'=================================================================
Incbin "mom_child.png"
Global mom:TImage = LoadImage("incbin::mom_child.png")
Global momImage:LineImage = LineImage.Create(mom)',0,255,255,255)
momImage.SetColorFunction(SetMomDrawColor) ' use this function to set the color when drawing
Incbin "hansolo_crisp.png"
Global font:TImage = LoadAnimImage("incbin::hansolo_crisp.png",32,32,0,128,FILTEREDIMAGE|MASKEDIMAGE|DYNAMICIMAGE)
Global lif:LineImageFont = LineImageFont.Create(font,0,0,0,90,-1)
lif.SetColorFunction(SetFontDrawColor) ' use this function to set the color when drawing
'lif.SetCoordFunction(SetFontCoordOffset) ' use this function to modify the draw coords
Incbin "hbar.png"
Global hbar:TImage = LoadImage("incbin::hbar.png")
MidHandleImage(hbar)
Global ang:Double=0
Global ang2:Double=0
Global tilt:Float=0'.5
Global tiltOff:Float=.01
Global scrollerx:Float=GraphicsWidth()
SetClsColor(100,100,200)
'lif.rotate(0,75,0)
'=================================================================
While Not KeyHit(KEY_ESCAPE)
Cls
SetScale(1,1)
'lif.DrawFont(tilt,False,0,0)
lif.rotate(4,0,0)
SetScale(1,1)
'momImage.Draw(320+Cos(ang2)*220,240+Sin(ang2)*140,tilt,False)
'momImage.rotate(0,0,1)
ang:+4
ang2:+1
'tilt:+tiltOff
'If tiltOff>0 And tilt>1 Then tiltOff=-.01
'If tiltOff<0 And tilt<-1 Then tiltOff=.01
Local msg:String = "       WICKED SCROLLER! BROUGHT TO YOU BY ZPARTICLE! I HAVE ONLY EVER SEEN THIS IN ONE DEMO AND I THOUGHT IT WAS TOTALLY COOL!      "
lif.DrawString(scrollerx,GraphicsHeight()/2,msg,0,0,0)
If scrollerx<=-Len(msg)*32 Then scrollerx=GraphicsWidth()
scrollerx:-1
Flip
Wend
End
'=================================================================
Function SetMomDrawColor(x:Int,y:Int,z:Int)
SetColor(Abs(255*Cos(x+ang2)),Abs(255*Sin(y+ang2)),Abs(255*Cos(y+ang2)))
End Function
'=================================================================
Function SetFontDrawColor(x:Int,y:Int,z:Int)
'SetColor(Abs(255*Cos(y+ang)),Abs(255*Sin(y+ang)),Abs(255*Cos(y+ang)))
SetColor(175+(5*z),175+(5*z),50+(5*z))
End Function
'=================================================================
Function SetFontCoordOffset(x:Double Var,y:Double Var)
x :+ Sin(y/.25+ang)*4
End Function
'=================================================================
' this type holds the coordinates for a line segment
'=================================================================
Type Line
Field x1:Double,y1:Double,x2:Double,y2:Double,z1:Double=15,z2:Double=15
Field SetDrawColor(x:Int,y:Int,z:Int) = Null
Field SetCoordOffset(x:Double Var,y:Double Var) = Null
Method compare:Int(o:Object)
     Local s:Line = Line(o)
     If Not s Then Return 1
     Return z1 - s.z1
  End Method
Method SetColorFunction(SetDrawColor(x:Int,y:Int,z:Int))
self.SetDrawColor = SetDrawColor
End Method
Method SetCoordFunction(SetCoordOffset(x:Double Var,y:Double Var))
self.SetCoordOffset = SetCoordOffset
End Method
Function Create:Line(x1:Double,y1:Double,x2:Double,y2:Double)
Local rval:Line = New Line
rval.x1=x1
rval.y1=y1
rval.x2=x2
rval.y2=y2
Return rval
End Function
'--------------------------------------------------------
' rotate a point around the origin, we rotate in the following order x,y,z
' xa,ya,za - The angle To rotate the point from its current position, in degrees
Method rotate(xa:Double,ya:Double,za:Double)
Local xx:Double = Cos(ya) * Cos(za)
Local xy:Double = (Sin(xa) * Sin(ya) *Cos(za)) - (Cos(xa) * Sin(za))
Local xz:Double = (Cos(xa) * Sin(ya) *Cos(za)) + (Sin(xa) * Sin(za))
Local yx:Double = Cos(ya) * Sin(za)
Local yy:Double = (Cos(xa) * Cos(za)) + (Sin(xa) * Sin(ya) * Sin(za))
Local yz:Double = (-Sin(xa) * Cos(za)) + (Cos(xa) * Sin(ya) * Sin(za))
Local zx:Double = -Sin(ya)
Local zy:Double = Sin(xa) * Cos(ya)
Local zz:Double = Cos(xa) * Cos(ya)
Local nx:Double = (x1*xx)+(y1*xy)+(z1*xz)
Local ny:Double = (x1*yx)+(y1*yy)+(z1*yz)
Local nz:Double = (x1*zx)+(y1*zy)+(z1*zz)
x1=nx
y1=ny
z1=nz
nx = (x2*xx)+(y2*xy)+(z2*xz)
ny = (x2*yx)+(y2*yy)+(z2*yz)
nz = (x2*zx)+(y2*zy)+(z2*zz)
x2=nx
y2=ny
z2=nz
End Method
'--------------------------------------------------------
' rotate a point around the origin, we rotate in the following order x,y,z
' xa,ya,za - The angle To rotate the point from its current position, in degrees
Method TempRotate(xa:Double,ya:Double,za:Double,x1:Double Var,y1:Double Var,z1:Double Var,x2:Double Var,y2:Double Var,z2:Double Var)
Local xx:Double = Cos(ya) * Cos(za)
Local xy:Double = (Sin(xa) * Sin(ya) *Cos(za)) - (Cos(xa) * Sin(za))
Local xz:Double = (Cos(xa) * Sin(ya) *Cos(za)) + (Sin(xa) * Sin(za))
Local yx:Double = Cos(ya) * Sin(za)
Local yy:Double = (Cos(xa) * Cos(za)) + (Sin(xa) * Sin(ya) * Sin(za))
Local yz:Double = (-Sin(xa) * Cos(za)) + (Cos(xa) * Sin(ya) * Sin(za))
Local zx:Double = -Sin(ya)
Local zy:Double = Sin(xa) * Cos(ya)
Local zz:Double = Cos(xa) * Cos(ya)
Local nx:Double = (x1*xx)+(y1*xy)+(z1*xz)
Local ny:Double = (x1*yx)+(y1*yy)+(z1*yz)
Local nz:Double = (x1*zx)+(y1*zy)+(z1*zz)
x1=nx
y1=ny
z1=nz
nx = (x2*xx)+(y2*xy)+(z2*xz)
ny = (x2*yx)+(y2*yy)+(z2*yz)
nz = (x2*zx)+(y2*zy)+(z2*zz)
x2=nx
y2=ny
z2=nz
End Method
Method Draw(x:Double,y:Double,tilt:Float, angle:Double=0)
Global lasty:Double=-1
Local x1:Double = self.x1
Local y1:Double = self.y1
Local z1:Double = self.z1
Local x2:Double = self.x2
Local y2:Double = self.y2
Local z2:Double = self.z2
If angle<>0 Then TempRotate(angle,0,0,x1,y1,z1,x2,y2,z2)
If SetDrawColor<>Null Then
SetDrawColor(x1+x,y1+y,z1)
EndIf
Local dx:Double = x1+x+(tilt*y1)
Local dy:Double = y1+y
If Abs(lasty-dy)>1 Then 'fill gaps between lines when wrapped around origin
If SetCoordOffset<>Null Then SetCoordOffset(dx,dy)
ScaleDrawRect(dx,dy-1,x2-x1,1)
EndIf
If SetCoordOffset<>Null Then SetCoordOffset(dx,dy)
ScaleDrawRect(dx,dy,x2-x1,1)
End Method
Function ScaleDrawRect(x:Double,y:Double,w:Double,h:Double)
Local sx:Float,sy:Float
GetScale(sx,sy)
If sx*x>GraphicsWidth() Or sy*y>GraphicsHeight() Then Return
DrawRect(sx*x,sy*y,w,h)
End Function
Method DrawByPixel(x:Double,y:Double,tilt:Double)
Local deltax:Double= Abs(x2 - x1)Â Â Â Â ' The difference between the x's
Local deltay:Double= Abs(y2 - y1)Â Â Â Â ' The difference between the y's
Local lx:Double= x1Â Â Â Â Â Â Â Â Â Â Â Â ' Start x off at the first pixel
Local ly:Double= y1Â Â Â Â Â Â Â Â Â Â Â Â ' Start y off at the first pixel
Local xinc1:Double= 0
Local yinc1:Double= 0
Local xinc2:Double= 0
Local yinc2:Double= 0
Local numadd:Double= 0
Local numpixels:Double= 0
Local den:Double= 0
Local num:Double= 0
If x2 >= x1 Then         ' The x-values are increasing
 xinc1 = 1
 xinc2 = 1
Else             ' The x-values are decreasing
 xinc1 = -1
 xinc2 = -1
EndIf
If y2 >= y1 Then         ' The y-values are increasing
 yinc1 = 1
 yinc2 = 1
Else             ' The y-values are decreasing
 yinc1 = -1
 yinc2 = -1
EndIf
If deltax >= deltay Then    ' There is at least one x-value For every y-value
 xinc1 = 0         ' Don't change the x when numerator >= denominator
 yinc2 = 0         ' Don't change the y for every iteration
 den = deltax
 num = deltax / 2
 numadd = deltay
 numpixels = deltax     ' There are more x-values than y-values
Else             ' There is at least one y-value For every x-value
 xinc2 = 0         ' Don't change the x for every iteration
 yinc1 = 0         ' Don't change the y when numerator >= denominator
 den = deltay
 num = deltay / 2
 numadd = deltax
 numpixels = deltay     ' There are more y-values than x-values
EndIf
For Local curpixel:Int = 0 To numpixels
If SetDrawColor<>Null Then
SetDrawColor(x1+x,y1+y,z1)
EndIf
Local dx:Double = lx+x-(y1*tilt)
Local dy:Double = ly+y
If SetCoordOffset<>Null Then SetCoordOffset(dx,dy)
ScaleDrawRect(dx,dy,1,1) ' draw the current pixel
num :+ numadd       ' Increase the numerator by the top of the fraction
If num >= den Then       ' Check If numerator >= denominator
num :- den        ' Calculate the New numerator value
lx :+ xinc1Â Â Â Â Â Â Â Â ' Change the x as appropriate
ly :+ yinc1Â Â Â Â Â Â Â Â ' Change the y as appropriate
EndIf
lx :+ xinc2Â Â Â Â Â Â Â Â Â ' Change the x as appropriate
ly :+ yinc2Â Â Â Â Â Â Â Â Â ' Change the y as appropriate
Next
End Method
End Type
'=================================================================
' an image made of line segments
'=================================================================
Type LineImage
Field lines:Line[] = New Line[0]
Field width:Int = 0
Field height:Int = 0
Field lineCount:Int = 0
Field bar:Byte=False
Method SetColorFunction(SetDrawColor(x:Int,y:Int,z1:Int))
For Local l:Int = 0 Until lineCount
lines[l].SetColorFunction(SetDrawColor)
Next
End Method
Method SetCoordFunction(SetCoordOffset(x:Double Var,y:Double Var))
For Local l:Int = 0 Until lineCount
lines[l].SetCoordFunction(SetCoordOffset)
Next
End Method
Method Draw(x:Double,y:Double,tilt:Double,pixel:Byte=True,angle:Double=0,inc:Double=0)
lines.sort()
If pixel=True Then
For Local l:Int = 0 Until lineCount
lines[l].DrawByPixel(x,y,tilt)
Next
Else
Local drawBar:Byte=True
For Local l:Int = 0 Until lineCount
If bar=True And lines[l].z1>0 And drawBar=True Then
Local sx:Float,sy:Float
GetScale(sx,sy)
drawBar=False
SetColor(50,50,255)
DrawImageRect(hbar,sx*x,sy*y,sx*width,sy*ImageHeight(hbar))
EndIf
lines[l].Draw(x,y,tilt,angle+(inc*l))
Next
If bar=True And drawBar=True Then
Local sx:Float,sy:Float
GetScale(sx,sy)
drawBar=False
SetColor(50,50,255)
DrawImageRect(hbar,sx*x,sy*y,sx*width,sy*ImageHeight(hbar))
EndIf
EndIf
End Method
'--------------------------------------------------------
' rotate a point around the origin, we rotate in the following order x,y,z
' xa,ya,za - The angle To rotate the point from its current position, in degrees
Method rotate(xa:Double,ya:Double,za:Double)
For Local l:Int = 0 Until lineCount
lines[l].rotate(xa,ya,za)
Next
End Method
Function Create:LineImage(image:TImage,frame:Int=0,r:Int=0,g:Int=0,b:Int=0,angle:Double=0,inc:Double=0)
Local rval:LineImage = New LineImage
Local pm:TPixmap = LockImage( image,frame)
rval.width = PixmapWidth(pm)
rval.height = PixmapHeight(pm)
Local started:Byte=False
Local sx:Int=-1
Local ex:Int=-1
For Local y:Int = 0 Until rval.height
started=False
sx=-1
ex=-1
For Local x:Int = 0 Until rval.width
Local pix:Int = pm.ReadPixel(x,y)
If started=False And (pix & $FF000000)<>0 And (pix & $00FFFFFF) | (r Shl 16|g Shl 8|b) <> 0 Then ' found SOL
started=True
sx = x
Else If started=True And ((pix & $FF000000)=0 Or (pix & $00FFFFFF) | (r Shl 16|g Shl 8|b) = 0) Then ' found EOL
ex = x-1
EndIf
If started=True And ex<>-1 Then
Local l:Line = Line.Create(sx-(rval.width/2),y-(rval.height/2),ex-(rval.width/2),y-(rval.height/2))
If angle<>0 Or inc<>0 Then l.rotate(angle+(inc*y),0,0)
rval.lines = rval.lines[..(rval.lineCount+1)]
rval.lines[rval.lineCount]=l
rval.lineCount:+1
started=False
sx=-1
ex=-1
EndIf
Next
If started=True And ex=-1 Then
ex=rval.width-1
Local l:Line = Line.Create(sx-(rval.width/2),y-(rval.height/2),ex-(rval.width/2),y-(rval.height/2))
If angle<>0 Or inc<>0 Then l.rotate(angle+(inc*y),0,0)
rval.lines = rval.lines[..(rval.lineCount+1)]
rval.lines[rval.lineCount]=l
rval.lineCount:+1
EndIf
Next
UnlockImage(image,frame)
Return rval
End Function
End Type
'=================================================================
' a font made of LineImage objects
'=================================================================
Type LineImageFont
Field chars:LineImage[] = New LineImage[256]
Method SetColorFunction(SetDrawColor(x:Int,y:Int,z:Int))
For Local c:Int = 0 To 127
chars[c].SetColorFunction(SetDrawColor)
Next
End Method
Method SetCoordFunction(SetCoordOffset(x:Double Var,y:Double Var))
For Local l:Int = 0 To 127
chars[l].SetCoordFunction(SetCoordOffset)
Next
End Method
'--------------------------------------------------------
' rotate a point around the origin, we rotate in the following order x,y,z
' xa,ya,za - The angle To rotate the point from its current position, in degrees
Method rotate(xa:Double,ya:Double,za:Double)
For Local l:Int = 0 To 127
chars[l].rotate(xa,ya,za)
Next
End Method
Function Create:LineImageFont(image:TImage,r:Int=0,g:Int=0,b:Int=0,angle:Double,inc:Double)
Local rval:LineImageFont = New LineImageFont
For Local c:Int = 0 To 127
rval.chars[c] = LineImage.Create(image,c,r,g,b,angle,inc)
rval.chars[c].bar=True
Next
Return rval
End Function
Method DrawFont(tilt:Float=0,pixel:Byte=True,angle:Double=0,inc:Double=0)
For Local y:Int=0 To 15
For Local x:Int = 0 To 15
If chars[(y*16)+x]<>Null Then
chars[(y*16)+x].Draw((x+1)*chars[0].width,(y+1)*(chars[0].height+20),tilt,pixel,angle,inc)
EndIf
Next
Next
End Method
Method DrawString(x:Int,y:Int,msg:String,tilt:Float=0,angle:Double=0,inc:Double=0)
Local spacing = chars[0].width
Local msglen:Int = Len(msg)
Local curx:Int = x
' draw each character
For Local i:Int = 1 To msglen
' get the letter
Local letter:String = Mid$(msg,i,1)
' get the ascii code
Local ccode:Int = Asc(letter$)
chars[ccode].Draw(curx,y,.2,False,angle,inc)
' move To the Next character position
curx = curx + spacing
'angle:+5 ' this gives a spiral effect
Next
End Method
End Type
-
I'll check these out in a bit. They do look handsome, welldone dude. I think your copper scroller looks pretty cool.
-
wow, no feedback on the scroller. :'( I was really happy with this.
-
Great job!!! I like the copper scroller!
-
Classic effect converted well :)
Slight bug with it though, the letters sometimes intersect the blue copperbar as they rotate over it, makes it look a little odd.
-
Yeah I know how to fix it, I think. ;D
-
Tell you what you should also try doing, is to eliviate the need for pressing space or keys to continue to the next part. Add in a time duration, and it would look cool. Unless, the aim is to create a kind of mega demo.
Looking cool, can't wait to see it all in action.
Cheers and all the best,
Clyde.
-
yeah these are just tests the reall thing will be time based.
-
Are there more parts to that preview? I tried pressing space and it didn't do anything :||
-
only on the "plasma" thingy
-
Ah, ok. I pressed space and got all the effects in that one (the first one was the best).
-
here is another one a real time water ripple effect. Code can be found on my site in the examples section. Click or click and drag on the image.
http://www.scottshaver2000.com/blitz/effects/water/water.exe
(http://www.scottshaver2000.com/blitz/effects/water/waterfx.png)
'=================================================================
' By: Scott Shaver
'
' references:
' http://www.gamedev.net/reference/articles/article915.asp
' http://freespace.virgin.net/hugo.elias/graphics/x_water.htm
'
'=================================================================
Strict
Framework BRL.GlMax2D
Import BRL.System
Import BRL.Basic
Import BRL.Retro
Import BRL.Max2D
Import BRL.pngloader
Graphics 640,480',32',60
'=================================================================
Incbin "water.png"
Global water:TImage = LoadImage("incbin::water.png")
Global pixmap:TPixmap = LockImage(water, 0)
Global width:Int = ImageWidth(water)
Global height:Int = ImageHeight(water)
Global buffer1:Int[,] = New Int[width,height]
Global buffer2:Int[,] = New Int[width,height]
Global imageBuffer:Int[,] = New Int[width,height]
Global damping:Double = .0005
Global frame:Int = 0
fillBuffer()
SetScale(2,2)
'=================================================================
While Not KeyHit(KEY_ESCAPE)
Cls
If frame Mod 2 = 0 Then
ProcessWater(buffer1,buffer2)
DrawWater(buffer2)
If MouseDown(1) Then
Local sx:Float,sy:Float
GetScale(sx,sy)
buffer1[MouseX()/sx,MouseY()/sy]:-1000
EndIf
Else
ProcessWater(buffer2,buffer1)
DrawWater(buffer1)
If MouseDown(1) Then
Local sx:Float,sy:Float
GetScale(sx,sy)
buffer2[MouseX()/sx,MouseY()/sy]:-1000
EndIf
EndIf
frame:+1
Flip
Wend
End
Function ScaleDrawRect(x:Double,y:Double,w:Double,h:Double)
Local sx:Float,sy:Float
GetScale(sx,sy)
If sx*x>GraphicsWidth() Or sy*y>GraphicsHeight() Then Return
DrawRect(sx*x,sy*y,w,h)
End Function
Function DrawWater(buffer:Int[,])
Local xoff:Int,yoff:Int,t:Int
For Local x:Int = 1 Until width-1
For Local y:Int = 1 Until height-1
xoff = buffer[x-1,y] - buffer[x+1,y]
yoff = buffer[x,y-1] - buffer[x,y+1]
If xoff+x<0 Or xoff+x>width-1 Then xoff=0
If yoff+y<0 Or yoff+y>height-1Then yoff=0
t = imageBuffer[x+xoff,y+yoff]
SetAlpha(((t & $FF000000) Shr 24)/255)
SetColor((t & $00FF0000) Shr 16,(t & $0000FF00) Shr 8,(t & $000000FF))
ScaleDrawRect(x,y,1,1)
Next
Next
End Function
Function ProcessWater(src:Int[,],dest:Int[,])
For Local y:Int = 1 Until height-1
For Local x:Int = 1 Until width-1
dest[x,y] = (((src[x-1,y]+src[x+1,y]+src[x,y+1]+src[x,y-1]) / 2) - dest[x,y])
dest[x,y] :- (dest[x,y] * damping)
Next
Next
End Function
Function fillBuffer()
For Local x:Int = 1 Until width-2
For Local y:Int = 1 Until height-2
imageBuffer[x,y] = pixmap.ReadPixel(x,y)
Next
Next
End Function
-
Cool that the ripples bounce off the screen edges :) Colours look a bit strange to me though.
-
Cool! Color looks a bit weird though.
try to change this:
dest[x,y] = (((src[x-1,y]+src[x+1,y]+src[x,y+1]+src[x,y-1]) / 2) - dest[x,y])
to this:
dest[x,y] = (((src[x-1,y]+src[x+1,y]+src[x,y+1]+src[x,y-1]) / 4) - dest[x,y])