It is currently Thu Apr 19, 2018 4:26 pm

 All times are UTC - 7 hours

Forum rules

Related:
• For making cartridges of your Super NES games, see Reproduction.

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Should I change how I do BG collision detection?Posted: Thu Feb 23, 2017 6:07 pm

Joined: Wed May 19, 2010 6:12 pm
Posts: 2603
So far I've done it where the BG collision routine itself moves the sprites because it needed to know which where the sprites are comming from.

Because of this, everything that uses BG collision has to be controlled by it's velocity. For certain types of sprites this works out nicely, but for other types (such as rotating joints) it ends up making the code into an unreadable mess.

I think it would make sense if I saved the coordinates before I move them, and jumped to the collision routine after moving it. Is this how other's do it?

Top

 Post subject: Re: Should I change how I do BG collision detection?Posted: Thu Feb 23, 2017 7:27 pm

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6202
I do movement collisions with 2 pieces of input data, 1. an X/Y point, 2. the direction of motion. The collision result returns how many pixels to move the point back (opposite of motion direction) to escape collision, 0 if no collision.

Something like this:
Code:
x = x + velocity_x;
if (velocity_x > 0) { x -= collide_tile_right(x,y); }
if (velocity_x < 0) { x += collide_tile_left(x,y); }

y = y + velocity_y;
if (velocity_y > 0) { y -= collide_tile_down(x,y); }
if (velocity_y < 0) { y += collide_tile_up(x,y); }

Top

 Post subject: Re: Should I change how I do BG collision detection?Posted: Fri Feb 24, 2017 12:57 pm

Joined: Wed May 19, 2010 6:12 pm
Posts: 2603
For pass-through tiles, do you just have the character snap to the platform if it's close to it, when moving downward, or do you do it the trickier way and actually detect if it was previously above it?

Top

 Post subject: Re: Should I change how I do BG collision detection?Posted: Fri Feb 24, 2017 3:26 pm

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19919
Location: NE Indiana, USA (NTSC)
The walker movement code in The Curse of Possum Hollow tests whether a walker is in the top 8 pixels of a pass-through platform and with a downward velocity. If so, it zeroes the velocity and moves the walker upward. Dropping through a platform is done by ignoring pass-through platforms for a quarter second.

Top

 Post subject: Re: Should I change how I do BG collision detection?Posted: Sat Feb 25, 2017 6:33 pm

Joined: Wed May 19, 2010 6:12 pm
Posts: 2603
Got done rearranging the collision detection so now I can move sprites in any way that is convenient, just as long as I save the old coordinates before moving the sprite.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 5 posts ]

 All times are UTC - 7 hours

Who is online

Users browsing this forum: No registered users and 9 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki