Scrollery.


Quiest said:
check the scroll.zip here. I hope it helps, you need a little knowledge of Fenix (or structs in Fenix).


can i get another(working) copy of this?
im back programming and i need this scrolling code again.
any help would be great.
 
Last edited by a moderator:
You can`t, sorry, I lost it.

But here's a good idea for a scrolling engine, using big images:

Have a
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

map_block_copy(0,0,0,0,bgimage,cam_x,cam_y,cam_w,cam_h);

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:
You can`t, sorry, I lost it.

But here's a good idea for a scrolling engine, using big images:

Have a
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

map_block_copy(0,0,0,0,bgimage,cam_x,cam_y,cam_w,cam_h);

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...
please let me know how it works out.
also, how can i change the color of the text in fenix?
 
Last edited by a moderator:
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.
 
Quiest said:
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?
 
Last edited by a moderator:
If you just used the built-in fenix scrolling, it would be so much easier! For vertical scrolling:

CODE

//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[0].camera = *processid*;
//////OR
/*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[0].y0 = *; scroll[0].x0 = *; //move the foreground;
scroll[0].y1 = *; scroll[0].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.
 
yonni said:
If you just used the built-in fenix scrolling, it would be so much easier! For vertical scrolling:

CODE

//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[0].camera = *processid*;
//////OR
/*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[0].y0 = *; scroll[0].x0 = *; //move the foreground;
scroll[0].y1 = *; scroll[0].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.
 
Last edited by a moderator:
So, how much fps did it make? also, the inbuilt scrolling is buggy, and i remember it being very slow and laggy on the 2X (so could be mine).

If you got any test results, please inform me.
 
Quiest said:
also, the inbuilt scrolling is buggy
How so? I've never noticed any bugs. Is that just for GP32/2X?
 
Last edited by a moderator:
Back
Top