It is currently Thu Jan 17, 2019 7:06 pm

 All times are UTC - 7 hours

 Page 2 of 2 [ 20 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
Author Message
 Post subject: Posted: Fri Dec 19, 2008 3:08 pm

Joined: Mon Sep 27, 2004 2:57 pm
Posts: 1258
Try using a collision system which uses the bottom corner points, and a movable point in between the corner points.

The idea is that the movable point defaults to the center between the two corner points, and you'll mostly be using the movable point to determine if the entity is on the ground or not.

If the movable point is on the ground, then the entity is on the ground, regardless of the corner points.

If the movable point is off the ground, but both of the corner points are on the ground, then you're on the ground, just too wide to fall through whatever gap is there.

If the movable point is off the ground, but just one of the corner points is on, then you're either floating over a slope, or you're stepping off of a ledge. The way you tell is by checking up to x amount of pixels underneath the movable point. If there's something solid under the point, within that tolerance, then you can simply reposition the entity on the ground, relative to the movable point.

If there's nothing under the movable point within the tolerance, then you slide the movable point towards the corner that still registers a collision, until the point is over the ledge, and you basically just glue the point to that edge, until you move in a way that the corner point moves off the ledge too, because that's when you fall.

If you walk back towards the ledge, rather than away from it, then once the movable point is back in the center of the entity, you unglue it from the ledge and you go back to repositioning the entity on top of the slope.

Hope this makes sense, I kinda had to think back to my TGF and MMF days to come up with it.

Top

 Post subject: Posted: Sat Dec 20, 2008 4:00 am

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7648
Location: Chexbres, VD, Switzerland
Quote:
Did you catch the part where I said this will only work for a specific sprite width? This is indeed the simplest solution, and might work well for the player, but once I have a huge enemy, like, 3 times wider than the player, walk on the same slope, things will look weird. Also, consider tiny items that might end up completely below the floor line.

Oh you are right. But after all, even if a signle corner would touch the slope, that wouldn't happear so weird. I looked at Gimmick and it seems to be like that. The collision window is typically slightly smaller than the area the sprite takes, so anyway some part of the sprite will be inside the slope and this won't look that weird.

Also, if the middle of the player is out of the cliff and that it falls, it won't look werid either. That's how actual physics woks in fact ! But yeah if half of your players goes into a wall it will look weird, unless you use minor pseudo-3D with oblique projection like Double Dragon or some Battletoads levels to hide that.

Top

 Post subject: Posted: Sun Dec 21, 2008 10:10 am

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11090
Location: Rio de Janeiro - Brazil
Drag wrote:
Try using a collision system which uses the bottom corner points, and a movable point in between the corner points.

I believe your idea is the most interesting so far, because it looks like it could work without the need for special blocks and other "hacks".

I'm still thinking of as many aspects of it as I can, as there is another complicated case I haven't talked about before: landing on a ledge. When a character is falling and hits a ledge, it might be difficult to place it the same as if it walked up to that point. I believe that with your technique this is possible though, I just have to give it some more thought. Thanks for the idea!

Top

 Post subject: Bkg slope/char interactionPosted: Sun Dec 21, 2008 12:43 pm

Joined: Tue Sep 02, 2008 12:43 pm
Posts: 32
I've got the same exact issue with sloped tiles in my project as well. I've also got a lookup table per character type for the y height per x value. I'm going for a slope tile system something like the arcade version of strider.

So far what I'm doing is having a single floor detection point (F) on the center base of the character, and then two wall detection points (W) 12 pixels over, and 16 pixels up on either side. The character can slide down walls and wall jump like Megaman X.

I have a single ceiling detect point on the head about 48 pixels above the base as well (C). My character is 56 pixels tall, and between 16-24 chars wide. The ceiling detect point is used to zero out Y velocity when a solid tile is hit when jumping up. Eventually I want to have ceiling hang/grapple.

Code:

C

W      W

F

I just accepting that the character can overlap the wall in the wall for a small amount of time and I think I'll add a push away amount for cases where the character is too far inside the wall.

To make sure the character doesn't get trapped inside a wall what I do is that if the floor detection point is inside a totally solid wall, I move the character up to the ground plane of the tile above it. (My scroll speed in limited to 8 pixels at a time in H or V).

Wall detect points only prevent horizontal motion with totally solid tiles, not sloped tiles. So far, I haven't been able to get my character stuck inside a wall section unless I design my level/metatiles in a certain nefarious way.

Also, I've got a "floor magnet" type effect so that my character sticks to the ground when going down an up to 45 degree slope.

Steep slopes (2 tiles over, 1 tile up) I'm still working out a way to handle them.

I think a lot of the decisions made for terrain detection points and code comes down to personal preference and speed vs accuracy tradeoffs. I'm erring more on the speed side. There isn't really a "right" way to do it.. only a "right for the given project" way.

Top

 Post subject: Posted: Sun Dec 21, 2008 1:02 pm

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11090
Location: Rio de Janeiro - Brazil
I had an idea you might find interesting. It does involve block types and it has its limitations, but if the blocks are small enough (good old 16x16 pixels should be fine), this should not be a big deal. OK, say I want my floor to look like this:

If I use 2 major block types (solid = dark, detailed = light), I could draw it like this:

Solid blocks make the basic shape and the detailed ones "decorate" it, making it look closer to what we actually want. All I have to do then is collide with each type of block in a different way: solid blocks use the whole area between the 2 hitbox corners, while detailed blocks only care about the central point.

Whenever the entity walks towards the ledge, once it's off the detailed block it will start colliding with the solid block below, behaving like Mega Man X (SNES) and Pugsley's Scavenger Hunt (NES).

The main limitation is that slopes must end perfectly aligned to the grid. This should not be obvious to the player/user, who usually does not know about any grids. I'm leaning towards coding it like this because it seems really simple, and the limitations are not that bad.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 2 of 2 [ 20 posts ] Go to page Previous  1, 2

 All times are UTC - 7 hours

#### Who is online

Users browsing this forum: No registered users and 2 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