Process Question


HeXy

Still Fresh
Joined
Jul 3, 2006
Messages
32
Hiya all,

I'm just revisiting fenix after a few months (too much real life got in the way!), and im having a spot of bother with a process, just wondering if any of you can see what I am doing wrong.

I'm concentrating on the opening sequence at the moment, using a variable "v_selected" to determine where to go from the title screen (ie, to start the game, goto the option screen, or quit).

The navigation of the option screen is contained in a process (called option) that should end when "v_selected" is no longer 0 (ie, an option has been selected). The option to quit the game works fine (v_selected=3), but the option to start the game fails (v_selected=1).

If I put the whole code of the process into my v_selected==0 loop it works fine, but I want to try and keep it as a process so I can reuse it if needed.

Here is what I have (its very basic I know)

CODE

//NinjaPirate 2x Version 0.002
//Developed by Chris Hexter, CDH interactive
//http://www.cdhinteractive.net

PROGRAM NP2X;

//private variables
private

//global variables
global
v_option;
gfx_title;
v_selected;
v_optiontime;

Begin

//default settings----------------------
dump_type=0;
restore_type=0;
set_mode(320,240,16);
set_title("NinjaPirate 2x");
set_fps(30,0);
v_option=0;
v_optiontime=0;
v_selected=0;
//--------------------------------------


//load cdh splash-----------------------
gfx_title=load_fpg("np2x_boards.fpg");
put_screen(gfx_title,1);
frame;
timer[0]=0;
fade(100,100,100,10);

while (fading)
frame;
end

while (timer[0]<=300)
frame;
end

fade(0,0,0,1);
while (fading)
frame;
end
//--------------------------------------


//load title screen----------------------
timer[0]=0;
put_screen(gfx_title,2);
fade(100,100,100,1);

while (fading)
frame;
end


if(v_selected==0)
write(0,170,175,0,"Start");
write(0,170,195,0,"Options");
write(0,170,215,0,"quit");
option();
frame;
end
//--------------------------------------


//level 1 intro ----------------------

if(v_selected==1)
write(0,170,175,0,"Level 1.. get ready!");
frame;
end

//--------------------------------------

//quit the game if option is 3
while(v_selected!=3)
frame;
end;


End; //end Begin loop

//Select an option from the title screen
process option()
Begin
graph=3; //option pointer
x=150; //initial coords
y=180; //
timer[1]=0;

while(v_selected==0)

if(x==150 && y==180)
v_option=1;
end;


if(x==150 && y==200)
v_option=2;
end;


if(x==150 && y==220)
v_option=3;
end;



//move option pointer up or down

if(key(_up) && v_option!=1 && v_optiontime==0 && y>179)
y-=20;
timer[1]=0;
v_optiontime=1;
end;

if(key(_down) && v_option!=3 && v_optiontime==0 && y<221)
y+=20;
timer[1]=0;
v_optiontime=1;
end;

//pointer delay
if(v_optiontime==1 && timer[1]>25)
v_optiontime=0;
timer[1]=0;
end;


if(key(_alt) && v_option==1)
v_selected=1;
end;

if(key(_alt) && v_option==2)
v_selected=2;
end;

if(key(_alt) && v_option==3)
v_selected=3;
end;
frame;

End; //end loop

End; //end option




Any help would be greatly appreciated :)
 
Hello, I'm not positive but it looks as if the section of your main code that starts the game is outside the main loop.

The section below loops so the rest of the main code is never returned to
CODE
while(v_selected!=3)
frame;
end;


Try moving the 'while(v_selected!=3)' line above the '//level 1 intro' section.
 
Hi Ruckage, thank you very much for that, it fixed my issue :D
 
HeXy said:
Hi Ruckage, thank you very much for that, it fixed my issue :D
No problem. Glad it worked.
 
Last edited by a moderator:
Back
Top