It is currently Mon May 22, 2017 10:34 am

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Feb 23, 2017 6:07 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2129
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
 Profile  
 
PostPosted: Thu Feb 23, 2017 7:27 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5163
Location: Canada
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
 Profile  
 
PostPosted: Fri Feb 24, 2017 12:57 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2129
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
 Profile  
 
PostPosted: Fri Feb 24, 2017 3:26 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18332
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
 Profile  
 
PostPosted: Sat Feb 25, 2017 6:33 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2129
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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: thefox and 8 guests


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group