Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 4th Aug 2010 16:02 Edited at: 4th Aug 2010 16:05
Hi, I'm working on pixel collision and I do this by hiding all other sprites other than the ones that I'm checking. Then I used the point command to return if any pixel values changed on the boarder of my sprite. However the point command isn't returning any other color other than black. Does the point command even work on sprites or will I have to use the get image command and then check.

Hears my collision function.
The sprite collisionblank is used to cover up all other sprites.


If it hasn't exploded yet, I haven't touched it.
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 4th Aug 2010 16:06
That won't work because sprites don't update as you hide/show them, they only update in the 'sync', so hiding and then showing a sprite will have no affect on the pixels in the backbuffer.

Also, point is very slow so don't bother using it.

[b]
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 4th Aug 2010 16:10 Edited at: 6th Aug 2010 18:11
Oh darn. I was basing that collision off something I wrote in C++. Because in C++ using SDL library doesn't need the images to be rendered to check pixel color.
Anyways, how could I get pixel collision fast without using any plugins?

EDIT:
Well I decided to use memblocks and being that I've never used them before, I have a good understanding of them. However my code doesn't detect colors in the image which is quite odd.



My computer can render anything no matter the complexity of it in real time.
The memory is enormous. My computer is unique to everyone else’s. What computer do I have?

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 6th Aug 2010 18:11
Anyone?
I really need this fixed for my platformer.

My computer can render anything no matter the complexity of it in real time.
The memory is enormous. My computer is unique to everyone else’s. What computer do I have?

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th Aug 2010 19:06
I think there is a pixel perfect collision example in the codebase, and you will certainly find one if you search the forum.

However, if you don't mind the extra setup, line based collision will give you much better performance and flexibility

To do line based collision, you describe each collision shape as a set of points. If you connected up these points in order with lines it would draw the outline of your collision shape.

When you want to test for collision between two objects, you test all of the lines in the first shape against all of the lines in the second. If a line from one intersects a line from the other there is a collision.

All you need to do this is a line intersection algorithm, and I imagine you can find one of those in the codebase.

[b]
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 6th Aug 2010 19:20
Well that won't work for what I'm doing. I have to check for collision for an entire image which my is level and see if my player is touching a wall or floor. The player is constantly inside the level image. So the easiest way would be to check eight points around the player on the level image and see if they equal anything other that the alpha background. Then I will have collision if it isn't alpha detected.

My computer can render anything no matter the complexity of it in real time.
The memory is enormous. My computer is unique to everyone else’s. What computer do I have?

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 9th Aug 2010 05:28 Edited at: 9th Aug 2010 05:30
Everyone says point is slow but I have used it to reasonable effect in stuff. Trick is not to overuse it. I make a mask of the sprites I want to check against and paste it to a hidden screen. I use that screen to check for my point collisions. You may be able to do something similar with memblocks, but not tried that myself. Oh, and no the point command doesn't work with sprites just images.

http://s6.bitefight.org/c.php?uid=103081
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 9th Aug 2010 06:23
Quote: "Everyone says point is slow but I have used it to reasonable effect in stuff. Trick is not to overuse it. "


I feel the same way about POINT.

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 10th Aug 2010 23:58
Together with a fellow coder, I have been working on a shoot em up editor. To test it I have started recreating a few levels off R-Type. The engine uses point for all of its collision in the main, and works at a very nice speed. So I whole heartedly recommend POINT.

http://s6.bitefight.org/c.php?uid=103081
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 15th Aug 2010 22:40
But point command is a lot slower then using memblocks. See my example:


My computer can render anything no matter the complexity of it in real time.
The memory is enormous. My computer is unique to everyone else’s. What computer do I have?

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 15th Aug 2010 22:54
Yeah your right. You've converted me with your excellent example.

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 17th Aug 2010 03:22
Ok, lol that is faster, but to some may seem complicated. You are calling point every loop which is exactly what I said to avoid lol. For instance.

Modifying your code so that it checks when you click and only when you click, makes the code pretty much the same as using memblocks. Dependant on what you need the collision for, it is perfectly acceptable to use the point command. But I do see that the memblock technique is ultimately the fastest method

http://s6.bitefight.org/c.php?uid=103081
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 17th Aug 2010 05:39
Well I finally got memblocks to work for my collision but thanks for the help anyway.
The reason it wasn't working was because I forgot to set the transparecy flag for paste image to 1 and that was the image collision was checked against.

My computer can render anything no matter the complexity of it in real time.
The memory is enormous. My computer is unique to everyone else’s. What computer do I have?

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Aug 2010 04:39
There's an alternative to using point:



Might have the pointer symbol wrong, I can't remember for sure. No clue if it's any faster than using the point command.


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke

Login to post a reply

Server time is: 2026-07-24 20:35:34
Your offset time is: 2026-07-24 20:35:34