2d smooth scroll

Post: #1

I cant figure out how to make scrolling smooth and fast.

I use a loop to draw my images, using X,Y cordinates.
When I press LEFT I decrease X by 1.

Everything works, it scrolls everything one pixel to the left.... but it goes very slow! If I press and hold left it drags forward so.. very.. slow!Takes maybe 5 seconds to scroll 50 pixels to the left.

Can it be because of the number of images I display? its about 50 or so smaller images (like textures)...

I worked from this tutorial :

When I try his example the box moves ALOT faster then my map scrolls in my own program.
Quote this message in a reply
Post: #2
sorry, to make it alittle more clear.. I am at work and does not have all code in my head tho..

int x,y; // Where i decide I want to start drawing, top left.
int i,j=0;

// Every frame this runs. 40x40 images, so...
DrawIMG(grass, i * 40 + x, j * 40 + y);

When I press left I decrease X--; so all images should be put 1 pixel to the left next frame.
Quote this message in a reply
Posts: 613
Joined: 2004.09
Post: #3
You will want to move the screen based on your current frames per second, this will give you a more uniformed speed across diffrent computers and should fix some of the choppyness you are experincing

Kyle Richter
Twitter: @kylerichter
Quote this message in a reply
Posts: 469
Joined: 2002.10
Post: #4
Transforming the view matrix is often faster than transforming the scene.
Don't forget to clip.

15.4" MacBook Pro revA
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Irrlicht Gouraud/Smooth Shading merrill541 4 9,673 Feb 3, 2010 01:13 PM
Last Post: merrill541
  Change scroll text using xcode imaumac 3 6,013 Nov 29, 2008 03:53 PM
Last Post: imaumac
  scroll text and images please. imaumac 13 11,077 Nov 6, 2008 07:42 AM
Last Post: imaumac
  Smooth model surfaces imikedaman 3 4,559 Jul 12, 2006 10:34 PM
Last Post: imikedaman
  nasty tearing when I scroll in openGL Joseph Duchesne 3 4,787 Aug 15, 2004 10:30 PM
Last Post: arekkusu