Message Board


Message Board > Fenix / Bennu / Gemix / DIV > new with some questions

February 22, 2011, 10:30
Dennis
どこかにいる
2092 posts

About your platform game: It doesn't look that bad, but you use awfully small numbers like acceleration 3 instead of 20 or something. And the animation must go extremely fast if you just flip 2 images, or is it a road runner game? :)

you can set the FPS with set_fps. you must know, if you have 60 frames per second: this means if you swap the image once per frame, as in your example, it swaps 60 times per second, this is useful to animate electricity, but not a character.
____________
Kwakkel
#
February 22, 2011, 15:48
Rincewind
programmer
1545 posts

To easily copy the following code to your .prg file, I pasted it at Pastebin, here.

Fenix code:
Program platform_engine;
Global
        Playerfpg;
        Ground_height=200;         
Begin
        Set_mode(320,240,8);
        Set_fps(40,0);
   
        PlayerFPG=load_fpg("Player.fpg");

        Map_clear(0,0,RGB(0,0,0));
        Write (0, 64, 16, 1, "Platform Game");

        Player(PlayerFPG,1,50,200);

        Loop
                If (key(_esc))
                        Exit("Bye",0);
                End
                Frame;
        End
End


Process Player(file,graph,x,y)
Private
        xspeed=8;
        yspeed=0;

        y_start_acceleration=5;
        y_acceleration=0;

        jump=0;

Begin
        Loop
                // Walking
                If (key(_left) or key(_right))
                        If (graph==1)
                                graph=3;
                        Else
                                graph=1;
                        End
                       
                        If (key(_left)-key(_right)>0)
                                flags=1;
                                x-=xspeed;
                        Else
                                flags=0;
                                x+=xspeed;
                        End
                Else
                // Standing still
                        graph=1;
                End

                // Jumping
                If (jump==0)
                        If(key(_space))
                                jump=1;
                                y_acceleration=y_start_acceleration;   
                        End
                Else           
                        y_acceleration-=1;
                        If (y=>ground_height)
                                jump=0;
                                y=ground_height;
                                y_acceleration=0;
                                yspeed=0;
                        End
                End

                yspeed+=y_acceleration;        
                y-=yspeed;
                       
                Frame;
        End
End



Judging from the code you had first, it seems you don't understand basic things like how the parameters of processes work, so look them up at the Fenix wiki here. If you would study the space game example it would become more clear.

You asked to help with your second FPG, but there's an image of a tile inside. I am not going to program a tile based game for you, you won't understand a bit of it. Once again first fully understand the space game I wrote out for you, and expand upon it yourself. If you're not willing to learn the basics that way it's going to be a lot harder if not impossible for you, and we're not going to write a platformer for you!
____________
Personal website: http://www.loijson.com
#
February 22, 2011, 16:27
Dennis
どこかにいる
2092 posts

Quoting Rincewind:
... and we're not going to write a platformer for you!


for free, that is!


:D
____________
Kwakkel
#
February 22, 2011, 23:24
DoctorN
Whiskered
91 posts
actually i would pay someone to make an engine itself for me :), i was just wandering i can can spawn multiples of that tile on the ground and make points all around it.
____________
#
February 22, 2011, 23:36
DoctorN
Whiskered
91 posts
thank you for the code! i needed this to get started :) yes i will read the wiki. i set the fps to about 25 cause 40 was a little too fast. whenever you post code with the [code] thing, i cant seem to copy it right (even in paste bin), i had to quote you and cope the code from there and
it copied right. thanks
____________
#
February 24, 2011, 16:00
Dennis
どこかにいる
2092 posts

I was joking around. I don't want any payment for such thing. Maybe it's useful experienced people make tutorials and share them somewhere on the net.
____________
Kwakkel
#
February 26, 2011, 05:01
DoctorN
Whiskered
91 posts
one thing though, in the part when its walking. how can i make it go between animations 3,4, and 5?
____________
#
February 26, 2011, 05:45
DoctorN
Whiskered
91 posts
to be more technical, picture megaman. imagine his walk movements 3,4,5. it goes (on repeat) 3 -> 4 -> 5 -> 4 -> 3 -> 4 -> you get what i mean. I tried setting a speed of the animation but the game got too many errors (i think i did something wrong from the wiki). im sure if you find a nes gameplay of megaman, you can picture the speed you see the sprites in your head. how would i incorporate that? the wiki didnt really seem to tell me.

as for jumping, i was able to get it that if its graph 1, it will jump. but not while walking, when you start walking, it goes to the walking animation. now, i have actually placed global variables throughout the code that when walking, it makes walking true, and everything else false; jumping, same thing; standing, you know what i mean. would these server any purpose where i can make a section of code saying like:

if Walking=true;
graph=3,4,5,4;
if Standing=true;
graph=1;
if Jumping=true;
graph=2;

along those lines? thanks

[Edited on February 26, 2011 by DoctorN]
____________
#
February 26, 2011, 20:33
DoctorN
Whiskered
91 posts
and i would like to have it that you dont hold down the jump button to keep jumping. you have to press it every time. i found on the wiki:
http://www.fenixdocs.com/index.php/Timer
that i could use this. how could i incorporate this into it? i tried putting it into the code but it didnt work. i want it there just so you cant hold down the space bar, but you can press it again no sooner the second you touch the ground.
____________
#
February 28, 2011, 05:42
DoctorN
Whiskered
91 posts
Quote:
Process Level(file,graph,x,y)
Private
        int map;
Begin
       
    map = new_map(100,100,8);
   
    map_clear(0,map,rgb(255,0,0));
   
    put(0,map,160,100);
   
    Loop
            frame;
    End
End


I also put this in the game (got it from the wiki, word for word), but nothign showed up (didnt get any errors) so if you could shed some light on this it would be greatful. also, what could i do to turn this map into an image? would i have to add points for every pixel in the fpg?
____________
#
February 28, 2011, 16:03
Dennis
どこかにいる
2092 posts

I haven't been doing bennu/fenix/div for years but I used to make an array.


g_animation[] = 3,4,5,4;

and then you COULD use timer or skip frames. I used to skip frames with an interval variable, creating somethign like this:

(It could have syntax errors)

Fenix code:
process player
private
  p_animation[] = 3,4,5,4;
  p_interval = 0;
  p_graph_i = 0;
end
begin
  loop
    graph = p_animation[p_graph_i++];
    if (p_interval > 3)
       p_graph_i ++;
       if (p_graph_i > 3)
          p_graph_i = 0;
       end
       p_interval = 0;
    end
    frame;
  end
end


However, there is probably a better way to do this, since my way is 10 years old from the days I didn't know much about programming.

[Edited on February 28, 2011 by Dennis]
____________
Kwakkel
#
March 1, 2011, 03:42
DoctorN
Whiskered
91 posts
it will run through that animation once and when thats done, it will make it the standing sprite once more and you dont seem to be moving but when you let go, you "warp"
____________
#
March 1, 2011, 04:29
DoctorN
Whiskered
91 posts
how can i make the jump graph last from when you start the jump to when you land? i put it it in this bit of code:

// Jumping
If (jump==0)
If(key(_space))
graph=2;
jump=1;
____________
#
March 1, 2011, 11:23
Dennis
どこかにいる
2092 posts

Here is a basic gravity system I used:

Fenix code:
private
  g_speed = 8;
end
loop
  y+=g_speed;
  g_speed++;

  if g_speed > 8
    g_speed = 8;
  end

  if (key(_space) and jump == 0)
     g_speed=-8; // player will jump.
     jump = 1;
  end
  while (touch_floor_or_object)
    jump=0; //jump ended
    y--; //move the player out of the floor
    // do not use a frame statement because we don't want to see it happen
  end
  frame; // send the (changed) coordinates to the screen
end


It's not perfect but I hope you can do something with it.

It may have bugs, I don't have the application to test it and my head may not be enough. XD
____________
Kwakkel
#
March 2, 2011, 03:05
DoctorN
Whiskered
91 posts
hmmm.... i dont think you really knew what i wanted (thanks anyways though). What I want is:
how can i make the jump graph permant as long as your jumping? when you land, your back to normal.
&
how can i make the animtion go through 3,4,5,4 and repeat? i tried what you helped me with, i tried the wiki, but nothings helping. heres my code (bits and peices from your help are in it):
Quote:
Program platform_engine;
Global
    Playerfpg;
    Ground_height=200;
    Standing=true;
    Walking=false;
    Jumping=false;
    Level;   
Begin
    Set_mode(320,240,8);
    Set_fps(25,0);

    PlayerFPG=load_fpg("Player.fpg");

    Map_clear(0,0,RGB(0,0,0));
    Write (0, 64, 16, 1, "Platform Game");

    Player(PlayerFPG,1,50,200);

    Loop
        If (key(_esc))
            Exit("Bye",0);
        End
        Frame;
    End
End


Process Player(file,graph,x,y)
Private
    xspeed=3;
    yspeed=0;

    y_start_acceleration=4;
    y_acceleration=0;

    jump=0;
   
    p_animation[] = 3,4,5,4;

p_interval = 0;

p_graph_i = 0;

g_speed = 8;

Begin
    Loop
        // Walking
        If (key(_left) or key(_right))
            graph = p_animation[p_graph_i++];
if (p_interval > 3)
p_graph_i ++;
if (p_graph_i > 3)
p_graph_i = 0;
end
p_interval = 0;
                Standing=false;
                Jumping=false;
                Walking=true;
            End
           
            If (key(_left)-key(_right)>0)
                flags=1;
                x-=xspeed;
            Else
                flags=0;
                x+=xspeed;
            End
        Else
        // Standing still
            graph=1;
            Standing=true;
            Walking=false;
            Jumping=false;
        End

        // Jumping
        If (jump==0)
            If(key(_space))
            graph=2;
                jump=1;
                Standing=false;
                Walking=false;
                Jumping=true;
                y_acceleration=y_start_acceleration;   
            End
        Else       
            y_acceleration-=1;
            If (y=>ground_height)
                jump=0;
                y=ground_height;
                y_acceleration=0;
                yspeed=0;
            End
        End

        yspeed+=y_acceleration;       
        y-=yspeed;
           
        Frame;
    End
End

Process Level(file,graph,x,y)
Private
        int map;
Begin
       
    map = new_map(100,100,8);
   
    map_clear(0,map,rgb(255,0,0));
   
    put(0,map,160,100);
   
    Loop
            frame;
    End
End


howcome you dont have the program?
____________
#
March 9, 2011, 09:42
Dennis
どこかにいる
2092 posts

I think someone needs to take over your PC for that. :O

I'm sorry that I'm not of much help. I don't program Fenix anymore so all I can provide are things in my brain from 5 years ago.

I don't see any system how you make your character check when you touch the ground.

Basically you just have to check in the main loop wether the character is in the air (not only when jumping, but also falling) and change the graph accordingly.

There are many many ways to do this though.

[Edited on March 9, 2011 by Dennis]
____________
Kwakkel
#

Page 1 , 2


Message Board > Fenix / Bennu / Gemix / DIV > new with some questions

Quick reply


You must log in or register to post.
Copyright © 2005 Booleansoup.com
Questions? Comments? Bug reports? Contact us!