Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411595 Posts in 69386 Topics- by 58445 Members - Latest Member: YomiKu_0

May 07, 2024, 06:45:04 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Wall Walking
Pages: 1 [2]
Print
Author Topic: Wall Walking  (Read 4558 times)
Alex May
...is probably drunk right now.
Level 10
*


hen hao wan


View Profile WWW
« Reply #20 on: January 21, 2009, 07:27:18 AM »

It should be fairly easy to do in a physics/vector environment - shoot a ray in your current downward direction and change your downward direction to point in the opposite direction to the normal you receive from the collision system. For sharp or right-angled corners, it would make sense to shoot many rays along a set of angles between some +/- N degrees away from the downward direction and taking the average of the resultant normals.

Not that this helps the arbitrary tiles / sloped tiles problem...
Logged

salade
Level 4
****



View Profile
« Reply #21 on: January 25, 2009, 12:30:09 AM »

if you haven't found a solution I think I found one.

find the differences x-xprevious and y-yprevious and add them together. that value will be called SUM for the sake of not being confusing.

do two place_free()s, one at (x+SUM,y) one at (x, y+SUM). this should serve as a collision check like this

Pixel 11Pixel 11Pixel 11Pixel 11
Pixel 11Pixel 06Pixel 0BPixel 11
Pixel 0FPixel 0BPixel 11Pixel 11

the exact orientation depends on the direction your going and what adding and subtracting you do at the place_free points. if you want to switch directions, make suse to multiply SUM by -1 in one of the place free() points. you could say something like SUM*the sign of(direction-91).

this should work, I think. I just thought it up off the top of my head, so it is not tested. the important idea though is the difference between x and xprevious, and the y equivalent, since one of them will always be zero if you restrict your movement to horizontal and vertical.

people have already suggested this method, but this is just a way to implement it.

it shouldn't work on slopes though, that's beyond me...
« Last Edit: January 25, 2009, 12:36:53 AM by salade » Logged
Loren Schmidt
Level 10
*****



View Profile WWW
« Reply #22 on: January 25, 2009, 02:44:17 AM »

Thanks for the ideas, folks. I was working on this a while ago your ideas are better than mine were.
Logged
Robotacon
Pixelhead
Level 3
******


Story mode


View Profile
« Reply #23 on: January 25, 2009, 11:43:21 AM »

This is the code I use for wall crawlers (slightly edited for clarity). I test straight ahead in the direction the crawler is moving first and then under the crawlers feet or it won't work for me.

Code:
if( (speedX < 0) && wallLeft() ) {
    speedX = 0;
    speedY = -crawlSpeed;
} else if( (speedY < 0) && wallAbove() ) {
    speedx = crawlSpeed;
    speedY = 0;
} else if( (speedX > 0) && wallRight() ) {
    speedX = 0;
    speedY = this.maxSpeed;
} else if( (speedY > 0) && wallBelow() ) {
    speedX = -crawlSpeed;
    speedY = 0;
} else if( (speedX < 0) && !wallBelow() ) {
    speedX = 0;
    speedY = crawlSpeed;
} else if( (speedY < 0) && !wallLeft() ) {
    speedX = -crawlSpeed;
    speedy = 0;
} else if( (speedX > 0) && !wallAbove() ) {
    speedX = 0;
    speedY = -crawlSpeed;
} else if( (speedY > 0) && !wallRight() ) {
    speedX = crawlSpeed;
    speedY = 0;
}

I also have code so that crawlers drop to the ground if they are in mid air (if a tile is blown away) and crawl up out of blocks they get caught in but if I understand correctly you're not interested in that.
« Last Edit: January 27, 2009, 11:58:12 PM by robotacon » Logged
BMcC
Senior Editor, Hero,
Level 10
*****

Bee Mixsy


View Profile WWW
« Reply #24 on: January 27, 2009, 03:45:28 PM »

Did you get it working, Paul?  I'm curious to know which solution you chose.

If you want, I could make a BQ script for this that you could mess around with.  (Gotta do that at some point, anyway!)
Logged

Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic