help with my platformer game

Started by MisterN, March 04, 2011, 03:34:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MisterN

hopefully someone is nice enough to donate a little time to get my "megaman-esque" engine started off the ground. Im not really that good because there really are no tutorials for fenix/bennu. I need help with fenix first, because in my introduction to these forums, I stated im making a dreamcast homebrew game (and there no bennu for dremacast D:) so the only way I can make it is with fenix, then when I get to the pc ill upgrade it into bennu (sounds fair enough, dont you think?). Seeing as though the two are similar (in what I need help with, im sure some of you know how to use fenix), thats why i cam here, booleansoup was too lazy to help, and most, if not all other forums are lazy too. I will make a double post (the second will have my code). The problems I am having though are:
*the character animaton doesnt work right, that whole area is "unpolished" because ive messed with the code so much there so the whole animation thing is incomplete (cause I was tweaking and someone closed out so I couldn't undo anything). i just want it to through frames (or graphs) 3,4,5,4,3,4,5,4, etc, etc.
*I cant get the jump graph to stay while hes jumping. The walk animation takes over if i move, and besides that the jump animation last about a split second. you'll see what I mean.
*I have the ground set to specific coordinates; how can I make the ground appear as an image (a mask, if you will) and he collides with anything thats not transparent (even though the image is invisible, like a mask), I set the character to spawn higher than the ground, but he didnt fall until i jumped.

thats all i need help with for now. :) thanks
werg

MisterN

Program platform_engine;
Global
   Playerfpg;
   Ground_height=200;      
Begin
   Set_mode(320,240,8);
   Set_fps(20,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;
   
   player_animation[] = 3,4,5,4;

Begin
   Loop
      // Walking
      If (key(_left) or key(_right))
         If (graph==1)
            graph=player_animation;
         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
werg

FreeYourMind

You have an error:

If (key(_left)-key(_right)>0)
            flags=1;
            x-=xspeed;
         Else


Zip

#3
please
add
code tag on your game source
use
[.code]
whithout dot

MisterN

ok ill do that next time. and FreeYourMind, what do you mean by error? could you show me whats correct then?
werg

Zip

key(left)-key(right)>0
its no sense

whit - you mean AND ?
what you want to do whit >0?

Drumpi

The best way to work with animations (I supose) its to work with character status: create a private variable, like "char_status", and give it values, 0 if it stands, 1 if it walks, 2 if it jumps.
Then, almost finishing the main loop of your character process, use a switch-case with "char_status" to change GRAPH.
You can use more variables if an animation secuence has more status, delay, or else.

Separate the graph section helps you if you need to add more status or change graphics.

With collision, i don't like to use collision with a big map, we recomend to use "hardness maps", they are maps stored in memory (loaded, but not assigned to a process). Then you can use map_get_pixel function to get a pixel from this map and act as you need.
Hala, como con 1001 procesos sólo va a 9 FPS, vamos a meterle 32 veces más, a ver si revienta.
(Drumpi epic moment)

MisterN

Quote from: Zip on March 04, 2011, 01:20:47 PM
key(left)-key(right)>0
its no sense

whit - you mean AND ?
what you want to do whit >0?

I have no idea, someone on booleansoup told me to use that code. it works though.
werg

Zip

#8
i never worked in Fenix but i so strange that code :-[
if it work ok..

for animation you have seen yet the "taller fenix" example?

that..

ps: why The .7z format is not allowed T_T

MisterN

[code language="fenix"]
Program platform_engine;
Global
   Playerfpg;
   Ground_height=200;
   
   //initializes the player's sprites
   int Player_graph[5];
   
   //initializes the level
   int level;
   int levelmask;
      
Begin
   Set_mode(320,240,16);
   Set_fps(20,0);
   
   PlayerFPG=load_fpg("Player.fpg");

   Map_clear(0,0,RGB(0,0,0));
   Write (0, 64, 16, 1, "Platform Game");
   
   // PlayerWalk Animations
   Player_graph[0]=load_png(".\sprites\player\Walk1.png");
        Player_graph[1]=load_png(".\sprites\player\Walk2.png");
        Player_graph[2]=load_png(".\sprites\player\Walk3.png");
  Player_graph[3]=load_png(".\sprites\player\Walk2.png");
  Player_graph[4]=load_png(".\sprites\player\Stand.png");
  Player_graph[5]=load_png(".\sprites\player\Jump.png");

   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;
   
   int i;
   int ii;

Begin
   Loop
      // Walking
      If (key(_left) or key(_right))
         If (graph==Player_graph[4])
            graph=Player_graph;;
            //Animation for movement
  • thru [3]
                i=(i+1)%4;
             End
             
             If (key(_left)-key(_right)>0)
                flags=1;
                x-=xspeed;
             Else
                flags=0;
                x+=xspeed;
             End
          Else
          // Standing still
             graph=Player_Graph[4];
          End

          // Jumping
          If (jump==0)
             If(key(_space))
                jump=1;
                graph=Player_Graph[5];
                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
    [/code]

    Ok I got stuff working. However, heres my issue:
    *I try to get the walking animation to work, but it does only 1 of the 4, its not animation (i wish there was a load_gif feature)
    *I took some code from the taller fenix to make stuff simpler, but it makes the game freeze upon starting up (look in caydaysalto.prg from lines 144 -> 153)
    *I figured out a jump thing where in the "//standing still" part of my code i put if(jump==0) and it worked, however pressing right or left crashed the game.

    so im stuck.
werg

Zip

try to use separated control

If (key(_left)
flags=1;
x-=xspeed;
end
if (key(_right)
flags=0;
x+=xspeed;
End

Drumpi

If (graph==Player_graph[4])
graph=Player_graph[i];;
//Animation for movement [0] thru [3]
i=(i+1)%4;
End


You only enter this code one time, just before your character is standing. Check the IF condition (maybe you don't need it) if you want to access it every frame.
Hala, como con 1001 procesos sólo va a 9 FPS, vamos a meterle 32 veces más, a ver si revienta.
(Drumpi epic moment)

MisterN

it works perfectly. testing it on the dreamcast however, the .pngs did not show up. how can i make the "./.png" part of the code become a graph from an .fpg?
werg

Zip


Drumpi

You can create FPGs with FPGEdit, FPGEdit2009 or your own aplication using FPG_ADD y SAVE_FPG on PC (there are other aplications, but they arent finished or don't remember its name ^^U).
Hala, como con 1001 procesos sólo va a 9 FPS, vamos a meterle 32 veces más, a ver si revienta.
(Drumpi epic moment)