We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › Sprites for Processing
Page Index Toggle Pages: 1
Sprites for Processing (Read 3166 times)
Sprites for Processing
Jun 22nd, 2009, 1:26pm
 
I have just released the first version of a new library that provides support for sprites in Processing. The main use of sprites is in computer games but I am sure others can find a novel use for them.

This is a simple example of what can be done with the library.

http://www.lagers.org.uk/s4p/applets/s4p_ghosts/index.html

For more information about this library please visit

http://www.lagers.org.uk/s4p/index.html
Re: Sprites for Processing
Reply #1 - Jun 22nd, 2009, 5:15pm
 
Awesome!!!  Cheesy  I'll give it a try when I get a chance.  So does this reduce the amount of vertexes required to bind an image to a point?  Usually I use a quad, but my understanding is that a sprite uses a point.  I'd like to see if I can gain performance by switching to sprites.
Re: Sprites for Processing
Reply #2 - Feb 4th, 2010, 10:37am
 
I am having issues with all my sprites being drawn semi transparently. I have given most of them a z-order of 10 and have no supplied an alpha mask file name. They are all .PNGs with some transparent pixels. Without lookin at the code or anything, do you have any idea why that might be?

*edit*

a bit more detail...my background is a jpeg. I am using the background() function to draw it before the  s4p.drawSprites method. I am drawing a bunch of "bugs" that occasionally "lay eggs". The bugs have a z order of 10 and the eggs have a z order of 5. However, it appears that the most recently created sprite will always overlap an older one, and they are all semi-transparent. I can see the background through them.

Any ideas?
Re: Sprites for Processing
Reply #3 - Feb 4th, 2010, 11:09am
 
The z-ordering is my fault in that I started to implement it in the library and then got sidetracked and forgot. Hopefully I will be able to fix it tonight and upload it to my website. I will keep you posted on that.
Cry

I believe png supports 2 types of transparency
1) colour pallette transparency: this is used in images that have a fixed number of colours usually 256 where one (and only one) of the colours is used to represent fully transparent pixels.
2) pixel level transparency - for 32 bit graphics (ARGB) where the 4 bytes represent alpha/red/green/blue

I don't know where you got the graphics from or whether you created them yourself but I suspect your images are of the second kind and they have some alpha value other than 255.

I have an old version of Paint Shop Pro that will only create the first type, but I have downloaded images that exhibit variable transparency so I think I am right here where did you get the images?


Re: Sprites for Processing
Reply #4 - Feb 4th, 2010, 11:34am
 
That's good news about the z-ordering. I realized that I'm messing up the transparency of my images in GIMP. I've never really used GIMP, so when I saw that it has a "color to alpha" feature, I used it. I didn't zoom in close enough to notice that it was not only making all of the selected pink transparent, but also making everything else semi-transparent.

*edit*

figured out a better way to handle transparency that is working for me now. Now I just need the z-ordering and I think I'll be up and running  Smiley.
Re: Sprites for Processing
Reply #5 - Feb 4th, 2010, 1:03pm
 
@Keaton_R
The library has been updated to implement Z ordering correctly.

OPEN TO ALL : AN INVITATION TO CONTRIBUTE

At present I don't have time to create new examples for this library and the ones included with the library are fairly complex for newbies so if you make an interesting example I would be happy to include it in the library and/or host it on the library website. You would be given full credit for the example and I would create a link from the website example to your own website if you wish.

The only conditions are that
(1) The example clearly demonstrate the library's features
(2) Well commented to make it suitable for newbies to learn from

I also make the same offer for my other libraries
G4P
Shapes3D

Cheesy
Re: Sprites for Processing
Reply #6 - Feb 4th, 2010, 1:51pm
 
Hey Quark, does your library support Billboarding? i believe it doesnt, right? this is a feature i miss so much recently. So if you ever have some time and want to add some more features i believe this is something alot of people could need, especially in games too
Re: Sprites for Processing
Reply #7 - Feb 4th, 2010, 7:26pm
 
Quark, I was wondering if you could add in some methods to check whether or not a sprite collides with a point (an x and y coordinate). I need to be able to check whether I am touching a sprite on a touch-screen device, so the mouse events don't help. I need to be able to provide the x and y coordinate of where I'm touching the screen to the sprite class so that the sprite can tell me whether or not I'm touching it.

I made a weak attempt at doing this myself before I realized I was going to have to learn the process of exporting the source to the jar file  Undecided
Re: Sprites for Processing
Reply #8 - Feb 5th, 2010, 1:27am
 
isnt that already part of the library ?

http://www.lagers.org.uk/s4p/applets/s4p_showcase/index.html

click on "show collision area"...
Re: Sprites for Processing
Reply #9 - Feb 5th, 2010, 4:21am
 
The discussion has moved on from the initial announcement of the Sprites library so rather than hog the Exhibition thread I have responded in the Other Libraries section.

With regard to the Sprites library and touch screen devices the discussion continues here

As to billboarding I assume that this is for the Shapes3D library and that continues here

Re: Sprites for Processing
Reply #10 - Feb 5th, 2010, 4:27am
 
Ah Smiley i was confused
Re: Sprites for Processing
Reply #11 - Apr 6th, 2010, 6:46pm
 
Yeah completely new to this, im really liking the idea behind the library, but im kinda clueless how to use it, can anyone throw up some source code of a simple side scroller? it would help a lot.  Smiley
Page Index Toggle Pages: 1