This code (see next posts) emulates on Blitz3d, the effect that your monitor is like a old broken TV. If you are old enough, you remember the random white noise pattern on a old TV, when no channel was found.
You can just copy and paste it into your Blitz3d to see it work. Use it for any purpose you see fit.
Don't worry, it's perfectly harmless, but great to scare someone, and tell them their monitor went KABOOM!!!
ps. Change the screenmode if you want, maybe you dont have a 32 bit mode in 640x480, then you could try 16 or 24
Global g_frameTimer
AppTitle "Noise"
g_frameTimer=CreateTimer(50)
Graphics 640,480,32,0
Dim noiseblocks(4,256)
Init()
Game()
free()
Function game()
f=0
While 1=1
If(KeyHit(1)) Exit
f=f+1
If(f>40000) Then f=0
sel=f/8 Mod 4
If(sel>4) Then
DebugLog "overflow " + sel +" :" + f
sel=4
EndIf
bgnoise(sel,BackBuffer())
LimitFPS()
Flip
SetBuffer BackBuffer()
Wend
End Function
Function bgnoise(sel,buffer)
oldbuffer=GraphicsBuffer ()
SetBuffer buffer
For y=0 To 48
If(r<0) Then r=0
For x=0 To 64
r=Int(Rand(0,100))
XX=x*10
YY=y*10
DrawBlock noiseblocks(sel,r), XX,YY
Next
Next
SetBuffer buffer
End Function
Function init()
For t=0 To 100
noiseblocks(0,t)=CreateImage(10,10)
noiseblocks(1,t)=CreateImage(10,10)
noiseblocks(2,t)=CreateImage(10,10)
noiseblocks(3,t)=CreateImage(10,10)
For x=0 To 9 Step 1
For y=0 To 9 Step 1
col1=Int(Rand(0,64))
buffer=ImageBuffer(noiseblocks(0,t))
SetBuffer buffer
Color col1,col1,col1:Plot (x,y)
col1=Int(Rand(0,128))
buffer=ImageBuffer(noiseblocks(1,t))
SetBuffer buffer
Color col1,col1,col1:Plot (x,y)
col1=Int(Rand(0,192))
buffer=ImageBuffer(noiseblocks(2,t))
SetBuffer buffer
Color col1,col1,col1:Plot (x,y)
col1=Int(Rand(0,255))
buffer=ImageBuffer(noiseblocks(3,t))
SetBuffer buffer
Color col1,col1,col1:Plot (x,y)
Next
Next
Next
SetBuffer BackBuffer()
End Function
Function free()
For t=0 To 100
FreeImage noiseblocks(0,t)
FreeImage noiseblocks(1,t)
FreeImage noiseblocks(2,t)
FreeImage noiseblocks(3,t)
Next
End Function
Function LimitFPS()
;While MilliSecs()-g_lastmilliseconds < g_FPSTIME : Wend
WaitTimer(g_frameTimer)
End Function
Oooh, I like this.
It's now mine.
For want of not hijacking I thought I'd have a go too! Mine's certainly not as sophisticated!
Graphics 640,480,0,1
SeedRnd MilliSecs()
SetBuffer BackBuffer()
gh = GraphicsHeight()
bar = 0
barspeed# = Rand(10,20)
Repeat
LockBuffer BackBuffer()
l = Rand(0,gh)
For y=0 To gh-1
For x=0 To GraphicsWidth()-1
c=Rand(0,2)
If c=0 Then col = $FFFFFFFF
If c=1 Then col = $FF888888
If c=2 Then col = $FF000000
If y>bar And y<(bar+20) And c<2 Then col = col - $FF222222
If y = l Then col = $FFFFFFFF
WritePixelFast x,y,col
Next
Next
UnlockBuffer BackBuffer()
bar = bar + barspeed
barspeed = barspeed + (Rnd(-5,5))
If bar > gh Or bar < 0 Then bar = Rand(0,gh):barspeed = Rand(10,20)
VWait
Flip False
Until KeyHit(1)
No offense chaos51, but ¿'s is better.
[edit]
and I wasn't sure about looking at the topic when I saw the title :P
And another....
You'll need this:

or something similar...
Graphics 640,480,0,1
SeedRnd MilliSecs()
SetBuffer BackBuffer()
bsod = LoadImage("bsod.png")
gh = GraphicsHeight()
roll# = 0
rollspeed# = Rand(5,10)
lock = MilliSecs() + Rand(3000,6000)
fixit = True
Repeat
If fixit Then
DrawBlock bsod,0,0
If MilliSecs() > lock Then fixit = False: lock = MilliSecs() + Rand(500,6000)
Else
Cls
l = Rand(0,20)
DrawBlock bsod,l,roll
DrawBlock bsod,l,roll-gh
LockBuffer BackBuffer()
t = Rand(0,gh-1)
th = Rand(0,gh-1)
If t+th>=gh Then th = gh-t-1
For y=t To t+th
For x=l To GraphicsWidth()-1
c=Rand(0,2)
If c=0 Then col = $FFFFFFFF
If c=1 Then col = $FF888888
If c=2 Then col = $FF000000
WritePixelFast x,y,col
Next
Next
roll = roll + rollspeed
rollspeed = rollspeed + Rnd(-5,5)
If roll > gh Then roll = roll - gh
If roll < 0 Then roll = roll + gh
If Abs(rollspeed) > 20 Then rollspeed = 0
UnlockBuffer BackBuffer()
If MilliSecs() > lock Then fixit = True: lock = MilliSecs() + Rand(500,1000)
EndIf
VWait
Flip False
Until KeyHit(1)
True... I downloaded that same pic from wikipedia. I used it an a "Is it Friday the 13th?" program :P
True ¿'s is quite cool as well, the stripes make it more real... my goal was more to have it also run on low spec machines..
¿ wins, cheers mate :)
Lets put the BSOD also in there, then its totally scary.
I didn't mean this as a competition, I simply thought it looked like a fun thing to write! Your code certainly runs on lower spec machines and is much less processor intensive.
Lets put the BSOD also in there
Here we go!
Graphics 800,600,0,1
SeedRnd MilliSecs()
SetBuffer BackBuffer()
bsod2=LoadImage("bsod.png")
gh = GraphicsHeight()
ClsColor 0,0,130
bar = 0
barspeed# = Rand(10,20)
Repeat
LockBuffer BackBuffer()
l = Rand(0,gh)
For y=0 To gh-1
For x=0 To GraphicsWidth()-1
c=Rand(0,2)
If c=0 Then col = $FFFFFFFF
If c=1 Then col = $FF888888
If c=2 Then col = $FF000000
If y>bar And y<(bar+20) And c<2 Then col = col - $FF222222
If y = l Then col = $FFFFFFFF
WritePixelFast x,y,col
Next
Next
UnlockBuffer BackBuffer()
bar = bar + barspeed
barspeed = barspeed + (Rnd(-5,5))
If bar > gh Or bar < 0 Then bar = Rand(0,gh):barspeed = Rand(10,20)
VWait
Flip False
Until GetKey()
Cls
DrawImage bsod,100,100
Flip
Delay 10000
ClsColor 0,0,0
Cls
Text 0,0, "Gotcha!"
Flip
Delay 3000
End
If you are old enough, you remember the random white noise pattern on a old TV, when no channel was found.
- My TV is only 4 years old and I get that pattern when no channel is found.....
Yo! Wazzup?: You forgot to put Flip after your DrawImage command. Also print won't work you'll need DrawTExt. Then another Flip.
That's YOUR code is it Yo? Remarkable! Our coding style is very similar.
That's YOUR code is it Yo? Remarkable! Our coding style is very similar.
:P
You know I was using your code and making it better.
Just some background info.
Actually this code is a "straight port" from my version on the C64. My first version was in assembly running on the allmighty sixy four, using the same speed-inprovements then my program does now.
However the 64 being the 64 and all, the screenres was lower, and for speed reasons, text mode was used. However in the C64, you could modify all characters to looks like a picture. So I had 256 random-noise pictures , and the c64 choose from these at random, while filling the screen..
Anyway, it actually did work pretty well on the C64.
My second version, was without programming, directly on the Amiga, using deluxe paint, and palette scrolling. I got some pretty convincing results there as well.. Costing almost no CPU power..
Just a small one:
Graphics3D 800,600,32
CreateCamera():q=CreateMesh():s=CreateSurface(q):AddVertex s,-1,1,1,0,0:AddVertex s,1,1,1,1,0:AddVertex s,1,-1,1,1,1:AddVertex s,-1,-1,1,0,1:AddTriangle s,0,1,2:AddTriangle s,0,2,3:EntityFX q,1
t=CreateTexture(256,256):b=TextureBuffer(t):SeedRnd MilliSecs()
For x=0 To 255:For y=0 To 255:If Rand(100)<60:WritePixel x,y,0,b:Else:WritePixel x,y,-1,b:EndIf:Next:Next
EntityTexture q,t
ScaleTexture t,0.45,0.45/0.75
Repeat
PositionTexture t,Rnd(0,5),Rnd(0,5)
RenderWorld
Flip 0 : Delay 25
Until KeyDown(1)
Ah thats a beauty, so few lines of code... I will definitly analyse that code...
Here is a bit longer one, and probably the last I post on this subject.... Its a bit lame, especially the style of coding, but the effect is somewhat hypnotising....
-----------------------------------------------------------
Const g_width=640
Const g_height=480
Const g_bxw=2500
Const g_bxh=2200
Const xstep=28
Const ystep=2
Dim xstepa(2)
Dim ystepa(2)
Dim noiseblocks(4,256)
Graphics g_width,g_height,32,0
SetBuffer BackBuffer()
Dim cosi3q#(g_width)
Dim sinmini4q#(g_width)
Dim cosmini4q#(g_width)
Dim cosj5q#(g_height)
Dim sinj2q#(g_height)
Dim sinminj2q#(g_height)
Dim cosminj2q#(g_height)
Dim sina#(g_height+g_width)
Dim cosa#(g_height+g_width)
For t=1 To g_width+g_height
sina#(t)=Sin(t)
cosa#(t)=Cos(t)
Next
bx#=0
by#=0
bxrc#=1.1
byrc#=1.1
Q=290
a=0
xstepa(0)=xstep
ystepa(0)=ystep
xstepa(1)=ystep
ystepa(1)=xstep
flipper=0
aa2=1
Init()
While Not KeyDown (1)
SetBuffer BackBuffer()
Q(Q,R2#,g_width,g_height,rf#,gf#,bf#)
a=a+2
If(a>360) a=0
aa2=aa2+1
If(a>360) a=0
s#=(-Cos(-a*1.5)+1)+(Cos(a*6.1)+1) * 2
s2#=(Cos(a*1.5)+1)+(Sin(-a*1.2)+1) * 2
rf#=Cos(aa2*2)
gf#=Cos(aa2*3)-Cos(a*2)
bf#=Sin(aa2*4)+Cos(a)
rf#=(rf#+1)*2
gf#=(gf#+1)*3
bf#=(bf#+1)*4
bx#=bx#+bxrc# *s2*2
by#=by#+byrc# *s *2
If(bx#>g_bxw) bx#=(g_bxw)-1 : bxrc#=-Rnd(1,4.8)
If(by#>g_bxh) by#=(g_bxh)-1 : byrc#=-Rnd(1,4.8)
If(bx#<-g_bxw) bx#=0 : bxrc#=Rnd(1,4.8)
If(by#<-g_bxh) by#=0 : byrc#=Rnd(1,4.8)
rc#=s#*32
Q=bx#
R=by#
R2#=R
R2#=R2#/200
R2#=.5+R2#
bgnoise(2,BackBuffer())
LimitFPS()
Flip
Wend
free()
Function Q(Q,P#,bw,bh,rf#,gf#,bf#)
mousewaiter=0
interlace=0
rsizeangle#=0
roffsetangle#=0
gsizeangle#=0
goffsetangle#=0
bsizeangle#=0
boffsetangle#=0
angle0step#=.3
angle1step#=.1
angle2step#=.15
angle3step#=.07
angle4step#=.12
angle5step#=.08
q=Q
For x=1 To bw Step xstep
i#=x
i#=i#*P
i3=i/3
i4=i/4
i5=i/5
cosi3q#(x)=Cos(i3+q)
sinmini4q#(x)=Sin(-(i4)+q)
cosmini4q#(x)=Cos(-(i4)+q)
Next
For y=1 To bh Step ystep
j#=y
j#=j#*P
j8=j/8
j2=j/2
j5=j/5
cosj5q#(y)=Cos(j5+Q)
sinj2q#(y)=Sin(j2+Q)
sinminj2q#(y)=Sin(-(j2)+q)
cosminj2q#(y)=Cos(-(j2)+q)
Next
For x=1 To bw Step xstep
For y=1 To bh Step yStep
i#=x
i#=i#*P
j#=y
j#=j#*P
r#=128
g#=128
b#=128
j8=j/8
j2=j/2
i3=i/3
i4=i/4
i5=i/5
cosjiq#=Cos(j+(i)+Q)
sinj8iq#=Sin((j8)+i+q)
r=Cos((j8)+i+q)+cosjiq+sinminj2q(y)+cosi3q(x)+sinmini4q#(x)+cosj5q(y)
r=(r*64)+128
g=sinj8iq+cosjiq+cosminj2q(y)+cosi3q(x)+cosmini4q#(x)+cosj5q(y)
g=(g*64)+128
b=sinj8iq+Sin(-j+(i4)+q)+sinj2q(y)+cosi3q#(x)+sinmini4q(x)+cosj5q(y)
b=(b*64)+128
r=r*rf#
g=g*gf#
b=b*bf#
If(r#>255) r#=255
If(g#>255) g#=255
If(b#>255) b#=255
If(r#<0) r#=0
If(g#<0) g#=0
If(b#<0) b#=0
Color(r#,g#,b#)
Rect x,y, xstep,ystep,1
Next
Next
End Function
Function LimitFPS()
While MilliSecs()-g_lastmilliseconds < g_FPSTIME : Wend
End Function
Function init()
For t=0 To 100
noiseblocks(0,t)=CreateImage(10,10)
noiseblocks(1,t)=CreateImage(10,10)
noiseblocks(2,t)=CreateImage(10,10)
noiseblocks(3,t)=CreateImage(10,10)
For x=0 To 9 Step 1
For y=0 To 9 Step 1
col1=Int(Rand(0,4)) * 16
buffer=ImageBuffer(noiseblocks(0,t))
SetBuffer buffer
Color col1,col1,col1:Plot (x,y)
col1=Int(Rand(0,4)) * 32
buffer=ImageBuffer(noiseblocks(1,t))
SetBuffer buffer
Color col1,col1,col1:Plot (x,y)
col1=Int(Rand(0,4)) * 48
buffer=ImageBuffer(noiseblocks(2,t))
SetBuffer buffer
Color col1,col1,col1:Plot (x,y)
col1=Int(Rand(0,4)) * 63
buffer=ImageBuffer(noiseblocks(3,t))
SetBuffer buffer
Color col1,col1,col1:Plot (x,y)
Next
Next
Next
SetBuffer BackBuffer()
End Function
Function free()
For t=0 To 100
FreeImage noiseblocks(0,t)
FreeImage noiseblocks(1,t)
FreeImage noiseblocks(2,t)
FreeImage noiseblocks(3,t)
Next
End Function
Function bgnoise(sel,buffer)
oldbuffer=GraphicsBuffer ()
SetBuffer buffer
For y=0 To 48
If(r<0) Then r=0
For x=0 To 64
r=Int(Rand(0,100))
XX=x*10
YY=y*10
DrawImage noiseblocks(sel,r), XX,YY
Next
Next
SetBuffer buffer
End Function