Pages: [1]
  Print  
Author Topic: slope running in characterStepEvent  (Read 4447 times)
Massif
Seedling
*
Posts: 5


View Profile
« on: January 23, 2011, 12:02:09 PM »

There's a part in the characterStepEvent script that has me puzzled.

Code:
if maxSlope>0 and platformCharacterIs(ON_GROUND) and xVel!=0
{
  slopeYPrev=y
  for(y=y;y>=slopeYPrev-maxSlope;y-=1)
    if colTop
      break
  slopeChangeInY=slopeYPrev-y
}
else
  slopeChangeInY=0

Inside of that for loop, colTop will never change. Therefore it will either be true in the first iteration of the loop, or it will be false the entire time. I checked out the original code for the platform engine and it calls "isCollisionTop(1)" which takes into account the change in y. There is a similar part later on:

Code:
if not colBot and maxDownSlope>0 and xVelInteger!=0 and platformCharacterIs(ON_GROUND)
{
  //the character is floating just above the slope, so move the character down
  upYPrev=y
  for(y=y;y<=upYPrev+maxDownSlope;y+=1)
    if colBot             // we hit a solid below
    {
      upYPrev=y           // I know that this doesn't seem to make sense, because of the name of the variable, but it all works out correctly after we break out of this loop
      break
    }
  y=upYPrev
}

In this for loop, it is impossible for colBot to ever be true since the if statement that surrounds it checks if it's false!

This seems broken. Does anyone know if this code is ever even used?
Logged
TyrOvC
Mossbaby
*
Posts: 424


This text is not random :(


View Profile WWW
« Reply #1 on: January 23, 2011, 12:11:16 PM »

Spelunky is based on this platform engine: http://www.pages.drexel.edu/~mfp27/platformengine/

and in the original engine the slope movement code certainly works. Not sure if it is ever actually used in the game, or if it got butchered in some way to no longer work.  Best I could say is maybe comb through the original and replace some stuff?
Logged

Massif
Seedling
*
Posts: 5


View Profile
« Reply #2 on: January 23, 2011, 12:20:36 PM »

Yeah, the code in the original platform engine (from the site you linked to) looks fine, but the implementation in Spelunky seems broken.  However, I can't find anything that would stop this code from running. Guess it's time to start using the debug mode!
Logged
halibabica
Bossy
Mossy
*
Posts: 2175


old guard


View Profile Email
« Reply #3 on: January 24, 2011, 06:27:19 PM »

As far as I know, this code is only applicable to the sides of Olmec's head, which is the only sloped solid in the entire game.  Whether it does what it's supposed to or not, I have no idea.
Logged

Sometimes I wonder if I like Spelunky too much.
ManTrap mod - Tastes Like Spelunky
Hand-drawn comic - Spelunkying
Patrick
Bean
*
Posts: 218



View Profile
« Reply #4 on: January 24, 2011, 06:31:14 PM »

As far as I know, this code is only applicable to the sides of Olmec's head, which is the only sloped solid in the entire game.
Actually, I think the "corners" of boulders have slopes... not sure though.
Logged
Wonkyth
Big Bossy
Mossy
*
Posts: 2129



View Profile
« Reply #5 on: February 01, 2011, 05:44:03 AM »

From memory, boulders are square.
Logged

Can you read the wry? Can you FEEL the wry?!
halibabica
Bossy
Mossy
*
Posts: 2175


old guard


View Profile Email
« Reply #6 on: February 01, 2011, 04:23:19 PM »

boulders are square.
Indeed they are!  Completely perfectly 100% square.  Or, at least, their hit boxes are.
Logged

Sometimes I wonder if I like Spelunky too much.
ManTrap mod - Tastes Like Spelunky
Hand-drawn comic - Spelunkying
Patrick
Bean
*
Posts: 218



View Profile
« Reply #7 on: February 01, 2011, 11:47:29 PM »

boulders are square.
Indeed they are!  Completely perfectly 100% square.  Or, at least, their hit boxes are.
Yeah, you're right. Actually maybe not... for some reason I get the feeling I have, at some point, either:
A) Gotten stuck between a boulder's bottom corner and a block tile that are close together (flip over the edge) OR
B) Run over the top of a boulder by running and jumping as it approaches, which has the Spelunker appear to "climb" over the corner - but this probably doesn't mean it's a slope.

EDIT: By "climb" I mean, sort of, run uphill.
« Last Edit: February 02, 2011, 01:00:13 AM by Patrick » Logged
Wonkyth
Big Bossy
Mossy
*
Posts: 2129



View Profile
« Reply #8 on: February 02, 2011, 12:51:48 AM »

B) Run over the top of a boulder by running and jumping as it approaches, which has the Spelunker appear to "climb" over the corner - but this probably doesn't mean it's a slope.
Yeah, pretty sure this is both possible and proof that it is square.
Logged

Can you read the wry? Can you FEEL the wry?!
TyrOvC
Mossbaby
*
Posts: 424


This text is not random :(


View Profile WWW
« Reply #9 on: February 02, 2011, 09:30:17 PM »

If the boulder sprite has Precise Collision Checking checked, then anything inside the hitbox will be checked pixel by pixel. In that case, they are sloped.
Logged

Wonkyth
Big Bossy
Mossy
*
Posts: 2129



View Profile
« Reply #10 on: February 04, 2011, 01:58:09 AM »

However, that might make it impossible to climb, so be careful.
Logged

Can you read the wry? Can you FEEL the wry?!
Pages: [1]
  Print  
 
Jump to: