2d smooth scroll

Luzander
Unregistered
 
Post: #1
Hey!

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 :
http://cone3d.gamedev.net/cgi-bin/index....fxsdl/tut2

When I try his example the box moves ALOT faster then my map scrolls in my own program.
Quote this message in a reply
Luzander
Unregistered
 
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...
for(i=0;i<20;i++){
for(j=0;j<20;j++){
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
Moderator
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
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #4
Transforming the view matrix is often faster than transforming the scene.
Don't forget to clip.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Post Reply 

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