Language…
9 users online: Cristian Cardoso, dotCoockie, DPBOX, Golden Yoshi, Lsh0426, Rauf, signature_steve, Sweetdude,  Telinc1 - Guests: 255 - Bots: 413
Users: 64,795 (2,377 active)
Latest user: mathew

How can I make a block that changes a sprites speed?

Here's what I tried, but it has no effect on the sprite...

Code
db $37

JMP MarioBelow : JMP MarioAbove : JMP MarioSide
JMP SpriteV : JMP SpriteH
JMP Cape : JMP Fireball
JMP MarioCorner : JMP MarioBody : JMP MarioHead
JMP WallFeet : JMP WallBody

MarioBelow:
MarioAbove:
MarioSide:
RTL

SpriteH:
SpriteV:
	LDA #$EC				; \ Set the sprite's y speed to -20.
	STA !AA,x				; /
	LDA #$0A				; \ Set the sprite's x speed to 10.
	STA !B6,x				; /
RTL




Cape:
Fireball:
MarioCorner:
MarioBody:
MarioHead:
WallFeet:
WallBody:
RTL
The sprite's vanilla code probably overwrites the speed with its own values before it's time to actually update the position. Adding a call to the "update XY positions" routine should fix that. You might need to adjust the speed values though, since the sprite would probably still be having its speed/position updated again by the vanilla code.
Something like this:
Code
LDA #$EC
STA !AA,x
LDA #$0A
STA !B6,x
PHY
JSL $01802A|!bank
PLY
THank you, this works :) Unfortunately, like you said, the sprites speed is updated every frame. I would otherwise would have liked to manipulate the movement of thwomps by having them hit invisible blocks that change their trajectory. <3

Can you explain what this does?

Code
PHY
JSL $01802A|!bank
PLY
$01802A is the routine in SMW that determines what a sprite's new position should be, based on the speed values set in !AA,x and !B6,x. The PHY/PLY preserve the value in the Y register, since $01802A overwrites it. In block code, Y holds the high byte of the block's "act as", so it needs to be preserved so that the block doesn't start acting like a different block.
Okay, thank you :)