Bennu Game Development

English Forums => General => Topic started by: MisterN on March 21, 2011, 10:56:48 PM

Title: instead of seperate map
Post by: MisterN on March 21, 2011, 10:56:48 PM
ok i learned how to export to map but that didn't help anything :S so since i have to do fpg's, id like to know if i can easily translate this code:
Player_graph[12]=load_png(".\sprites\player\Stand.png");
can i simply go?
Player_graph[12]=graph(1);
i tried it but i got an error. all the images are addressed in the Begin after global of my program code. i dont want to reinvent my long lines of code since ive come this far already, is there anything that can easily turn:
Player_graph[12]=load_png(".\sprites\player\Stand.png");
into a code that involves graphs? not .pngs? thanks
Title: Re: instead of seperate map
Post by: Drumpi on March 22, 2011, 01:00:06 AM
Emmm, i don't know what are you trying to do.
First, you must load graphics with load_png, load_map or load_fpg, if you didn't, the program don't know what file are you talking about.

If you want to load several images, you can use a FPG file. You can put 999 graphics on every FPG, and use a single line to load all.
Title: Re: instead of seperate map
Post by: MisterN on March 22, 2011, 01:30:13 AM
I did this and got no errors but what happened was:
*you didnt see the player, instead you got the background level (weird)
[code language="fenix"]
    Player_graph[0]=load_fpg(3);
    Player_graph[1]=load_fpg(3);
    Player_graph[2]=load_fpg(3);
    Player_graph[3]=load_fpg(4);
    Player_graph[4]=load_fpg(4);
    Player_graph[5]=load_fpg(4);
    Player_graph[6]=load_fpg(5);
    Player_graph[7]=load_fpg(5);
    Player_graph[8]=load_fpg(5);
    Player_graph[9]=load_fpg(4);
    Player_graph[10]=load_fpg(4);
    Player_graph[11]=load_fpg(4);
    Player_graph[12]=load_fpg(1);
    Player_graph[13]=load_fpg(2);[/code]

so what am i doing wrong now?
Title: Re: instead of seperate map
Post by: SplinterGU on March 22, 2011, 01:31:44 AM
load_fpg need a string argument... you don't must use a numeric value.

graph(N) requiere a function named graph... bennugd don't have it.
Title: Re: instead of seperate map
Post by: MisterN on March 22, 2011, 01:34:32 AM
im using fenix first for the dreamcast
Title: Re: instead of seperate map
Post by: SplinterGU on March 22, 2011, 01:36:29 AM
my response is valid for fenix too.
Title: Re: instead of seperate map
Post by: Drumpi on March 22, 2011, 01:41:44 AM
You are doing it wrong, you must do:

file_id=load_fpg("my_dir/my_file.fpg");
then you can use FILE_ID in every FILE process variable, and any value between 1 and 999 in his graph value.

Or if you want:
loaded_graph1=load_png(".\sprites\player\Stand.png");
loaded_graph2=load_png(".\sprites\player\Jump.png");
loaded_graph3=load_png(".\sprites\player\Walk1.png");
loaded_graph4=load_png(".\sprites\player\Walk2.png");
loaded_graph5=load_png(".\sprites\player\Walk3.png");
loaded_graph6=load_png(".\sprites\player\Fall.png");

Player_graph[0]=loaded_graph3;
Player_graph[1]=loaded_graph3;
Player_graph[2]=loaded_graph3;
Player_graph[3]=loaded_graph4;
Player_graph[4]=loaded_graph4;
Player_graph[5]=loaded_graph4;
Player_graph[6]=loaded_graph5;
Player_graph[7]=loaded_graph5;
Player_graph[8]=loaded_graph5;
Player_graph[9]=loaded_graph4;
Player_graph[10]=loaded_graph4;
Player_graph[11]=loaded_graph4;
Player_graph[12]=loaded_graph1;
Player_graph[13]=loaded_graph2;
Title: Re: instead of seperate map
Post by: MisterN on March 22, 2011, 01:45:36 AM
the or code game me an error saying it doesnt know what loaded_graph is

and with the file_id=load_fpg("my_dir/my_file.fpg"); do i have to put it on top of everything or just type it once then do all the status=graph things?
Title: Re: instead of seperate map
Post by: SplinterGU on March 22, 2011, 01:54:36 AM
loaded_graph2, are sample vars that use drumpi for explain this to you.

the local var file must be set with the fpg's id (previous loaded) of you graph collection.
Title: Re: instead of seperate map
Post by: Drumpi on March 22, 2011, 01:56:15 AM
Again, don't read the code literally, loaded_graph is a variable that you define with the name you want.

I don't understand the second part. You can use LOAD_FPG to load the file, this give you an ID number similar as FOPEN on C, this number is used on FILE local variable of every process to know what set of graphics must use.
Inside this set, you can found lots of images, they are numerated, and you can use their numbers in GRAPH variables on every process that uses this FILE.
Title: Re: instead of seperate map
Post by: MisterN on March 22, 2011, 02:24:48 AM
oierjvowiejrv
frustrating...

with that whole file_id thing, where do i put it? ive already got eh fpg loaded, now what. just show me, so i cna do this for everything else. how can i convert
[code language="bennu"]
Player_graph[0]=load_png(".\sprites\player\Walk1.png"); 
    Player_graph[1]=load_png(".\sprites\player\Walk1.png"); 
    Player_graph[2]=load_png(".\sprites\player\Walk1.png"); 
    Player_graph[3]=load_png(".\sprites\player\Walk2.png"); 
    Player_graph[4]=load_png(".\sprites\player\Walk2.png"); 
    Player_graph[5]=load_png(".\sprites\player\Walk2.png"); 
    Player_graph[6]=load_png(".\sprites\player\Walk3.png"); 
    Player_graph[7]=load_png(".\sprites\player\Walk3.png"); 
    Player_graph[8]=load_png(".\sprites\player\Walk3.png"); 
    Player_graph[9]=load_png(".\sprites\player\Walk2.png"); 
    Player_graph[10]=load_png(".\sprites\player\Walk2.png"); 
    Player_graph[11]=load_png(".\sprites\player\Walk2.png"); 
    Player_graph[12]=load_png(".\sprites\player\Stand.png"); 
    Player_graph[13]=load_png(".\sprites\player\Jump.png");
[/code]

to fpg code, words arent going to help me that well on this one unless it is so finely detailed cause im stuck in a pickle
Title: Re: instead of seperate map
Post by: MisterN on March 22, 2011, 03:51:44 AM
hmmm i know i can do it easily if each fpg is one image... nope scratch that
Title: Re: instead of seperate map
Post by: FreeYourMind on March 22, 2011, 08:26:31 AM
Karma: -3  !!!!

You have new world record  ;D
Title: Re: instead of seperate map
Post by: MisterN on March 22, 2011, 12:38:10 PM
I dont even think that karma can go negative XD
Title: Re: instead of seperate map
Post by: handsource-dyko on March 22, 2011, 06:37:57 PM
I recommend reading these wiki pages:  http://wiki.bennugd.org/index.php?title=Fpg_new (http://wiki.bennugd.org/index.php?title=Fpg_new), http://wiki.bennugd.org/index.php?title=Fpg_add (http://wiki.bennugd.org/index.php?title=Fpg_add), http://wiki.bennugd.org/index.php?title=FileID (http://wiki.bennugd.org/index.php?title=FileID), http://wiki.bennugd.org/index.php?title=GraphID (http://wiki.bennugd.org/index.php?title=GraphID).

Title: Re: instead of seperate map
Post by: Drumpi on March 22, 2011, 08:43:45 PM
loaded_fpg=load_fpg(".\sprites\player\megaman.fpg");
Player_graph[0]=3;
Player_graph[1]=3;
Player_graph[2]=3;
Player_graph[3]=4;
Player_graph[4]=4;
Player_graph[5]=4;
Player_graph[6]=5;
Player_graph[7]=5;
Player_graph[8]=5;
Player_graph[9]=4;
Player_graph[10]=4;
Player_graph[11]=4;
Player_graph[12]=1;
Player_graph[13]=2;


So you must assign loaded_fpg to every FILE variable of every process who use it, and assign to GRAPH the Player_graph[the_number_you_want].
Title: Re: instead of seperate map
Post by: MisterN on March 23, 2011, 12:30:19 AM
thanks :) a demo of my engine might be done soon, im thinking of writing a book one day for fenix/bennu after ive learned enough
Title: Re: instead of seperate map
Post by: MisterN on March 23, 2011, 02:40:21 AM
hmmm heres the problem (look at the pic for more info, look at the code too for more info)
*i set each individual fpg but, if theres only one of that object, then it shows up as the player, anything after the first (like the pellets) will be the correst sprite. any help?
[code language="fenix"]
Program platform_engine; 
//these are global variables 
Global

   //initiliazes the fpg's used in the game
   playerfpg;
   enemy_x_fpg;
   pelletfpg;
 
    //initializes the player's sprites 
    int Player_graph[14];
 
    //initializes the enemy(s) sprites
    //letter of alphabet sorts out the enemies
    int enemy_x_graph[12];
 
   //initializes the collectibles sprites
   int pellet_graph[1];
 
    //initializes the level 
    int level; 
    int levelmask; 
 
//this sets up things like the games resolution and whatnot     
Begin 
    Set_mode(320,240,16); 
    Set_fps(20,0);   
 
    Map_clear(0,0,RGB(0,0,0)); 
    Write (0, 64, 16, 1, "Platform Game"); 
 
    //sets the levels background images
    level=load_png(".\sprites\level\image\test-1.png"); 
    levelmask=load_png(".\sprites\level\mask\test-1.png"); 
 
    Player(playerfpg,50,100);
 
    EnemyX(enemy_x_fpg,290,100);
 
   pellet(pelletfpg,100,200);
   pellet(pelletfpg,116,200);
   pellet(pelletfpg,132,200);
   pellet(pelletfpg,148,200);
 
    start_scroll(0,0,level,0,0,0); 
 
    Loop 
        If (key(_esc)) 
        Exit("Bye",0); 
        End 
        Frame; 
    End 
End 
 
//This process is for the player, all code that belongs to him is in this part 
Process Player(file,x,y) 
Private
    xspeed=3; 
    yspeed=0; 
 
    y_start_acceleration=4; 
    y_acceleration=0; 
 
    int fall; 
    int falling;    //indicate if character is in falling mode or not 
 
    jump=0; 
 
    int i; 
    int ii;         //you must say: counter to test every pixel of movement of hardness map 
    int pixel; 
    int red,blue,green; 
 
    int player_status; //0 is standing, 1 is walking, 2 is jumping, 3 is falling 
 
 
Begin
   //loads the fpg
   playerfpg=load_fpg(".\sprites\player\player.fpg");
   //PlayerWalk Animations; it a good idea to repeat the same sprite 3 times so it doesn't 
    //look sped up unless you have many detailed frames, you can add as many as you want, just 
    //be sure to change int Player_graph[X] to the number of sprites you have (0 included, so 
    //its one number higher than the last Player_graph[X] you have 
   Player_graph[0]=2;
   Player_graph[1]=2;
   Player_graph[2]=2;
   Player_graph[3]=3;
   Player_graph[4]=3;
   Player_graph[5]=3;
   Player_graph[6]=4;
   Player_graph[7]=4;
   Player_graph[8]=4;
   Player_graph[9]=3;
   Player_graph[10]=3;
   Player_graph[11]=3;
   Player_graph[12]=1;
   Player_graph[13]=5;
    ctype=c_scroll; 
    Loop 
        //Player Movement 
        if (key (_left)) 
            flags = 1; 
            ii = 0; 
            while (ii <4) 
                pixel = map_get_pixel(0, levelmask, x-16, y); 
                get_rgb (pixel, & red, & green, & blue); 
                if (blue>200) 
                    ii = 0; 
                    break; 
                else 
                    if (player_status!=2 and player_status!=3) player_status=1; end 
                end 
                ii = ii + 1; 
            end 
            x = x-ii; 
        end 
        if (key (_right)) 
            flags = 0; 
            ii = 0; 
            while (ii <4) 
                pixel = map_get_pixel(0, levelmask, x + 16, y); 
                get_rgb (pixel, & red, & green, & blue); 
                if (blue>200) 
                    ii = 0; 
                    break; 
                else 
                    if (player_status!=2 and player_status!=3) player_status=1; end 
                end 
                ii = ii + 1; 
            end 
            x = x + ii; 
        end 
 
        if (!key(_left) and !key(_right) and player_status==1) 
            player_status=0; 
        end 
 
        // Jumping 
        if (key (_space)) 
            player_status=2; 
            falling=true; 
            pixel = map_get_pixel(0, levelmask, x, y +1 +15);   
            get_rgb (pixel, & red, & green, & blue);   
            if (blue> 200) 
                fall =- 20;   
            end   
        end 
        // Implementation of fall.   
        ii = fall;   
        if(ii > 0)   
            while(ii != 0) 
                pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15); 
                get_rgb (pixel, & red, & green, & blue); 
 
                if (blue>200) 
                    ii = ii + 1; 
                    falling=false; 
                    say("I'm in ground now"); 
                    break; 
                end 
                ii = ii - 1; 
            end   
        else   
            ii = 0; 
        end   
        // Move the fall until we can.   
        y = y + (fall-ii); 
 
        //Ending of jumping and falling status 
        say("FALLING: "+falling+"   Player status: "+player_status); 
        if (player_status==2 and !key(_space)) player_status=3; end 
        if (player_status==3 and !falling) player_status=0; end 
 
 
        // Acceleration of gravity   
        if (ii == 0)   
            fall = fall + 3;   
            falling=true; 
        else   
            fall = 0; 
        end 
 
        //Player Status 
        //say(player_status); 
        switch (player_status) 
        case 0: graph=Player_graph[12]; end 
        case 1: 
            graph=Player_graph
            i=(i+1)%12; 
        end 
        case 2: graph=Player_graph[13]; end 
        case 3: graph=Player_graph[13]; end 
        end
 
        //say("frame"); 
        Frame;
      end
end
 
Process EnemyX (file,x,y) 
private 
int i;
int ii; 
int Xini;
int fall; 
int falling;
int pixel; 
int red,blue,green;
int inactive; 
begin
   //loads the fpg
   enemy_x_fpg=load_fpg(".\sprites\enemies\enemyx.fpg");
   //animations for the enemy
    enemy_x_graph[0]=1;
    enemy_x_graph[1]=1;
    enemy_x_graph[2]=1;
    enemy_x_graph[3]=2;
    enemy_x_graph[4]=2;
    enemy_x_graph[5]=2;
    enemy_x_graph[6]=3;
    enemy_x_graph[7]=3;
    enemy_x_graph[8]=3;
    enemy_x_graph[9]=2;
    enemy_x_graph[10]=2;
    enemy_x_graph[11]=2;
   Xini = x; 
   ctype = c_scroll; 
   loop 
      if(flags == 0) 
            ii = 0; 
            while (ii <3) 
                pixel = map_get_pixel(0, levelmask, x + 16, y); 
                get_rgb (pixel, & red, & green, & blue); 
                if (blue>200) 
                    ii = 0;
                    flags = 1; 
                    break; 
                end 
                ii = ii + 1; 
            end 
            x = x + ii;   
      else
         if(flags == 1) 
            ii = 0; 
            while (ii <3) 
                pixel = map_get_pixel(0, levelmask, x-16, y); 
                get_rgb (pixel, & red, & green, & blue); 
                if (blue>200) 
                    ii = 0;
                    flags = 0; 
                    break; 
                end 
                ii = ii + 1; 
            end 
            x = x-ii; 
        end
        end 
      i = i +1; 
      graph = enemy_x_graph [i%12];
      falling=true;
      if (inactive==0) 
            falling=true;   
        end 
        // Implementation of fall.   
        ii = fall;   
        if(ii > 0)   
            while(ii != 0) 
                pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15); 
                get_rgb (pixel, & red, & green, & blue); 
 
                if (blue>200) 
                    ii = ii + 1; 
                    falling=false; 
                    say("I'm in ground now"); 
                    break; 
                end 
                ii = ii - 1; 
            end   
        else   
            ii = 0; 
        end   
        // Move the fall until we can.   
        y = y + (fall-ii);   
 
        // Acceleration of gravity   
        if (ii == 0)   
            fall = fall + 3;   
            falling=true; 
        else   
            fall = 0; 
        end   
      frame; 
   end
end
 
process pellet(file,x,y)
begin
   //loads the fpg
   pelletfpg=load_fpg(".\sprites\collectibles\pellet.fpg");
   graph=1;
   ctype=c_scroll;
   loop
      if(collision(type player))
         break;
      end
      frame;
   end
end
[/code]
Title: Re: instead of seperate map
Post by: Eckolin on March 23, 2011, 11:38:02 AM
You call  EnemyX(enemy_x_fpg,290,100);  but on the first call, enemy_x_fpg hasn't been initialised yet (since you load_fpg inside the enemy).


   level=load_png(".\sprites\level\image\test-1.png"); 
   levelmask=load_png(".\sprites\level\mask\test-1.png"); 

   playerfpg=load_fpg(".\sprites\player\player.fpg");
   enemy_x_fpg=load_fpg(".\sprites\enemies\enemyx.fpg");
   pelletfpg=load_fpg(".\sprites\collectibles\pellet.fpg");

   Player(playerfpg,50,100);

   EnemyX(enemy_x_fpg,290,100);

pellet(pelletfpg,100,200);
pellet(pelletfpg,116,200);
pellet(pelletfpg,132,200);
pellet(pelletfpg,148,200);


Move the load_fpg()'s to your main process. This also stops them from being loaded multiple times.
Title: Re: instead of seperate map
Post by: MisterN on March 24, 2011, 05:01:31 AM
thanks! i need to work on getting the level part ported to fpg now, i keep getting errors for it