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

#1 2007-05-15 02:05:50

rszrama
Scratcher
Registered: 2007-05-15
Posts: 25

Something screwy in the speed

I'm not entirely sure why, but there's an inconsistency in the movement here resulting from using multiple keypresses.  The test project is:

http://scratch.mit.edu/projects/rszrama/3188

If you use just the left or right arrow, you'll see some fairly slow movement.  (Granted, it was faster when I was testing on my desktop.)  However, you can speed it up by first holding an arrow in one direction and then, while still holding that key down, holding the arrow in the opposite direction.  This was breaking when testing on my PC and through a browser.

For now I can market it as a "run" feature... I'd be curious to know if this is a bug or just bad practice for the code.

Offline

 

#2 2007-05-16 10:45:40

johnm
Scratcher
Registered: 2007-03-08
Posts: 100+

Re: Something screwy in the speed

Hi!

You have:
  "forever if key <right arrow> pressed?" move 2"
and also:
   "forever if key <left arrow> pressed?" move 2"

So if you hold down both keys, the sprite moves by 4, giving you double the speed.

The "forever if" constructs are underneath "when <> key pressed" blocks, which may be misleading you. Once The "forever if" constructs are started, they keep running.

There are many other ways to solve this problem. Now that you know why it is behaviing the way it is you can probably figure out a solution that gives you the game play that you want.

Scratch on!

  -- John

Last edited by johnm (2007-05-16 10:48:30)

Offline

 

#3 2007-05-16 14:52:44

rszrama
Scratcher
Registered: 2007-05-15
Posts: 25

Re: Something screwy in the speed

Yep, I eventually found the not sitting in the numbers menu, so I made movement much better in the Grumpy Wizard game.

Offline

 

Board footer