This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-03-02 23:25:51

shigrammer
Scratcher
Registered: 2011-02-14
Posts: 8

stopping diagonal movement?

I am currently working on a pacman game and I have a problem with diagonal movement. I don't want pacman to be able to move diagonally.
<when green flag clicked>
<forever>
<if> up key is pressed <<  <and>  >> variable down arrow=not pressed <<  <and>  >> right arrow not pressed <<  <and>  >> left arrow not pressed <change y by(4 <point in direction(0)
ect. for the rest of the arrow keys; now I have motion.

<when green flag clicked>
<set{ variable up arrow to not pressed  }
<set{ variable down arrow to not pressed  }
<set{ variable left arrow to not pressed  }
<set{ variable right arrow to not pressed  }

now I can move when I click start.

<when green flag clicked>
<if> up arrow pressed <set{ variable up arrow }to( pressed
<if> up down pressed <set{ variable down arrow }to( pressed
<if> right arrow pressed <set{ variable right arrow }to( pressed
<if> left arrow pressed <set{ left arrow }to( pressed

when I clicked start I could still move diagonally like nothing happened. Can anyone spot a glitch in my codes or think of a better way to stop the diagonal movement?
Thanks,
Shigrammer

Offline

 

#2 2011-03-02 23:51:08

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: stopping diagonal movement?

If you just upload it, it'd make it better for us to see and less messy. We'd also be able to see placements.

Try using the built in one that comes included with the scratch program.

Offline

 

#3 2011-03-03 21:50:48

shigrammer
Scratcher
Registered: 2011-02-14
Posts: 8

Re: stopping diagonal movement?

Thank you. I didn't realize that there was a demo on scratch.

Offline

 

Board footer