I want a script which checks if my hero is aligned. Here's the script I wrote, however I wasn't sure if I also have to account for hero offset value...
Spoonweaver wrote:I don’t think this actually will work.
Won’t Heropixelx(me)/20 just round to the closest whole number?
Thus making this script always true?
I suggest also testing for (heropixelx(me)+20)/20
You should get all four points of the walkabout square too, while you’re at it.
Yeah you're right, I just noticed this when I went to test it out. I think I got it working right by multiplying hero x*20 so that it will check if it's equal to hero pixel x at any given time. The check seems to work fine now.
Im curious what you mean about checking all four points of the walkabout square. I assume you're talking about checking whether the top-right, bottom-right, top-left, and bottom-left pixel line up with the grid properly. I just don't understand why this would be necessary to check. Could you explain further? As far as I understand checking if the one single point lines up (with both x and y) should tell me if my hero is currently aligned with the grid... or am I missing something important?
"hero is moving(me) == false" accomplishes the same thing, except during cutscenes: if you hold down the, say, right arrow key, then "hero is moving" returns false at the end of every step. But if you run "walk hero(me, right, 4)" then "hero is moving" won't return false until the whole movement is finished.
TMC wrote:"hero is moving(me) == false" accomplishes the same thing, except during cutscenes: if you hold down the, say, right arrow key, then "hero is moving" returns false at the end of every step. But if you run "walk hero(me, right, 4)" then "hero is moving" won't return false until the whole movement is finished.
Good to know. I think I'll change to your method since it simplifies things further yet. I don't think the cutscene thing will raise any issues but I'll try to keep that in mind.
See, if you divide, you will always return the square the the top left corner is in. so the only way to detect alignment with dividing would be to check if each corner is aligned.