Fenix Code Help


meandu229

Zubeman
Joined
Mar 20, 2004
Messages
1,170
Age
37
Location
England(north east)
Website
www.zubeonline.com
Hey i know alot of you are starting to code fenix and we really need a topic to ask questions so we dont have to use evil dragons tutorial thread all the time,, ill start the ball rolling, i know how to graph things and how to make a background but how would i make the background scroll across?? thanx
 
You could or calculate the correct position yourself every frame and put() the background graphic, or you could try to use a scroll, for example:

The start_scroll command:
Code:
Start_Scroll(int number,int fpg,int foreground picture,int background picture,int region,int repetition)
number - number of the scroll, from 0 to 9
fpg - file where the graphics are located
foreground - main picture, number of the map within the given fpg
background - optional picture, 0 if you don't want it.
region - region
repetition - if the fore/background pictures are cyclic:
1 - foreground is horizontally cyclical
2 - foreground is vertically cyclical
4 - background is horizontally cyclical
8 - background is vertically cyclical

A simple scrolling background would look like this(assuming the fpg is loaded in fpg1, graphic number 1 is the only picture we want, and is cyclic both horizontal and vertical):
Code:
start_scroll(0, fpg1, 1, 0, 0, 3);
loop
  scroll[0].x += 2;
  scroll[0].y += 2;
  frame;
end
The scroll would move 2 pixels every frame both horizontally and vertically.

Hope this solves it :)
 
Nice example.

You can try to add
Code:
scroll[0].camera=id_player;

id_player is the tag for the process of your character/ship/whatever you want ther scroll automatically follows.
 
so here is my question...
im making a spaceinvader like game with a tutorial..
really easy but i have a problem:

Code:
// Falling Rocks GP32!!
PROGRAM Falling_Rocks_Gp;
GLOBAL
game;
flgshot;
PRIVATE 
BEGIN
game=LOAD_FPG("d:\fenix\Falling_Rocks_GP\falling.fpg");
PUT_SCREEN(game,1);
ship();
WHILE(NOt Key(_enter))
  	Frame;
  	End
END
PROCESS SHIP();
BEGIN
x=160;
y=170;
graph = 2;
loop
	x=mouse.x;
 if (mouse.left and not flgshot)
    shot();
    end;
 frame;
END
end
PROCESS shot();
PRIVATE
BEGIN
x=mouse.x;
y=155;
graph = 3;
flgshot=1;
loop
	for(y=155;y>0;y=y-10)
  frame;
  end;
end;
flgshot=0;
END

this is the code, a mess i know ;) but i have one problem..
in the shot process, when i move the sprite for the shot up the screen it should dissappear when it reaches the top.. but it doesnt how can i do this?
Thanks

EDIT:
another thing.. what do i have to do to get parts in graphics transparent?
i cant get it to work... but i dont think its that hard

hehe i got a bit more into fenix and now modified it that way that it works without mouse (ok but i still have this bug)

Code:
// Falling Rocks GP32!!
PROGRAM Falling_Rocks_Gp;
GLOBAL
game;
flgshot;
shipx;
PRIVATE 
BEGIN
game=LOAD_FPG("frgp.fpg");
PUT_SCREEN(game,1);
ship();
WHILE(NOt Key(_enter))
  	Frame;
  	End
END
PROCESS SHIP();
BEGIN
x=160;
y=170;
graph = 2;
loop
	if (x<320 and key(_right))
    x=x+5;
    end
  if (x>0 and key(_left))
     x=x-5;
     end
  if (key(_alt) and not flgshot)
    shot();
    end;
 frame;
shipx=x;
END
end;
PROCESS shot();
PRIVATE
BEGIN
x=shipx;
y=155;
graph = 3;
flgshot=1;
	for(y=155;y>0;y=y-10)
  frame;
 end;
flgshot=0;
END

EDIT2:
ok the loop was the problem.. im an idiot ;)
ok works now pretty well.. this code also works on the gp32 ;)
 
just color it black.. thats how it works for me ;)

now another problem from me ;)
im trying to make a Zelda Like game.
got a character Process out of a tutorial,
it works quite well and i mostly understand it,
but i have to things i would like to change, tried it but with no good result.

Code:
Process MyCharacter (x,y);// Or whatever you want really
PRIVATE
dir=3; 
speed=-7;
status=0;
incx,incy;

	i;
	STRUCT run[3] //four directions
  STRUCT anim[5] //6 frames each animation
  	f; 
  END
	END=2,3,4,5,6,7, //right
         9,10,11,12,13,14, //left
           16,17,18,19,20,21, //up
           23,24,25,26,27,28; //down
	STRUCT stop[3] //four directions
  f;
	END=1,8,15,22;
BEGIN
ctype=c_scroll;   // He'll scroll with the background
scroll.camera=id; // The camera will focus on him during the scroll
LOOP
	IF (key(_left)) // left-key
  dir=1; //look at the correct direction
  status=1; //run
  incx=-4; //move horizontally
	ELSE
  IF (key(_right)) //right-key
  	dir=0; 
  	status=1;
  	incx=4;
  ELSE //neither left nor right are pressed
  	incx=0; //the chara's not moving horizontally
  	IF (key(_up)) //up-key
    dir=2;
    status=1;
    incy=-4;
  	ELSE
    IF (key(_down)) //down-key
    	dir=3;
    	status=1;
    	incy=4;
    ELSE //no key is pressed
    	incy=0; //don't move vertically
    	status=0; //keep still
    	i=0; //re-start animation
    	END
  	END
  END
	END
	
	x+=incx; //increase x
	y+=incy; //increase y


	//let's give a graph to the chara
	SWITCH (status)
  CASE 0: //stopped
  	graph=stop[dir];
  END
  CASE 1: //running
  	graph=run[dir].anim[i].f;
  	i=(i+1) mod 5; //i goes from 0 to 5
  END
	END

	FRAME;
END
END
thats the code..
ok my problems are,
i want, after moving the charakter in one direction, that it still looks in that direction..
it just looks in the right direction :(
the other thing is that its to fast (the animation), there is a speed control in the code but i doesnt make any change...
hope some of you can help me

EDIT:
here are screenshots of the game:
screen1.jpg

screen2.jpg
 
Code:
Process MyCharacter (x,y);// Or whatever you want really
PRIVATE
dir=3;
speed=-7;
status=0;
incx,incy;


//Working speed:
runspeed = 4;

i;
STRUCT run[3] //four directions
 STRUCT anim[5] //6 frames each animation
  f;
 END
END=2,3,4,5,6,7, //right
        9,10,11,12,13,14, //left
          16,17,18,19,20,21, //up
          23,24,25,26,27,28; //down
STRUCT stop[3] //four directions
 f;
END=1,8,15,22;
BEGIN
ctype=c_scroll;   // He'll scroll with the background
scroll.camera=id; // The camera will focus on him during the scroll
LOOP
IF (key(_left)) // left-key
 dir=1; //look at the correct direction
 status=1; //run
 incx=-runspeed; //move horizontally
ELSE
 IF (key(_right)) //right-key
  dir=0;
  status=1;
  incx=runspeed;
 ELSE //neither left nor right are pressed
  incx=0; //the chara's not moving horizontally
  IF (key(_up)) //up-key
   dir=2;
   status=1;
   incy=-runspeed;
  ELSE
   IF (key(_down)) //down-key
    dir=3;
    status=1;
    incy=runspeed;
   ELSE //no key is pressed
    incy=0; //don't move vertically
    status=0; //keep still
    i=0; //re-start animation
    END
  END
 END
END

x+=incx; //increase x
y+=incy; //increase y


//let's give a graph to the chara
SWITCH (status)
 CASE 0: //stopped
  graph=stop[dir].f;
 END
 CASE 1: //running
  graph=run[dir].anim[i].f;
  i=(i+1) mod 5; //i goes from 0 to 5
 END
END

FRAME;
END
END

Try this. Are you sure though you want to start with Ocarina of Time 2? Quite an ambitious project to start with?

Fenix picks color 0,0,0 in 16 bit mode and palette color 0 in 8 bit mode as black, Make sure the transparent color is at palette position 0 in your pixel program.
 
Thanks!!!
the animations are still to fast, perhaps you have another idea?

yes i started to write a story some time ago... and then i stopped working on it.
now i want to learn fenix and also want to make a zelda game so thought it might be a nice idea..
 
This
Code:
Process MyCharacter (x,y);// Or whatever you want really
PRIVATE
dir=3;
speed=-7;
status=0;
incx,incy;


//Working speed:
runspeed = 4;
animspeed = 2;

//Wait for a given amount of frames, looking in the specified direction
waitframes = 0;
waitdir;

i;
STRUCT run[3] //four directions
STRUCT anim[5] //6 frames each animation
 f;
END
END=2,3,4,5,6,7, //right
       9,10,11,12,13,14, //left
         16,17,18,19,20,21, //up
         23,24,25,26,27,28; //down
STRUCT stop[3] //four directions
f;
END=1,8,15,22;
BEGIN
ctype=c_scroll;   // He'll scroll with the background
scroll.camera=id; // The camera will focus on him during the scroll
LOOP
IF (key(_left)) // left-key
dir=1; //look at the correct direction
status=1; //run
incx=-runspeed; //move horizontally
ELSE
IF (key(_right)) //right-key
 dir=0;
 status=1;
 incx=runspeed;
ELSE //neither left nor right are pressed
 incx=0; //the chara's not moving horizontally
 IF (key(_up)) //up-key
  dir=2;
  status=1;
  incy=-runspeed;
 ELSE
  IF (key(_down)) //down-key
   dir=3;
   status=1;
   incy=runspeed;
  ELSE //no key is pressed
   incy=0; //don't move vertically
   status=0; //keep still
   i=0; //re-start animation
   END
 END
END
END

if(waitframes > 0)
  status = 0;
  waitframes--;
  //Set direction to the desired one
  dir = waitdir;
  //No moving!
  incx = 0;
  incy = 0;
end

x+=incx; //increase x
y+=incy; //increase y


//let's give a graph to the chara
SWITCH (status)
CASE 0: //stopped
 graph=stop[dir].f;
END
CASE 1: //running
 graph=run[dir].anim[i/animspeed].f;
 i=(i+1) % (6*animspeed); //i goes from 0 to 6*animspeed :)
END
END

FRAME;
END
END
Should do it :)
 
THANKS!!!
will try it later..
i finished now a rupee system ;)
its a process which will add a rupee to the screen
i have 3 types now
green, when you collect this you get 1 point
blue, when you collect this you get 5 points
and red, if you collect this one you get 20 points..

in the screenshot i just spawned some on the screen and collected a red one.
screen3.jpg


if you want to spawn one you have to add
rubine(x,y,rubcolor);
to the code...

EDIT:
tried it and its still the same.. :(
isnt it possible to do some kind of delay between the single spirtes for the animation?
 
Oops, bit too fast there, try replacing

graph=run[dir].anim[i%animspeed].f;

with

graph=run[dir].anim[i/animspeed].f;

And I think this is a mistake in the tutorial:

i=(i+1) % (5*animspeed); //i goes from 0 to 5*animspeed :)

should be

i=(i+1) % (6*animspeed); //i goes from 0 to 6*animspeed :)

since there are 6 frames of animation.

Sorry :)
 
no problem!
and YEAH IT WORKS!!!
THANK YOU SO MUCH...

ok i want to release a small demo...
nothing in here.. just link walking arround with no collision but he can collect rupees ;)
download it
 
yes...
right now im working on collision...
the world will first stay a picture (tiles are so complicated :( ) (until i get really used to fenix)
but only the backgrounds... (grass, houses etc)
bushes, chests etc wont be in the picture of the world
 
hmm why not just say
(key(_up) and key(_right))
... just as example..
hope this is what you mean
 
now another question by me with a similar problem ;)

i use this code for my rolling move:
Code:
IF (key(_right)and key(_a)) 
  dir=0; //direction 0,1,2,3
  status=3; //is the rolling animation
  incx=4; //movment in x
  dirx=2; //has to do with collision

so when i press both keys the charakter will roll arround the screen ;)
nice nice, but when you played zelda you know that there is a delay after you roll and also you have to move (press the direction) and then the A button..
how can i do this with fenix?
tryd several things but that wasnt that good :D
 
Changed something to do that in the code, see if you can make anything out of it. I was typing an explanation but then my mother came home, we had a long frustrating discussion about organizing a familyday and now I don't have the energy to type a big reply. Sorry, maybe later. :)
 
thanks!!!
the player stops now after he "rolled"
the things which are missing are now(for perfect zelda feeling ;) ):
you have to walk and then press a for rolling
if you press a the character roles for some time you dont have to keep the button pressed :)
so if you have time and want to help me with that, that would be nice..
 
Back
Top