Discuss Scratch

UnlimitedJokinha
Scratcher
100+ posts

How do I make diagonal walking scripts?

BEFORE ANYTHING:I'M NOT MAKING A GAME,I JUST WANT TO KNOW :D

So let's say I have a sprite,and it points in all 8 directions(north,northeast,east,southeast,south,southwest,west and northwest).
I was trying to make a walking script for all 8 directions.
I already knew how to make one for up,down,left and right,but when I tried to make the diagonal ones,for some reason only the southwest sprites were right,and all other diagonal sprites weren't showing…
I tried it with both
if <<key [right arrow v] pressed?> and <key [down arrow v] pressed?>> then
set [dir v] to [?]
end

and

when [right arrow v] key pressed
set [dir v] to [?]
if <key [down arrow v] pressed?> then
set [dir v] to [?]
end

But none of them worked…
(OBS.:the “dir” variable above is used because the sprite has an idle animation that is the same as the walking,so instead of using a sprite changing script and bugging the animation,I used this variable,so that when dir is set to number,it points to direction number° and loops the costumes number and number)

Before you answer anything,I used
change x by (10)
blocks and stuff,I just didn't put it on the scripts because I'm lazy
(oh,and by the way,another thing is that when i used the second scripts,the sprite for some reason didn't move up and down and the diagonal scripts started bugging,i dunno)

So basically I can't make diagonal walking scripts,but I want to,so i just came here and asked it

when green flag clicked
repeat until <[someone v] answers>
hit head on wall
end

P.S.:I'm dumb.
powercon5
Scratcher
1000+ posts

How do I make diagonal walking scripts?

could you be more clear on what you mean?
asivi
Scratcher
1000+ posts

How do I make diagonal walking scripts?

UnlimitedJokinha wrote:

BEFORE ANYTHING:I'M NOT MAKING A GAME,I JUST WANT TO KNOW :D

So let's say I have a sprite,and it points in all 8 directions(north,northeast,east,southeast,south,southwest,west and northwest).
I was trying to make a walking script for all 8 directions.
I already knew how to make one for up,down,left and right,but when I tried to make the diagonal ones,for some reason only the southwest sprites were right,and all other diagonal sprites weren't showing…
I tried it with both
if <<key [right arrow v] pressed?> and <key [down arrow v] pressed?>> then
set [dir v] to [?]
end

and

when [right arrow v] key pressed
set [dir v] to [?]
if <key [down arrow v] pressed?> then
set [dir v] to [?]
end

But none of them worked…
(OBS.:the “dir” variable above is used because the sprite has an idle animation that is the same as the walking,so instead of using a sprite changing script and bugging the animation,I used this variable,so that when dir is set to number,it points to direction number° and loops the costumes number and number)

Before you answer anything,I used
change x by (10)
blocks and stuff,I just didn't put it on the scripts because I'm lazy
(oh,and by the way,another thing is that when i used the second scripts,the sprite for some reason didn't move up and down and the diagonal scripts started bugging,i dunno)

So basically I can't make diagonal walking scripts,but I want to,so i just came here and asked it

when green flag clicked
repeat until <[someone v] answers>
hit head on wall
end

P.S.:I'm dumb.
Hi, i'm lazy too(and lot of others scratchers)
So, what do you think we could do?
footsocktoe
Scratcher
1000+ posts

How do I make diagonal walking scripts?

UnlimitedJokinha wrote:

BEFORE ANYTHING:I'M NOT MAKING A GAME,I JUST WANT TO KNOW :D

So let's say I have a sprite,and it points in all 8 directions(north,northeast,east,southeast,south,southwest,west and northwest).
I was trying to make a walking script for all 8 directions.
I already knew how to make one for up,down,left and right,but when I tried to make the diagonal ones,for some reason only the southwest sprites were right,and all other diagonal sprites weren't showing…
I tried it with both
if <<key [right arrow v] pressed?> and <key [down arrow v] pressed?>> then
set [dir v] to [?]
end

and

when [right arrow v] key pressed
set [dir v] to [?]
if <key [down arrow v] pressed?> then
set [dir v] to [?]
end

But none of them worked…
(OBS.:the “dir” variable above is used because the sprite has an idle animation that is the same as the walking,so instead of using a sprite changing script and bugging the animation,I used this variable,so that when dir is set to number,it points to direction number° and loops the costumes number and number)

Before you answer anything,I used
change x by (10)
blocks and stuff,I just didn't put it on the scripts because I'm lazy
(oh,and by the way,another thing is that when i used the second scripts,the sprite for some reason didn't move up and down and the diagonal scripts started bugging,i dunno)

So basically I can't make diagonal walking scripts,but I want to,so i just came here and asked it

when green flag clicked
repeat until <[someone v] answers>
hit head on wall
end

P.S.:I'm dumb.

If you use direction blocks, then don't use change x blocks, use move blocks. x is a direction so it won't work to combine it with change direction. Move is not a direction. It moves the sprite in any direction.
TheGamer1144
Scratcher
12 posts

How do I make diagonal walking scripts?

Point your sprite diagonally.
Make a script to move*.

*Do this:
when green flag clicked
if <key [space v] pressed?> then
move (25) steps
end
UnlimitedJokinha
Scratcher
100+ posts

How do I make diagonal walking scripts?

footsocktoe wrote:

UnlimitedJokinha wrote:

BEFORE ANYTHING:I'M NOT MAKING A GAME,I JUST WANT TO KNOW :D

So let's say I have a sprite,and it points in all 8 directions(north,northeast,east,southeast,south,southwest,west and northwest).
I was trying to make a walking script for all 8 directions.
I already knew how to make one for up,down,left and right,but when I tried to make the diagonal ones,for some reason only the southwest sprites were right,and all other diagonal sprites weren't showing…
I tried it with both
if <<key [right arrow v] pressed?> and <key [down arrow v] pressed?>> then
set [dir v] to [?]
end

and

when [right arrow v] key pressed
set [dir v] to [?]
if <key [down arrow v] pressed?> then
set [dir v] to [?]
end

But none of them worked…
(OBS.:the “dir” variable above is used because the sprite has an idle animation that is the same as the walking,so instead of using a sprite changing script and bugging the animation,I used this variable,so that when dir is set to number,it points to direction number° and loops the costumes number and number)

Before you answer anything,I used
change x by (10)
blocks and stuff,I just didn't put it on the scripts because I'm lazy
(oh,and by the way,another thing is that when i used the second scripts,the sprite for some reason didn't move up and down and the diagonal scripts started bugging,i dunno)

So basically I can't make diagonal walking scripts,but I want to,so i just came here and asked it

when green flag clicked
repeat until <[someone v] answers>
hit head on wall
end

P.S.:I'm dumb.

If you use direction blocks, then don't use change x blocks, use move blocks. x is a direction so it won't work to combine it with change direction. Move is not a direction. It moves the sprite in any direction.

Thanks,I'll try that.
I tried that,and the walking part works,but it stills only points to the southwest when pointing diagonally

Last edited by UnlimitedJokinha (May 2, 2017 23:15:53)

asivi
Scratcher
1000+ posts

How do I make diagonal walking scripts?

UnlimitedJokinha
Scratcher
100+ posts

How do I make diagonal walking scripts?

asivi wrote:

Hi, test https://scratch.mit.edu/projects/136951941/
Works for you?

Yes,why?
Do you want me to copy the scripts or somethin'?
asivi
Scratcher
1000+ posts

How do I make diagonal walking scripts?

I don't want anything from you bb.
Good luck.

Last edited by asivi (May 3, 2017 09:12:01)

Powered by DjangoBB