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

#1 2008-02-26 12:36:55

BenIGreen
Scratcher
Registered: 2008-01-26
Posts: 7

Smooth 4-directional scrolling

So far, I've only seen one example of really smooth 4-directional scrolling and it's only smooth on the website.  When I downloaded it, I found it had the same clunky problems as the ones I've been trying.  Strangely, the same method works beautifully for the side-scrollers I've made, but the movement is slow, jerky, and you can see the gaps between the background pieces as they move.
I don't like the block images so I've written out my code here:

FOREVER
GO TO X: [(scrollx) + (480 * 0)] Y: [(scrolly) + (480 * 0)]
IF [460 < ABS of (x position)]
  HIDE
ELSE
  IF [340 < ABS of (y position)]
    HIDE
  ELSE
    SHOW

I also tried this:

FOREVER
GO TO X: [(scrollx) + (480 * 0)] Y: [(scrolly) + (480 * 0)]
IF [460 < ABS of (x position)] OR [340 < ABS of (y position)]
  HIDE
ELSE
  SHOW


Any suggestions?

Offline

 

#2 2008-02-26 16:24:40

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Smooth 4-directional scrolling

All scrolling projects will be laggy when run in development mode.
The only way I can see to improve what you have is to remove the part that makes the sprites hide or just alter the values that the sprites hide at.

One thing I noticed is that when run online, sprites can go further off screen so hiding them may be not entirely necessary if you just want to display the project online.

Check this project for a very simple example of 4 way scrolling. http://scratch.mit.edu/projects/archmage/100982


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#3 2008-02-26 21:31:05

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Smooth 4-directional scrolling

You can speed up scripts in development mode by switching to a sprite that has no active scripts.

Offline

 

#4 2008-02-27 15:55:27

BenIGreen
Scratcher
Registered: 2008-01-26
Posts: 7

Re: Smooth 4-directional scrolling

kevin_karplus wrote:

You can speed up scripts in development mode by switching to a sprite that has no active scripts.

What do you mean by this?  The active scripts are needed to keep the sprites scrolling right?  How could I keep them moving appropriately if they had no active scripts?

Also, it seems odd to me that projects run slower in development mode than they do online.  Is that because the scratch server compiles them so they're no longer scratch projects as such?  If so, shouldn't scratch have a feature to run projects off-line in the same way?

Offline

 

#5 2008-02-27 16:25:49

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Smooth 4-directional scrolling

When you run something in development mode, the script window is animated and this results in the animation window also slowing down.

Online, (or in full screen mode) there is no animation of the scripts, so no slowdown.

You can switch to *viewing*  a sprite that has no active scripts whilst in development mode (ie, a sprite that isn't one of your scrolling ones) in order to avoid the script-animation slowdown but you are still better off in full-screen or online mode.

Incidentally, which 4 way scrolling demo did you find that was smoothest?


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#6 2008-02-28 16:38:29

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: Smooth 4-directional scrolling

Well my version it glitch free so you might want to try it. Here it is: http://scratch.mit.edu/projects/Lucario621/98639 .


http://i.imgur.com/WBkM2QQ.png

Offline

 

Board footer