A Few Questions About Fenix.


plopperz

Huh?
Joined
Mar 27, 2008
Messages
1,050
Website
Visit site
After many hours of trying, I finally got Fenix setup on my Mac. I did ED's tutorials and looked at some of the documented source and snippets, but I still have some questions:

How to I change the speed of a controlled object?




How do I make a projectile move on an arc (like throwing rather than shooting)?




How do I create make a collision with an object other than the boundry? (Sorry I know this sounds confusing, but if the character collides with a building within the game's boundries)




Also, are there any slightly more advanced tutorials than the ones on FenixOnFire?


Any help would be greatly appreciated.
 
PlopperZ said:
How to I change the speed of a controlled object?
Well, I'm not sure how you're doing it now, but I'm assuming you've created a process which has a map controllable by the x and y variable. You could try increasing your x or y increment with each frame: x+=2 or y+=2 instead of x++ or y++....

Try posting some of your own source code here and we can have a look.

PlopperZ said:
How do I make a projectile move on an arc (like throwing rather than shooting)?
The motion of a throwing arc is determined by gravity. Horizontal velocity would be constant (x+=1 with each frame) but the y position would depend on your vertical velocity, which changes with gravity. The formula for distance in a gravitiational field is:

d = (1/2)*a*t^2;

So you could say y = step*step/scale.. where y increases going down on the fenix screen, step is your timestep, and scale is some factor to make sure it doesn't go too fast.

To move in a circle (which isn't a parabola like gravity), you'd use the sin and cos functions.

PlopperZ said:
How do I create make a collision with an object other than the boundry? (Sorry I know this sounds confusing, but if the character collides with a building within the game's boundries)
I'm not sure about actual collisions between maps. Fenix may have a native way to check for it.

You could do some math where one process checks the position of another to see if they've come within some distance of each other, say:

dist = sqrt((x2-x1)^2+(y2-y1)^2); // where x1, y1 is the center of first object, x2, y2 is center of second)
if (dist<10) // centers are 10 pixels apart
...
end

Processes can see each other's x and y position. You could either have a third process check for a collision, or have the main process do this, or have one of the two objects check for a collision.


PlopperZ said:
Also, are there any slightly more advanced tutorials than the ones on FenixOnFire?

Any help would be greatly appreciated.
Well, Fenix isn't the best language to learn programming on. In terms of learning the language itself, the fenixwiki is best.... http://fenixdocs.com/index.php . Sometimes you have to look at the original documentation.. Spanish to English translation can be done by babelfish in a pinch.

Hope this helps!
 
Last edited by a moderator:
hi,
I don't have any of my actual code because i wanted to know exactly what i needed to do before i started it, so I quickly edited an example source, which is probably what my game will be based around.

CODE
program scrolltest;

const



global



local



begin

SET_MODE(320,240,8);

LOAD_FPG("scroll.fpg");

scroller();

end

process scroller()

begin

START_SCROLL(0,0,3,0,0,3); scroll[0].camera=block(160,120);



track(320,240);

end


process block(realx,realy)

graphic;

begin

graphic=blockgraphic(160,120);

loop

frame;

if(key(_right)and realx<640)realx+=5;end

if(key(_left) and realx>0)realx-=5;end


x=realx;
y=realy;

if(x<160)x=160;end

if(y<120)y=120;end

if(x>480)x=480;end

if(y>360)y=360;end

graphic.x=realx;

graphic.y=realy;

end

end



process blockgraphic(x,y)

begin

graph=2;

ctype=c_scroll;
loop

frame;

end

end



process track(x,y);

private

col;
begin

ctype=c_scroll;

write_int(0,160,120,0,&col);

graph=3;

col=COLLISION(type blockgraphic);
graph=0;

frame;

end

end
 
Right, to change the speed of the object, in this part

CODE
if(key(_right)and realx<640)realx+=5;end

hange the number added onto it
e.g
CODE
if(key(_right)and realx<640)realx+=2;end

The number is how many pixels to move each frame.
You can do this in all instanes of code like this.

With collision between an object and another process, it's simply

CODE
If(collision(type PROCESS)) dosomething; End

obviously you need ot replace PROCESS with the procss needed and dosomething which whatever you want to happen. If it's with the background, then you need to look up hardness maps on fenixonfire.
 
Back
Top