Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
19 June, 2013, 14:25:50 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: Pixel perfect collision testing -  (Read 655 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Yeong
Eternally Young Scarlet Moon
LV12 Extreme Poster (Next: 5000)
************
Offline Offline

Gender: Male
Last Login: Today at 00:24:25
Date Registered: 15 October, 2010, 04:29:49
Location: Arden, NC
Posts: 3705


Topic starter
Total Post Ratings: +260

View Profile
« on: 09 March, 2012, 01:58:13 »
0

I'm just wondering if it's possible with axe bitmap or sprite or stuff.
I have no idea where to start from. help?
« Last Edit: 09 March, 2012, 01:58:34 by TBO_Yeong » Logged

Project Redemption....

My project progresses:HERE
My Pastebin stuffs:HERE
Check your rate: HERE
My Animations: HERE
Spoiler for Images :D:

ノ◕ヮ◕)ノ:・゚ PENGUIN WAVE!!:„ø¤º°¨ ¨°º¤KEEP THE PENGUIN GOING ¸„ø¤º°¨ ¨°º¤øº LETS GO PENGUIN !¤¤º°¨¨°º¤øº¤ø„¸¸ø¤º°¨„ ø¤º°¨¨°º
parserp
Hero Extraordinaire
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 28 May, 2013, 02:33:36
Date Registered: 08 September, 2011, 02:01:43
Location: Here.
Posts: 1421


Total Post Ratings: +80

View Profile WWW
« Reply #1 on: 09 March, 2012, 01:59:56 »
0

You could always do it the HARD way like I did in swords. Tongue


1
If X>stuff and X<stuff and Y>stuff and Y<stuff
Logged

ticalc.org | Cemetech | TI-Freakware | casiocalc.org

My New Website!
Spoiler for The Rest:



A useful tool
Spoiler for bands:
Five Finger Death Punch
Disturbed
Slipknot
Linkin Park
Avenged Sevenfold
Breaking Benjamin
Skillet
30 Seconds to Mars
Yeong
Eternally Young Scarlet Moon
LV12 Extreme Poster (Next: 5000)
************
Offline Offline

Gender: Male
Last Login: Today at 00:24:25
Date Registered: 15 October, 2010, 04:29:49
Location: Arden, NC
Posts: 3705


Topic starter
Total Post Ratings: +260

View Profile
« Reply #2 on: 09 March, 2012, 02:00:24 »
0

but... what if sprite is complicated and it's 24x16?
Logged

Project Redemption....

My project progresses:HERE
My Pastebin stuffs:HERE
Check your rate: HERE
My Animations: HERE
Spoiler for Images :D:

ノ◕ヮ◕)ノ:・゚ PENGUIN WAVE!!:„ø¤º°¨ ¨°º¤KEEP THE PENGUIN GOING ¸„ø¤º°¨ ¨°º¤øº LETS GO PENGUIN !¤¤º°¨¨°º¤øº¤ø„¸¸ø¤º°¨„ ø¤º°¨¨°º
LincolnB
Check It Out Now
LV9 Veteran (Next: 1337)
*********
Offline Offline

Gender: Male
Last Login: 20 May, 2013, 05:36:22
Date Registered: 02 May, 2011, 00:56:28
Location: Utah Valley
Posts: 1114


Total Post Ratings: +121

View Profile
« Reply #3 on: 09 March, 2012, 02:01:30 »
0

Do you remember the engine I posted in the Seeker thread a while ago? Probably not, well anyways here it is:

http://www.omnimaga.org/index.php?topic=11789.msg215938#msg215938

^^That basically has pixel perfect collisions, it's not tilemap based like most. However, the source is moderately ugly and inelegant - for example I toyed around with weird stuff like 8x inflation and the like.
Logged

Completed Projects:
   >> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
   >> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.


Spoiler for Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)


Yeong
Eternally Young Scarlet Moon
LV12 Extreme Poster (Next: 5000)
************
Offline Offline

Gender: Male
Last Login: Today at 00:24:25
Date Registered: 15 October, 2010, 04:29:49
Location: Arden, NC
Posts: 3705


Topic starter
Total Post Ratings: +260

View Profile
« Reply #4 on: 09 March, 2012, 02:37:53 »
0

But the problem is that the sprite will be going through another sprite, not just a boundary. Big frown Also, the sprite is not "boxy".
That's why I'm having some problem.
Logged

Project Redemption....

My project progresses:HERE
My Pastebin stuffs:HERE
Check your rate: HERE
My Animations: HERE
Spoiler for Images :D:

ノ◕ヮ◕)ノ:・゚ PENGUIN WAVE!!:„ø¤º°¨ ¨°º¤KEEP THE PENGUIN GOING ¸„ø¤º°¨ ¨°º¤øº LETS GO PENGUIN !¤¤º°¨¨°º¤øº¤ø„¸¸ø¤º°¨„ ø¤º°¨¨°º
nxtboy III
LV8 Addict (Next: 1000)
********
Offline Offline

Last Login: 22 May, 2013, 02:53:41
Date Registered: 30 March, 2011, 22:57:58
Posts: 784


Total Post Ratings: +23

View Profile WWW
« Reply #5 on: 09 March, 2012, 04:05:10 »
0

is there pxl-test in Axe?
Logged

parserp
Hero Extraordinaire
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 28 May, 2013, 02:33:36
Date Registered: 08 September, 2011, 02:01:43
Location: Here.
Posts: 1421


Total Post Ratings: +80

View Profile WWW
« Reply #6 on: 09 March, 2012, 04:05:28 »
0

is there pxl-test in Axe?
indeed.
Logged

ticalc.org | Cemetech | TI-Freakware | casiocalc.org

My New Website!
Spoiler for The Rest:



A useful tool
Spoiler for bands:
Five Finger Death Punch
Disturbed
Slipknot
Linkin Park
Avenged Sevenfold
Breaking Benjamin
Skillet
30 Seconds to Mars
nxtboy III
LV8 Addict (Next: 1000)
********
Offline Offline

Last Login: 22 May, 2013, 02:53:41
Date Registered: 30 March, 2011, 22:57:58
Posts: 784


Total Post Ratings: +23

View Profile WWW
« Reply #7 on: 09 March, 2012, 04:08:12 »
0

Huh?
Then why not use that for pixel-perfect collision?
Logged

parserp
Hero Extraordinaire
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 28 May, 2013, 02:33:36
Date Registered: 08 September, 2011, 02:01:43
Location: Here.
Posts: 1421


Total Post Ratings: +80

View Profile WWW
« Reply #8 on: 09 March, 2012, 04:09:45 »
0

I'M not sure if TBO wants collisions like player movement, or collisions with the map, such as spikes, etc.
Logged

ticalc.org | Cemetech | TI-Freakware | casiocalc.org

My New Website!
Spoiler for The Rest:



A useful tool
Spoiler for bands:
Five Finger Death Punch
Disturbed
Slipknot
Linkin Park
Avenged Sevenfold
Breaking Benjamin
Skillet
30 Seconds to Mars
Yeong
Eternally Young Scarlet Moon
LV12 Extreme Poster (Next: 5000)
************
Offline Offline

Gender: Male
Last Login: Today at 00:24:25
Date Registered: 15 October, 2010, 04:29:49
Location: Arden, NC
Posts: 3705


Topic starter
Total Post Ratings: +260

View Profile
« Reply #9 on: 09 March, 2012, 04:15:24 »
0

sprite vs sprite.
detects collision if even 1 pxl is crossed
Logged

Project Redemption....

My project progresses:HERE
My Pastebin stuffs:HERE
Check your rate: HERE
My Animations: HERE
Spoiler for Images :D:

ノ◕ヮ◕)ノ:・゚ PENGUIN WAVE!!:„ø¤º°¨ ¨°º¤KEEP THE PENGUIN GOING ¸„ø¤º°¨ ¨°º¤øº LETS GO PENGUIN !¤¤º°¨¨°º¤øº¤ø„¸¸ø¤º°¨„ ø¤º°¨¨°º
chattahippie
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: 27 March, 2013, 05:21:38
Date Registered: 19 July, 2011, 04:13:49
Location: Somewhere
Posts: 358


Total Post Ratings: +27

View Profile
« Reply #10 on: 09 March, 2012, 04:21:44 »
0

How about checking to see if your sprites are within distance of each other

If {2nd sprite location} - {1st sprite's location} < 16 (or whatever number)
Do Stuff
End

Or

If {1st sprite location} + (sprite size) >= {2nd sprite location}

Would those work?
Logged
nxtboy III
LV8 Addict (Next: 1000)
********
Offline Offline

Last Login: 22 May, 2013, 02:53:41
Date Registered: 30 March, 2011, 22:57:58
Posts: 784


Total Post Ratings: +23

View Profile WWW
« Reply #11 on: 09 March, 2012, 04:21:54 »
0

So just add another buffer for different types of pixels, like a spike pixel, etc

EDIT: Why not do this: http://www.omnimaga.org/index.php?topic=12834.0
« Last Edit: 09 March, 2012, 04:31:15 by nxtboy III » Logged

Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 31 May, 2013, 10:48:29
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Total Post Ratings: +1019

View Profile
« Reply #12 on: 16 March, 2012, 12:41:10 »
0

This is an odd solution, but it might be fast enough to work.  Consider the following situation:  Your foreground layer is white everywhere there is no collision, and dark everywhere that you can collide, this is before the player is drawn of course otherwise there would always be a collision.  Now, do a pt-get() on the location you plan on drawing the sprite.  You can now scan this region R and the original sprite S and if ever the boolean operation "S and R" is true, you have a collision!  Here is some sample code:


1
2
3
4
5
6
7
8
9
10
:.Example use
:CHECK(X,Y,Pic1)

:Lbl CHECK
:pt-Get(r1,r2)->R
:For(A,0,7)
:  ReturnIf {R+A} and {r3+A}
:End
:Return 0

This can be optimized slightly, but this should make clear what is going on in the code.  Keep in mind this code only works assuming my original condition.  You might have to use another buffer for the sprite "collision masks" if you are already double buffering prior to spriting.
« Last Edit: 16 March, 2012, 12:43:54 by Quigibo » Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
Xeda112358
Xombie. I am it.
Coder Of Tomorrow
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Last Login: Yesterday at 21:03:28
Date Registered: 31 October, 2010, 08:46:36
Location: Land of Little Cubes and Tea, NY
Posts: 3781


Total Post Ratings: +614

View Profile
« Reply #13 on: 16 March, 2012, 14:42:13 »
0

Here is another method I have been discussing quite often over the past few days and made an example of. It is what Quigibo mentioned in his last few lines, so here is what it looks like... If you have room for another buffer, you will want to draw sprites twice-- once on the viewable buffer and again on the "collision" buffer. For example, if I draw this sprite on the buffer shown on the LCD:

Then I want to draw the hit-box region on the other buffer:


Now all you do for collision is pxl-Test( on that buffer. So here I will pause to explain why this is better:

Say you have a huge monster or kill zone that is like a circle bigger than your sprite. Now say you go inside that area and pixel test for collision-- you will get nothing. However, with that idea above, you will just fill in the hit region with pixels on.
This method can also be applied to creating several layers such as a collision buffer, killzone buffer, warping buffer, et cetera-- and it works quickly.
Also, there are times where you will want a collision zone that does not necessarily have pixels shown. Since the other buffer is not displayed, you are fine Smiley

Finally, here is an example (sorry, it isn't in Axe, but it is the same concept):
« Last Edit: 16 March, 2012, 14:47:10 by Xeda112358 » Logged



Grammer Download (2.29.04.12)
Latest update (possibly incomplete)
My pastebin
Spoiler for FileSyst:
FileSyst is an application that provides a folder and filesystem for the TI-83+/84+ calculators. It is designed to be easy to access and use in BASIC, and it can be used to access game files and save data, or to create a command prompt, among other things:

Spoiler for Graphiti:
This is a graph explorer for graph theory. It will require lots of work to finish. Currently you can:
Add/delete vertices
Add edges (direction not shown, but they are directed)
Arrange vertices in a circle (in the future, you will be able to define levels of rings and the number of nodes in each)
Create complete graphs quickly

Plans:
Add adjacency matrix viewer
Deleting edges
Multiple graphs support
Arrows for directed graphs
Planarity testing
Matrix operations
Weighted edges
Chromatic polynomials
Chromatic numbers

Spoiler for Stats:

Samocal             [o---------]
Virtual Processor   [o---------]
EnG                 [oo--------]
Grammer             [ooo-------]
AsmComp             [ooo-------]
Partex              [oooo------]
BatLib              [oooooooo--]
Grammer82           [----------]
Grammer68000        [----------]


Pseudonyms:  Zeda, Xeda, Thunderbolt
Languages:   English, français
Programming: z80 Assmebly
             Grammer
             TI-BASIC (83/84/+/SE, 89/89t/92)
Known For:   -Creator of the Grammer programming language
              (Winning program of zContest2011)
             -BatLib- One of the most feature packed libraries for BASIC programmers available
              with over 100 functions and a simple programming language
             -Learning to program z80 in hexadecimal before using an assembler (no computer was
              available!)
╔═╦╗░╠═╬╣▒║ ║║▓╚═╩╝█


hellninjas
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: 31 May, 2013, 02:16:24
Date Registered: 12 May, 2011, 02:15:30
Location: USA
Posts: 617


Total Post Ratings: +17

View Profile
« Reply #14 on: 16 March, 2012, 20:59:45 »
0

Do you remember the engine I posted in the Seeker thread a while ago? Probably not, well anyways here it is:

http://www.omnimaga.org/index.php?topic=11789.msg215938#msg215938

^^That basically has pixel perfect collisions, it's not tilemap based like most. However, the source is moderately ugly and inelegant - for example I toyed around with weird stuff like 8x inflation and the like.
This helped me a bit, but i read parser's post :| (sorry!)
Anyways, how would you also do left, right, and above the sprites check?
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.468 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.