[Example] New Platformer Engine -Pixel Perfect Collisions-

Learn to use DS Game Maker by Example.

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Z-Dragon » January 25th, 2013, 12:31 am

Ok. I've been looking for this code for quite literally for over 12 months but was too lazy/shy/busy to post about it.
Still alive. Still ashamed of my past behavior on these forums.
No, really. I'm sorry.

If you see me, no you don't.
Won't be on here as a participant because I have no games in mind to actively pursue and finish. Busy with multiple roleplays and writing, anyway.



_______________________________________________________________________
Current projects:

The Great and Powerful Text-Based Game
P0rtal DS (In perpetual hiatus until Sonic comes back (probably never))
User avatar
Z-Dragon
 
Posts: 254
Joined: December 23rd, 2011, 10:51 pm
Location: New Brunswick, Canada

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Nobody » January 25th, 2013, 12:41 am

You're all set! Alternatively you can make collisions with a collision map. A collision map if you don't know what it is, it is a sub background that contains a map outline for walls and such.
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Retro Ducks: viewtopic.php?f=13&t=3533 (latest)
The Living Dead 2: viewtopic.php?f=13&t=3483
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082
User avatar
Nobody
 
Posts: 2323
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Z-Dragon » January 25th, 2013, 12:47 am

I tried collision maps before, but in my opinion, it takes up space and memory if you have lots of rooms.
Still alive. Still ashamed of my past behavior on these forums.
No, really. I'm sorry.

If you see me, no you don't.
Won't be on here as a participant because I have no games in mind to actively pursue and finish. Busy with multiple roleplays and writing, anyway.



_______________________________________________________________________
Current projects:

The Great and Powerful Text-Based Game
P0rtal DS (In perpetual hiatus until Sonic comes back (probably never))
User avatar
Z-Dragon
 
Posts: 254
Joined: December 23rd, 2011, 10:51 pm
Location: New Brunswick, Canada

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Nobody » January 25th, 2013, 1:02 am

True. I prefer sprites when possible. It also allows for easier intractable maps
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Retro Ducks: viewtopic.php?f=13&t=3533 (latest)
The Living Dead 2: viewtopic.php?f=13&t=3483
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082
User avatar
Nobody
 
Posts: 2323
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Foxi4 » January 25th, 2013, 8:36 am

A collision map takes up virtually no space at all if created correctly. All you need are two tiles, if you want to be super-exact you can use six (4x diagonals, 1 transparent, 1 coloured) and the map which is small anyways. Moreover, you can create a tile-based collision system without using a collision map at all by using the appropriate tile numbers from the original bg as reference. Your only problem here is RAM, and we jumped over that hurdle back in 5.12 times.
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Buck_7 » January 26th, 2013, 3:01 am

That's not the only problem. If you do the way you suggested, the annoying problem is that your background collision map can only be 256x256 for a normal background.
User avatar
Buck_7
 
Posts: 1460
Joined: February 19th, 2011, 1:44 am

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Foxi4 » January 26th, 2013, 3:57 am

Your Collision Map can be any size - it doesn't matter, that's dictated by the Map portion of the background which isn't all that big (just a collection of char's). The biggest space-mongers are the tiles, and you only have 2 of those. ;)
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Buck_7 » January 26th, 2013, 4:30 am

I think I get it.(I misread your sentence).
I saw a post about something like that somewhere.
http://awarrior.wordpress.com/2008/09/0 ... ision-map/
This is what you mean right?
User avatar
Buck_7
 
Posts: 1460
Joined: February 19th, 2011, 1:44 am

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Bobbyloujo » January 27th, 2013, 2:59 am

That's weird. Did all the attachments on the forum get deleted when the forum went down? Here it is again for anyone who still wants it for reference.
Attachments
New Platformer Engine.dsgm
(94.5 KiB) Downloaded 421 times
Image
User avatar
Bobbyloujo
Site Admin
 
Posts: 1385
Joined: December 30th, 2010, 8:40 pm
Location: USA

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Foxi4 » January 27th, 2013, 3:44 am

@Buck
Pretty much, minus the tons of code, plus a simple map file. :P It doesn't have to be hard-coded, y'know.

The only limitation the DS has is that it can display only a given amount of tiles at a time, but that doesn't mean that your collision map has to be inactive when outside of that frame - you can check the map file contents on the fly, so yeah.

@Bobby
All the attachments were removed, yes. All the old tutorials pretty much vaporized.
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Z-Dragon » January 30th, 2013, 4:47 pm

Thanks Bobbyloujoe! I probably don't really need it at this moment, though I will use it later.

My custom crap gravity engine uses 8 objects for the blocks: Ceiling, Floor, Wall1, Wall2, NWWall, NEWall, SWWall, and SEWall.

Tell me, do sprite collisions take place with the pixels? For example, you have a pixel in the middle of a 64x64 object. If another object collided with it, would it detect collision if it touched the pixel, or the boundary? I can't test this right now, not allowed on the PC on weekdays.

Thanks!
Still alive. Still ashamed of my past behavior on these forums.
No, really. I'm sorry.

If you see me, no you don't.
Won't be on here as a participant because I have no games in mind to actively pursue and finish. Busy with multiple roleplays and writing, anyway.



_______________________________________________________________________
Current projects:

The Great and Powerful Text-Based Game
P0rtal DS (In perpetual hiatus until Sonic comes back (probably never))
User avatar
Z-Dragon
 
Posts: 254
Joined: December 23rd, 2011, 10:51 pm
Location: New Brunswick, Canada

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Foxi4 » January 30th, 2013, 5:59 pm

Tell me, do sprite collisions take place with the pixels? For example, you have a pixel in the middle of a 64x64 object. If another object collided with it, would it detect collision if it touched the pixel, or the boundary? I can't test this right now, not allowed on the PC on weekdays.


Sprite collision is based entirely on maths, collision itself depends on what kind of a mechanism you utilize. The two systems embedded in DSGM are rectangular collision and mid-point collision.

Mid-point collision draws a circle around the exact middle of the sprite - whenever two circles of two sprites intersect, collision occurs.

Rectangular collision is based on the sprite boundries - whenever the "rectangles" the sprites are on intersect, collision occurs.
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Z-Dragon » January 30th, 2013, 9:46 pm

So that's what mid-point collision was... thanks!
Still alive. Still ashamed of my past behavior on these forums.
No, really. I'm sorry.

If you see me, no you don't.
Won't be on here as a participant because I have no games in mind to actively pursue and finish. Busy with multiple roleplays and writing, anyway.



_______________________________________________________________________
Current projects:

The Great and Powerful Text-Based Game
P0rtal DS (In perpetual hiatus until Sonic comes back (probably never))
User avatar
Z-Dragon
 
Posts: 254
Joined: December 23rd, 2011, 10:51 pm
Location: New Brunswick, Canada

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Foxi4 » January 30th, 2013, 10:51 pm

Take into consideration that the radius of the circle equals 1/2 of the Width of the sprite.

Say, you have a 16px per 64px sprite, the Width is 64px so the radius of the drawn circle is 32px (As far as I know - correct me on this if I'm wrong) so depending on the sizes of sprites you're using, different collision mechanisms may work out better.

...or was it half of the shorter value? Height OR Width? I don't remember, I gotta check the source files...

In any case, it works best with relatively square-like sprites.
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: [Example] New Platformer Engine -Pixel Perfect Collision

Postby Bobbyloujo » February 15th, 2015, 3:41 am

In case anyone is looking for this example and comes across the reuploaded file, I've noticed that it may not work. Way back when James updated DSGM for some reason he removed the Layer argument from the Change Background action. This example relied on being able to choose the layer. Here is an updated version in which I replaced the Change Background action with a piece of code.

Also, the If BG Pixel Color action.
Attachments
New Platformer Engine - updated 2015.dsgm
(94.93 KiB) Downloaded 225 times
If BG Pixel Color.action
(242 Bytes) Downloaded 201 times
Image
User avatar
Bobbyloujo
Site Admin
 
Posts: 1385
Joined: December 30th, 2010, 8:40 pm
Location: USA

Previous

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron