Better:
Fenix Wiki
Please people, help adding some content.
CODE
program scrolling;
global
graphic;
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
begin
set_mode(cam_w,cam_h,16);
set_fps(0,0);
write_int(0,5,5,0, &fps);
//Make the testmap
graphic = new_map( bg_len, cam_h, 16 );
set_center(0,graphic,0,0);
for( x = 0; x < bg_len; x++ )
for( y = 0; y < cam_h; y++ )
if( x % 30 < 15 )
map_put_pixel(0,graphic,x,y,rgb(255,0,0));
else
map_put_pixel(0,graphic,x,y,rgb(0,255,0));
end;
end;
end;
//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
frame;
end;
exit();
end;
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?