Below is a sequence of images of the problem I am facing.
I use the mget() function to return the sprite value, but when it changes the numeric value, it doesn't change the sprite automatically.
As shown in the images, it changes only after the character is on the second block of water, and the same thing happens when he comes out of the water, as if there is a delay.
Does anyone know how to resolve?
I'll leave the cart for you to help me
Oh man, that was tricky for me, I totally thought that should work.
I eventually realised you check the square you're on, then move the character, so its always looking at the last square you were on.
I've not got an elegant solution, but the gist is you want to check the square you're about to move onto. so I added a map check under each button command to look ahead and that seemed to work.
function mov() if btnp(⬆️) then map_tile=mget(pato.x+4\8,(pato.y+4\8)-1) if map_tile == 52 then pato.y-=1 pato.sp=55 else pato.y-=1 pato.sp=3 end end if btnp(⬇️) then map_tile=mget(pato.x+4\8,(pato.y+4\8)+1) if map_tile == 52 then pato.y+=1 pato.sp=53 else pato.y+=1 pato.sp=1 end end if btnp(➡️) then map_tile=mget((pato.x+4\8)+1,pato.y+4\8) if map_tile == 52 then pato.x+=1 pato.flp=false pato.sp=54 else pato.x+=1 pato.flp=false pato.sp=2 end end if btnp(⬅️) then map_tile=mget((pato.x+4\8)-1,pato.y+4\8) if map_tile == 52 then pato.x-=1 pato.flp=true pato.sp=54 else pato.x-=1 pato.flp=true pato.sp=2 end end end |
so if you push right it does mget x+1, if you push down it does mget y+1, etc...
Maybe there is a nicer way of doing that, but this seems to work.
(BTW, I'm loving the duck in the hat. It's so cute)
[Please log in to post a comment]