Conveyor belt

Mugi

Member
this took me a moment and gave me a headache, but it was rather simple at the end of the day.

make a new tile assembly (conveyorbelt.asm) and assign it to an unused tiletype in your game.

Code:
; 11_ConveyorBelt

    LDA #TILE_SOLID
    STA tile_solidity
    
    LDA Object_h_speed_lo,x     ; load movement speed, we use lo to get any movement to count
    BEQ setConveyorLeft01       ; we're not moving, set the conveyor to move you left
    CMP #$01                    
    BMI conveyorFunctionEnd     ; we're moving already, dont mess it up by setting new values.

    
    ; hi and lo values here control the "resistance" of the conveyor belt when walking against it
    ; negative values are used because this is a left moving conveyor, for right moving one, use positive values.
    LDA #$FE                    ; set movement speed to -2 (negative values move us left)
    STA Object_h_speed_hi,x
    LDA #$90                    ; lo is used for finetuning the speed
    STA Object_h_speed_lo,x
    
    JMP conveyorFunctionEnd
    
setConveyorLeft01:
    ; hi and lo here are used to determine the speed that the belt moves you when you're idle.
    ; use positive values to move you right, and negative values to move you left
    LDA #$FD
    STA Object_h_speed_hi,x
    LDA #$80
    STA Object_h_speed_lo,x
    
conveyorFunctionEnd:

https://youtu.be/LWhVTddbecY
 

Mugi

Member
it's worth a note that this is coded and finetuned according to the physics and movement attributes of my game, so you will have to finetune the speed values differently
depending on how your game's protagonist moves by default, if your player's speed is much faster or slower than what i use, this will propably give you some unexpected behavior.

you can also easily change this to handle differently for mosnters (propably needed if your monsters movement speed differs a lot from your players)

simply do:

Code:
CPX #$12 ; monster type here
BEQ setMonster1speeds

; load and store default values here into temps

JMP doConveyorMovement

setmonster1speeds:
LDA #$FE
STA temp
LDA #$88
STA temp1
LDA #$FD
STA temp2
LDA #$90
STA temp3

doConveyorMovement:
; conveyor belt code here, change the speed valeus to temp, temp1, temp2 and temp3 instead of hardcoded values.
 

Dirk

Member
Thank you for the additional code. I hope I find some time in August to learn a bit assembly so I might be able to create my own code or understand code of others a bit better.
 

Mugi

Member
Dirk said:
Thank you for the additional code.

no probs. I recall some people were asking about conveyor belts and thought this would be something maybe worth sharing.
 

rimoJO

Member
Pressing against a wall and releasing while on a conveyor drops you into another screen.
 

Attachments

  • Conveyor Clip.gif
    Conveyor Clip.gif
    235.8 KB · Views: 3,370

Mugi

Member
dont press against the wall them.
all in all though, this is propably again the same thing that's been around ever since the beginning, where the collision routine starts ignoring stuff when it's already colliding.

there's a fix for that somewhere in the forum i posthed ages ago.
 

Mugi

Member
you use values between 01 and 7F
values 80 - FF are negative

it should work, but mind you i never actually tested that. This was entirely made just to get a left moving conveyor.
 

jcramer

New member
Ok. Is there anything special I need to do to make left and right conveyer belts? I'm getting errors saying "label already defined" I just put the same code in 11 and 12 with the values changed.
 

dale_coop

Moderator
Staff member
You need to make a copy of this script, for the other side.
And rename every labels, for example, rename
"setConveyorLeft01" to "setConveyorRight01"
and "conveyorFunctionEnd" to "conveyorRightFunctionEnd"
 

baardbi

Well-known member
I'm trying to implement this in 4.5.9, but it's driving me nuts. 4.5.9 has a lot of tile types hard coded in the physics script (and other places), so making custom tiles like this in 4.5.9 is tricky. Has anyone made a conveyor tile in the current NESmaker version?
 

baardbi

Well-known member
@baardbi Did you ever get conveyor tile to work in 4.5.9.?
Yes. Sort of. But it's a dirty hack. Unfortunately it's not as simple as making a code snippet for a tile type (at least the way I did it). I did a lot of modification to the physics script, since a lot of tile types are hard coded in there. And I also had to make a separate tile to stop the player at the end of the conveyor belt. I wish I could share a simple tile script code here, but that's not the case. This hack is very much integrated with the rest of my custom game code so it can't easily be used in other projects. But if you want to experiment with it yourself, I can tell you that I used the StartMoving macro in the physics script and StopMoving for the stop tile. But there are other issues as well if you want to use it in a scrolling game. If I ever make a simple tile for this then I'll share it here on the forum.
 
Top Bottom