Another Newbish Question - Animation


Twinbee

Tales From The Big Room
Joined
Jan 1, 2004
Messages
598
Age
37
Location
Essex, England
Website
Visit site
I'm really sorry about all of these posts filled with really silly questions. :)

I have two PNGs in my FPG, which I want the program to toggle between at a certain speed while moving... No fancy animation or anything, just to toggle between these two graphics only while the character is moving.

How would I go about doing this?
 
idunno what a png is....
but
Code:
PROCESS blah();
private
animation=0;
BEGIN
timer[0]=0;
animation=timer[0];
x=(insert x value);
y=(insert y value);
graph=1; //for example
LOOP
FRAME;
if(animationr+3<timer[0])
  if(graph==1)
  graph=2;
  ELSE
  graph=1;
  end
animation=timer[0];
end
END
END
i think that ought to work....
 
beherits way is good, but I wanted to show the way I use:

Code:
//in you player process:

graph=1 //or use the numbers in your fpg

loop
  if(not key(_left) and not key(_right))graph=1;end; //extra sprite for standing
  if(key(_left)) //walking left
    flag=0; // 0, if your sprite is facing left
    x--; //or how fast you want you player to walk
    graph++;
    if(graph>2)graph=2;end; // this switches between graph 2 and 3
   end;
  if(key(_right))  //walking right
    flag=1; // 1, if your sprite is facing left
    x++; //or how fast you want you player to walk
    graph++;
    if(graph>1)graph=1;end; // this switches between graph 2 and 3
   end;
  frame;
end;
 
Quiest posted on Mar 26 2005 at 02:38 AM said:
beherits way is good, but I wanted to show the way I use:

Code:
//in you player process:

graph=1 //or use the numbers in your fpg

loop
  if(not key(_left) and not key(_right))graph=1;end; //extra sprite for standing
  if(key(_left)) //walking left
    flag=0; // 0, if your sprite is facing left
    x--; //or how fast you want you player to walk
    graph++;
    if(graph>2)graph=2;end; // this switches between graph 2 and 3
   end;
  if(key(_right))  //walking right
    flag=1; // 1, if your sprite is facing left
    x++; //or how fast you want you player to walk
    graph++;
    if(graph>1)graph=1;end; // this switches between graph 2 and 3
   end;
  frame;
end;

:-D amazing how we both missed one little bit.
i suggest, in the light of the above code, this:
Code:
PROCESS blah();
private
animation=0;
BEGIN
timer[0]=0;
animation=timer[0];
x=(insert x value);
y=(insert y value);
graph=1; //for example
LOOP
FRAME;
if(not key(_left) and not key(_right))
graph=1;
ELSE
if(animation+3<timer[0])
 if(graph==2)
 graph=3;
 ELSE
 graph=2;
 end
animation=timer[0];
end
end
if(key(_left))
x--;
flag=0;
end
if(key(_right)
x++;
flag=1;
end
END
END
if you wanted a more complex (ie, more than two frames) animation, all you need do is this.
Code:
if(animation+3<timer[0])
 if(graph<5)//for instance
 graph++;
 ELSE
 graph=2;
 end
animation=timer[0];
end
end
which is really no more difficult.:)
hope that helps
 
Last edited by a moderator:
Sorry, but I would just like to know... what are the x,y, and graph variables? I know there somehow built in because I can't declare them as regular variables, so what do they do? Also, is there some kind of tutorial for this for Fenix in general. I tried looking on some fenix websites but didn't find many tutorials at all. Maybe I'm missing something but I don't seem to understand what all these
 
x,y,graph are some of the local variables that are already declared for all processes, automatically, by Fenix. x and y represent the coordinates of the process graphic relative to the screen grid, and graph represents the number of the graphic file from your FPG library.

Use the search tool to find Chapter 0, 1, and 2 by EvilDragon, those should give you the heads up.
 
Back
Top