Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Sprite invisible color
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Insectoid




PostPosted: Fri May 02, 2008 8:30 am   Post subject: Sprite invisible color

How do you set a color of a sprite to be 'invisible'? The sprite I am using as the paintbrush in my painting program has a black background. How can I make this have the same color as my background (color is user defined)
Sponsor
Sponsor
Sponsor
sponsor
petree08




PostPosted: Fri May 02, 2008 8:42 am   Post subject: RE:Sprite invisible color

Pic.SetTransparentColor Part of Pic module

Syntax Pic.SetTransparentColor (colorNumber : int)

Description The Pic.SetTransparentColor procedure sets the color in the picture that should be considered transparent when the picture is drawn using the picMerge or picUnderMerge modes. If no color is specified, then the default background color (colorbg, usually white) is used as the transparent color.

Details This call is often used when displaying images that were originally stored as GIFs and translated into another format. Many GIFs have a transparent color that can be non-white. To use this call, you must know the color number that represents the color in the image that is to be transparent.

Example This program displays two images loaded from the same file. In the second image,the transparent color has been set to bright red (that is, the parts of the image that are meant to be transparent are in bright red).

var pic1 : int := Pic.FileNew ("airplane.bmp")
var pic2 : int := Pic.FileNew ("airplane.bmp")
Pic.SetTransparentColor (pic2, brightred)
setscreen ("offscreenonly")
for x : 100 .. maxx - 100
cls
put "The lower image has the transparent color set to bright red"
Pic.Draw (pic1, x, 150, picMerge)
Pic.Draw (pic2, x, 50, picMerge)
View.Update
delay (5)
end for

ripped from turing's help file
Insectoid




PostPosted: Fri May 02, 2008 8:53 am   Post subject: RE:Sprite invisible color

Well, Would this work with the sprite module?
The picture was originally a JPEG with a white background, but turned black when I converted to a BMP.
petree08




PostPosted: Fri May 02, 2008 11:09 am   Post subject: RE:Sprite invisible color

okay.. so

Pic.SetTransparentColor (red)

will make all red pixcels invisible regardless of what type of image you are using

and turing's Sprite moduals are gross, i'd write my own if i where you
Insectoid




PostPosted: Sun May 04, 2008 9:24 am   Post subject: RE:Sprite invisible color

Yes...er...I have no idea as to how to write my own module. I have looked at the code for several modules, and it looks very different to what I am used to coding.
TheGuardian001




PostPosted: Sun May 04, 2008 2:12 pm   Post subject: Re: Sprite invisible color

If you dont want to write your own module, you can use one thats already out there like BacchusSprite, which has a command to set the transparent colour (in bacchussprite it's BSprite.ColorBack).
Insectoid




PostPosted: Sun May 04, 2008 4:56 pm   Post subject: RE:Sprite invisible color

Of course I would like to try writing my own module! I just have no idea how that code works, and my teacher won't tell me, partly because that would constitute going into the illegal network drive, partly because he's a dink who doesn't even know what a sprite is!

Actually, he worked for IBM back when IBM made great computers. I don't think he ever got a teaching degree though...
petree08




PostPosted: Mon May 05, 2008 8:24 am   Post subject: RE:Sprite invisible color

Sprite modules aren't terribly hard to make. You basically need to load every frame in the animation into an array.

so that Pic.Draw (Frame(1) , X, Y, picMerge) will draw the first frame in your animation

you then need a frame counter and a frame rate "buffer" (for lack of a better term), when the frame buffer reaches a certain number increase the frame number and set the buffer back to 0 . When your frame number is greater than or equal to the number of frames in the animation set it back to the first frame.

I may post the sprite module i wrote for my Star Wars game sometime, with a little tutorial on how it works and how to use it.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: