[4.5.9] SOLVED How to slide along ceilings in the platformer module?

pigeonaut

Member
When you jump in the platformer module and hug a wall, you will slide down it and preserve your vertical momentum. However if you jump and hit your head on the ceiling, your horizontal momentum stops dead, even if you are still holding right or left d-pad.

I was wondering if there was a way to keep the the player's horizontal speed from stopping when they hit the ceiling? This would make the ceiling feel less sticky when you collide with it after a jump.

Please let me know if I need to clarify anything!
 

Jonny

Well-known member
I know exactly what you mean because this is on my list of stuff too.
Could so with confirmation on this but I'm almost completely sure that the hor momentum didn't do this on older versions of NesMaker. I started late on, maybe 4.4ish, so if those early scripts are still available maybe the answer is in those older physics scripts. It definately feels 'wrong' the way it is now.
 

pigeonaut

Member
I know exactly what you mean because this is on my list of stuff too.
Could so with confirmation on this but I'm almost completely sure that the hor momentum didn't do this on older versions of NesMaker. I started late on, maybe 4.4ish, so if those early scripts are still available maybe the answer is in those older physics scripts. It definately feels 'wrong' the way it is now.
Thanks for the lead! I will go check those older scripts and see if I can't find anything. Yeah the current way almost feels like when you are small Mario and hit a breakable block with your head.
 

Jonny

Well-known member
@pigeonaut I think I may have this sorted. I've been trying loads of different things to make a new solid tile which uses a few lines of code from Dale which stops vertical movement to get the desired effect of gliding along rather than bumping. I found the AI reaction script for stop on solid prize, which is a modified one for games with the SMB style prize blocks. Tried using the AI reaction and just removing all the prize block code. It actually made it worse! With the AI reaction, it didn't just bump, it also stuttered a bit too.

Anyway, I went back to the new solid tile aproach and took the snipped of code from the AI reaction when checks collision is above. Ended up with this which works in my project... let me know if it works or not for yours....

Code:
;;; SOLID FOR ALL OBJECTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    LDA ObjectUpdateByte
    ORA #%00000001
    STA ObjectUpdateByte
    
;;; CHECK SOLID ABOVE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    LDY Object_type,x
    LDA Object_x_hi,x
    CLC
    ADC self_left
    STA temp
    JSR getPointColTable
    
    LDA Object_y_hi,x
    CLC
    ADC self_top
    CLC
    ADC Object_v_speed_hi,x
    SEC
    SBC #$01
    STA temp1
    CheckCollisionPoint temp, temp1, #$01, tempA
    BNE dontStopVerticalMovement

;;; STOP VERTICAL MOVEMENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    LDA yPrev
    STA Object_y_hi,x
    STA yHold_hi

dontStopVerticalMovement:
 

pigeonaut

Member
@pigeonaut I think I may have this sorted. I've been trying loads of different things to make a new solid tile which uses a few lines of code from Dale which stops vertical movement to get the desired effect of gliding along rather than bumping. I found the AI reaction script for stop on solid prize, which is a modified one for games with the SMB style prize blocks. Tried using the AI reaction and just removing all the prize block code. It actually made it worse! With the AI reaction, it didn't just bump, it also stuttered a bit too.

Anyway, I went back to the new solid tile aproach and took the snipped of code from the AI reaction when checks collision is above. Ended up with this which works in my project... let me know if it works or not for yours....

Code:
;;; SOLID FOR ALL OBJECTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
    LDA ObjectUpdateByte
    ORA #%00000001
    STA ObjectUpdateByte
  
;;; CHECK SOLID ABOVE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
    LDY Object_type,x
    LDA Object_x_hi,x
    CLC
    ADC self_left
    STA temp
    JSR getPointColTable
  
    LDA Object_y_hi,x
    CLC
    ADC self_top
    CLC
    ADC Object_v_speed_hi,x
    SEC
    SBC #$01
    STA temp1
    CheckCollisionPoint temp, temp1, #$01, tempA
    BNE dontStopVerticalMovement

;;; STOP VERTICAL MOVEMENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    LDA yPrev
    STA Object_y_hi,x
    STA yHold_hi

dontStopVerticalMovement:
Hey @Jonny, I put this code into a new script and attached it to a new tile type. My player will now jump through the tile above them and horizontal movement will be stopped. I think I just need the reverse of this where vertical movement is still stopped but horizontal movement is not stopped. I must have done something wrong, do I add this code to a new tile or an existing one? Was there another step I missed?

Thanks so much for helping me out on this one!
 

Jonny

Well-known member
Hmm.. not sure. Which tile ID did you assign the script to? Did you avoid the ones for jump though tile / ladder etc?
 

pigeonaut

Member
Hmm.. not sure. Which tile ID did you assign the script to? Did you avoid the ones for jump though tile / ladder etc?
I assigned the script to the last one, tile 15. Was there a modification to any of the AI reaction scripts?
 

Jonny

Well-known member
I assigned the script to the last one, tile 15. Was there a modification to any of the AI reaction scripts?
This might be why it's not working. I used it for a normal solid tile ($01), parts of which are handled by other scripts. I think that might be why it doesn't work correctly but give it a go.
 

GlassFrog

Member
I think I made the same mistake, so you basically replace the normal solid tile script with your new script?

Edit. seems to be working great now cheers @Jonny you're legend mate, it was quite a painless fix and saved me a lot of head scratching lol
 
Last edited:

Jonny

Well-known member
I think I made the same mistake, so you basically replace the normal solid tile script with your new script?

Edit. seems to be working great now cheers @Jonny you're legend mate, it was quite a painless fix and saved me a lot of head scratching lol
Yeah, and tbh I didn't know either until @pigeonaut mentioned it. Some of the tiles are handled differently in scripts such as inputs and physics which you'll probably know. I think there's a thread somewhere about having a second solid tile if anyone needed that. I can't seem to find it now, must be quite old.
 

pigeonaut

Member
Yeah, and tbh I didn't know either until @pigeonaut mentioned it. Some of the tiles are handled differently in scripts such as inputs and physics which you'll probably know. I think there's a thread somewhere about having a second solid tile if anyone needed that. I can't seem to find it now, must be quite old.
THANK YOU! It works so well now! Just had to assign your script as tile 01 like you said.
 
Top Bottom