please let me know how it works out.Quiest said:You can`t, sorry, I lost it.
But here's a good idea for a scrolling engine, using big images:
cam_x, cam_y, cam_w, cam_h
cam_w = 320 (screen res x)
cam_h = 240 (screen res y)
cam_x = 0 ( starting position, gets increased )
cam_y = 0 ( horizontal scrolling )
bgimage = loaded background image
now you can use
this cuts a pipece from the large bgimage to the screen, from cam_x|cam_y with the size of cam_w|cam_h.
The first 0 is the target fpg (none is used), the second is the map ( 0 = screen background ) the others are x|y.
I think I will do this in Fenix later to see how fast it is...
Quiest said:Better: Fenix Wiki
Please people, help adding some content.
int cam_x = 0;
int cam_y = 0;
int cam_w = 320;
int cam_h = 240;
int scroll_speed = 3;
int bg_len = 16000; // the testmap will be 16000x240
//Make the testmap
graphic = new_map( bg_len, cam_h, 16 );
for( x = 0; x < bg_len; x++ )
for( y = 0; y < cam_h; y++ )
if( x % 30 < 15 )
//x=y=0; //Method 2
//graph = graphic; //Method 2
while( !key(_esc) )
//map_block_copy(0,0,0,0,graphic,cam_x,cam_y,cam_w,cam_h,0); //Method 3
put(0,graphic,-cam_x,cam_y); //Method 1
cam_x += scroll_speed;
if( cam_x + cam_w + scroll_speed > bg_len ) cam_x = 0; end;
//x = -cam_x; //Method 2
Try for yourself, using the scrolling as a graph can be about 10 to 20% faster if there arent too many active processes.
Runs 170fps on my pc, the rest (put & map_block_copy) runs at about 155 fps.
what should i change to make a vertical map that starts at the bottom and scrolls upward?
yonni said:If you just used the built-in fenix scrolling, it would be so much easier! For vertical scrolling:
//initiate the scroll window
start_scroll(0,*fpg number/0*,*graphic number/load_graph()/0*,*graphic number/load_graph()*,0,10);
//set a process to be the "camera" for the scroll window (this will always be on screen)
scroll.camera = *processid*;
/*use these functions to move the scroll window (the foreground is the first graph identified in "start_scroll" (3rd parameter) and the background is the other graph identified in "start_scroll")*/
scroll.y0 = *; scroll.x0 = *; //move the foreground;
scroll.y1 = *; scroll.x1 = *; //move the background;
/*the only thing that needs to be done now is to tell which processes should be drawn within the scroll window (rather than in the main window, floating above the scroll) by allocating the local variable ctype*/
ctype = c_scroll;
This may well be faster than using an enormous graph as it is in-built into fenix and it will automatically tile graphics to take up the space needed.
ill test this out tonight.