2d smooth scroll
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.
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.
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.
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.
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
Transforming the view matrix is often faster than transforming the scene.
Don't forget to clip.
Don't forget to clip.
---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Irrlicht Gouraud/Smooth Shading | merrill541 | 4 | 4,788 |
Feb 3, 2010 01:13 PM Last Post: merrill541 |
|
| Change scroll text using xcode | imaumac | 3 | 3,757 |
Nov 29, 2008 03:53 PM Last Post: imaumac |
|
| scroll text and images please. | imaumac | 13 | 6,319 |
Nov 6, 2008 07:42 AM Last Post: imaumac |
|
| Smooth model surfaces | imikedaman | 3 | 2,480 |
Jul 12, 2006 10:34 PM Last Post: imikedaman |
|
| nasty tearing when I scroll in openGL | Joseph Duchesne | 3 | 2,783 |
Aug 15, 2004 10:30 PM Last Post: arekkusu |
|

