News:

Function Finder  Find all the functions within source code files

Main Menu

SpriteCollisionMode sprite#,3

Started by Ian Price, January 09, 2006, 06:27:46 AM

Previous topic - Next topic

Ian Price

Is it me of does SpriteCollisionMode sprite#,3 (pixel perfect collision) not work?

I always get an error - "Shape number out of legal range" Error #500.

I've tried changing the value on the demos too, and always get the same error.


I need to have pixel perfect collision in my game, and I just can't get it to work.

Any thoughts?

[EDIT] Just discovered that I might need to use "ImageShape" to get this to work - I'll try this out later.
I came. I saw. I played some Nintendo.

kevin

Yes,  shape mode uses the Vector Shape assigned to the image as the 'Hard region' of that sprite.  It's up to you to define the shape and assign it to the image.  Which is noting more than a wire frame outline really.  

Been meaning to write a shape editor for this purpose for ages, but haven't got around to that yet.  Like a million other things. :(

Digital Awakening

Kevin:
Would it be too slow to implement per pixel collision? What about a setting to change the accuratcy?
Wisit my site at: DigitalAwakening.net

kevin

Yes, across the board it's too slow.  While  it can be done in certain situations, it's loaded with problems.   In particular future problems (ie. DX9 )..  Now you can mask two video memory images together today.  It's about the same speed of drawing the smaller image,  but kicker is you can't rotate/scale them.

 The same applies to FX images, masking them together means drawing them (comparing spans),  scaled or not (which certainly would be quicker). But since there's pixel reading involved, you couldn't mask an fx image to video image or vise versa.  As reading video memory is just too slow on PC..  

 Hence, vector collision.

Ian Price

#4
So how exactly do you define a shape and assign it to an image?

If I use say ImageShape 1,1 then I have to use a shape previously set up using the CreateConvexImage 1,Size, No. of points.

Or am I wrong?

How would this make my sprite have pixel perfect collision as it's only a geometric shape?

How can I make a more complex shape have pixel perfect collision, or is it just not possible?
I came. I saw. I played some Nintendo.

kevin

QuoteHow would this make my sprite have pixel perfect collision as it's only a geometric shape?

 Make a shape that fits the 'hard' part or parts of the require image(s).  How perfect the result is, stems from how well the shape matches the image data.


QuoteHow can I make a more complex shape have pixel perfect collision, or is it just not possible?

 see > CreateShape

 Define a vert list,  connect edges to form shape, then attach to image

 Shapes can be convex, concave or complex.

Ian Price

Cheers :D

I shall have a looksee straight away.
I came. I saw. I played some Nintendo.

Digital Awakening

Can vector based software be used like Illustrator or Freehand? I don't remember if Photoshop can export vector graphics. Oh, and there are some image to vector converters those would be useful if PB supprts the formats.
Wisit my site at: DigitalAwakening.net

kevin

Not that i can think of (been meaning to write a simple outliner), but if you find something, then  that'd be a much easier solution.

medwayman

QuoteBeen meaning to write a shape editor for this purpose for ages, but haven't got around to that yet. Like a million other things. sad.gif
Do you plan to make one any time soon?

I'm asking because I'm thinking about doing one myself.

kevin

Yeah, I'll prolly have a crack at something after the PlayMapper thing. But don't let that stop you !..

 I'm actually messing around with a few ideas ATM to trace the outline of image.   But sadly i'm not having much luck.

medwayman

But wouldn't a tracer create far more vertexes than was needed for the job? I was thinking about something that allows the user to draw the shape by hand and not just for sprites for levels too.

kevin

Yes certainly, for the best (fastest) results, by hand is the only way the go. Which is what our editor will do also.

The tracer routine would ideally be used to first get the outline in high detail.. Then merge similar edges to reduce the vert/edge count. The user could (in theory if this all works) do this various times to scale down the detail.  The quality would certainly get a bit iffy though.. But ya get that..And they really don't have to be perfect.

medwayman

QuoteThe tracer routine would ideally be used to first get the outline in high detail.. Then merge similar edges to reduce the vert/edge count. The user could (in theory if this all works) do this various times to scale down the detail.
Sounds like a good idea good luck with it  :)

Maybe I'll still do something. I just fancied doing an app of some kind. Doesn't necessarily have to be a shape editor, but couldn't think of anything specific to PlayBasic that people would need. Just don't think I could handle doing another game straight away, not after the nightmare that is my current project! lol

kevin

It's sorta working for simple box images.   Should just be matter of tweaking the pen cases.  Nothing flash mind you, just enough to get it done.

 I still think a shape editor would be a very useful project though.  The more options/take on the problem then better.

 But you could also, have a go at building a world editor Or perhaps a sprite editor even.