Dark Bit Factory & Gravity
PROGRAMMING => General coding questions => Topic started by: Pot Noodle on February 20, 2012
-
Hi guy's, Hope you all forgive me but I am trashing my brain trying to think of the name for an old effect so I can find out a bit of info about it, It's like having an image in the background that you can't see until say you pass a font or something over it then you can see the image through the font, I remember a rainbow effect behind the font.
Just can't think what it's called as I will try and produce it in Purebasic.
Thanks for reading.
-
Hi. I hope that is the effect yu are looking for.
Watch the example i did years ago for some people that
wanted to do 64 remakes.
I mean the small Charset with the copperbars in the background.
yu can use the keys A,B,C,D for some effect changes.
The sourcecode is included aswell in Purebasic.
Yu can use it, when ever yu want.
cheers
eNeRGy
-
Thanks energy, I will have a look and get back to you.
I have had a look at your code and I was hopping to use DrawText() with screen output I have played with Alpha but no go, any ideas?
-
Stencil Vectors.
-
Stencil Vectors :o Umm.. Ok Jim I will have a look to see what I can find on the subject, Thanks
-
You're probably best of thinking of these as masking effects. I've had a look for some oldschool stencil vector stuff but can only find stenciling stuff in OpenGL.
You'd probably have a background image (or effect such as copper bars) and draw something over the top of it (spinning cube or text). Where the text or cube is, knock through and show the background.
I'm not sure of the most efficient way of doing this. You could maybe have an offscreen buffer/image that you fill black each frame and then draw your text on it in white. Then cycle through each pixel in the buffer - if the buffer pixel is white you grab the corresponding pixel (at X/Y) from the background and draw that to the screen, if the pixel is black, draw a black pixel (or a pixel from your overlay foreground image if you wanted to have a picture in the foreground rather than black).
That's how I'd implement it, might run like crap though. You might want to use dirty rectangles to speed it up. That's a way to keep track of parts of the screen that have changed each frame, so you avoid unnecessary drawing.
-
Thanks Raizor for the info, I have been playing around with this and this is what I have so far..
#XPos = 800
#YPos = 600
InitSprite()
InitSprite3D()
OpenScreen(#XPos, #YPos, 32, "")
LoadFont(0, "Topaz", 20, #PB_Font_Bold)
Img = LoadImage(#PB_Any, "back.bmp") ; The Background Image
CreateSprite(0 , #XPos+800, 100, #PB_Sprite_Texture)
StartDrawing(SpriteOutput(0)) ; --- Create a 3D Sprite to go over the Image ---
Box(0, 0, #XPos+800, 32, $1)
DrawingFont(FontID(0))
DrawText(0, 0, "THIS IS THE EFFECT I AM AFTER - THE BACK IMAGE.", 0, $1)
StopDrawing()
CreateSprite3D(0, 0)
X = #XPos
Repeat
ClearScreen(0)
StartDrawing(ScreenOutput())
DrawImage(ImageID(Img), 0, 414) ; Draw the background
StopDrawing()
Start3D()
DisplaySprite3D(0, X, 411) ; Draw the 3D Sprite
Stop3D()
X - 2
If X < - #XPos
X = #XPos
EndIf
FlipBuffers()
Until GetAsyncKeyState_(#VK_ESCAPE)
End
-
The way I did it was to have a negative bitmap font so that it is transparent where the actual character is. Then I drew a lot of lines on the background, and the scroller on top of that. That would let you see the "rainbow" where the character is and block where it is not.
-
Having taken on board what you said witch of course made sense I rewrote my code to include a negative sprite/font
then displayed my rainbow image then the transparent sprite but still I can see the image where there is no sprite
I guess I need a kind of mask for the image, Any thought's as to why this is.
Thanks
-
Ok Jim I will have a look to see what I can find on the subject
Lots of nice stencil vectors in scoopex mental hangover.
[youtube]http://www.youtube.com/watch?v=37XY28YDju4[/youtube]
Jim
-
Thanks Jim for the clip, I must say Scoopex had it sorted wish I did ??? I have a pic of what it looks like so far but I just can't work it out where I am going wrong.
-
Looks as though your 'spaces' are being rendered, which you don't want. I hope I'm giving some correct advice here... me being a newbie and all.
In your loop to render the font... (this is freebasic code)
whatcharisit = asc(scrollertext)-32 ' the -32 char offset is so you start at 'space' character
' below... if the character doesn't equal 'space' and the character is greater than char 0...
' and less than or equal to character 64 (within proper character range), then do something...
' this will stop you printing the spaces, which render a square block.
if scrollertext <> " " and whatcharisit > 0 and whatcharisit <= 64 then
'do it all here
end if
If I gave bad advice... sorry. It's looking good though Pot Noodle. :)
-
Looks like the space character in your bitmap font needs to be inversed so that it blocks out the rainbow graphics.
-
Hay guys, Managed to sort it out and am now moving on to the next problem ;D
I would just like to thank you guys for inspiration and advice, Will post when done.