Autor Tema: instead of seperate map  (Leído 4813 veces)

Drumpi

  • Hero Member
  • *****
  • Mensajes: 6466
  • Karma: 168
  • Odio el periodo "entre proyectos"
    • La web de Drumpi
Re: instead of seperate map
« Respuesta #15 en: Marzo 22, 2011, 08:43:45 pm »
Código: [Seleccionar]
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].
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

  • Hero Member
  • *****
  • Mensajes: 650
  • Karma: 4
Re: instead of seperate map
« Respuesta #16 en: Marzo 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
werg

MisterN

  • Hero Member
  • *****
  • Mensajes: 650
  • Karma: 4
Re: instead of seperate map
« Respuesta #17 en: Marzo 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]
werg

Eckolin

  • Newbie
  • *
  • Mensajes: 12
  • Karma: 5
Re: instead of seperate map
« Respuesta #18 en: Marzo 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).

Código: [Seleccionar]
   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.

MisterN

  • Hero Member
  • *****
  • Mensajes: 650
  • Karma: 4
Re: instead of seperate map
« Respuesta #19 en: Marzo 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
werg