Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » [Fixed] How to make a 8-directional sprite?
- S_prite
-
Scratcher
48 posts
[Fixed] How to make a 8-directional sprite?
I'm trying to make a game where the player can move in all 8 directions and I want the visuals to match up.
I haven't found any tutorials on how to make a clean and easy to understand script for 8-directional visuals though.
I haven't found any tutorials on how to make a clean and easy to understand script for 8-directional visuals though.
Last edited by S_prite (Nov. 11, 2020 00:56:23)
- Nezon
-
Scratcher
1000+ posts
[Fixed] How to make a 8-directional sprite?
Uhh, it is really easy.
This not only makes it go in four directions but also all other 4 diagonal directions.
when green flag clicked
forever
if <key [right arrow v] pressed?> then
change x by (10)
end
if <key [left arrow v] pressed?> then
change x by (-10)
end
if <key [up arrow v] pressed?> then
change y by (10)
end
if <key [down arrow v] pressed?> then
change y by (-10)
end
end
This not only makes it go in four directions but also all other 4 diagonal directions.
- S_prite
-
Scratcher
48 posts
[Fixed] How to make a 8-directional sprite?
No, I need the visuals to be 8-directional too.
- colinmacc
-
Scratcher
1000+ posts
[Fixed] How to make a 8-directional sprite?
No, I need the visuals to be 8-directional too.
What does that even mean?
- -CloudGate-
-
Scratcher
1000+ posts
[Fixed] How to make a 8-directional sprite?
you need to make the player walk animation in 8 directions
- S_prite
-
Scratcher
48 posts
[Fixed] How to make a 8-directional sprite?
I mean if the character is going southwest, I want it to switch to the “going southwest” costume.No, I need the visuals to be 8-directional too.
What does that even mean?
- colinmacc
-
Scratcher
1000+ posts
[Fixed] How to make a 8-directional sprite?
I mean if the character is going southwest, I want it to switch to the “going southwest” costume.No, I need the visuals to be 8-directional too.
What does that even mean?
OK, something like this I guess… Assuming your costume names are N, S, E, W, NE, SE, NW and SW …
I don't know if you have a default costume if you're not moving, but I assumed so.. Also the set to blank blocks, are not space, but actually blank.
switch costume to [default v]
set [vcostume v] to []
if <key [up arrow v] pressed?> then
set [vcostume v] to [N]
end
if <key [down arrow v] pressed?> then
if <(vcostume) = [N]> then
set [vcostume v] to []
else
set [vcostume v] to [S]
end
end
set [hcostume v] to []
if <key [left arrow v] pressed?> then
set [hcostume v] to [W]
end
if <key [right arrow v] pressed?> then
if <(hcostume) = [W]> then
set [hcostume v] to []
else
set [hcostume v] to [E]
end
end
switch costume to (join (vcostume) (hcostume))
Last edited by colinmacc (Nov. 10, 2020 10:38:25)
- deck26
-
Scratcher
1000+ posts
[Fixed] How to make a 8-directional sprite?
If you have multiple costumes for each direction you could add a number to the end of the costume names generated by @colinmacc's script. That number just cycles from 1 to n each time through the loop.
- colinmacc
-
Scratcher
1000+ posts
[Fixed] How to make a 8-directional sprite?
If you have multiple costumes for each direction you could add a number to the end of the costume names generated by @colinmacc's script. That number just cycles from 1 to n each time through the loop.
Yes.
I mean personally I wouldn't have a different costume for each direction, but if (for example) it was a top-down view of a guy walking, Just cycle through the costumes as @deck26 describes, and then just rotate to point in the direction you're going.
- deck26
-
Scratcher
1000+ posts
[Fixed] How to make a 8-directional sprite?
Agreed. It may also be possible to share costumes - eg left and right movement might share the same costume set with left-right rotation style.If you have multiple costumes for each direction you could add a number to the end of the costume names generated by @colinmacc's script. That number just cycles from 1 to n each time through the loop.
Yes.
I mean personally I wouldn't have a different costume for each direction, but if (for example) it was a top-down view of a guy walking, Just cycle through the costumes as @deck26 describes, and then just rotate to point in the direction you're going.
- Arjule
-
Scratcher
1 post
[Fixed] How to make a 8-directional sprite?
Can someone give me a 8 direction sprite with run animation
- Discussion Forums
- » Help with Scripts
-
» [Fixed] How to make a 8-directional sprite?