transparency help

Started by MisterN, March 26, 2011, 01:22:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MisterN

so i got everything converted to .fpg for my game and its all working well except im getting some errors. it seems as though the level mask is acting weird. when i put them into fpg edit, they were transparent, and i checked them and they are transparent. except for the rgb colors. when the objects touch any of the rgb colors, they react to it (such as blue, its like a wall). somethings weird because (i put gravity into the objects so i know) all the objects with gravity are floating up (like if they spawned inside an fpg spot) and you cant move left or right. any help?
[code language="fenix"]
Program platform_engine; 
//these are global variables 
Global

   //initiliazes the fpg's used in the game
   //fpg for the player
   playerfpg;
   //fpg's for enemies
   enemy_x_fpg;
   //fpg's for collectibles
   pelletfpg;
   //fpg's for levels
   testlevelfpg;
   testlevelmaskfpg;
 
    //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 levelmask   
    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");

   //loads all the menu's, backgrounds, and cutscenes through this one fpg
   load_fpg(".\sprites\level\image\testlevel.fpg");

    playerfpg=load_fpg(".\sprites\player\player.fpg");
    enemy_x_fpg=load_fpg(".\sprites\enemies\enemyx.fpg");
    pelletfpg=load_fpg(".\sprites\collectibles\pellet.fpg");
   testlevelfpg=load_fpg(".\sprites\level\image\testlevel.fpg");
   testlevelmaskfpg=load_fpg(".\sprites\level\mask\testlevelmask.fpg");

   //Starts the scroller
   scroller();
   
   //starts the levelmask (par on with the scroller, but is the mask for the levels)
   level_mask();
   
   //players fpg, and position
    Player(playerfpg,50,100);
 
   //enemy(s) fpg, and position
    EnemyX(enemy_x_fpg,290,100);
   
   //collectibles fpg, and position
   pellet(pelletfpg,100,200);
   pellet(pelletfpg,116,200);
   pellet(pelletfpg,132,200);
   pellet(pelletfpg,148,200);
 
    Loop 
        If (key(_esc)) 
        Exit("Bye",0); 
        End 
        Frame; 
    End 
End

//This process is for all the levels, menu's, and cutscenes
Process scroller()
Begin
   start_scroll(0,0,1,0,0,0);//starts the scroll, variables:
   /*
   0: number of scroll, 0-9 are possible, this is the first one, so 0 :)
   0: fpg library you use, i only laoded 1 fpg, so it's 0 (the first library) in this case :)
   level: the map in the library chosen
   0: a background for the scroll you can choose (kind of second image scrolling
      with the same parameters, but not necessarily the same way, and in behind the previously
      selected image
   0:is the part of the screen the scroll is shown in, 0 is default region, the entire screen
      you can use this if you want to limit the size of the scrol (not in behind a menu or so)
      for performance issues i guess, thigns on the scroll also won't show outside the region.
      make sure you give your new regiona number other than 0 or it won't work ;)
   0:the flags:
      1:horizontal scroll of the map
      2:vertical scroll of the map
      4:horizontal scroll of the background
      8:vertical scroll of the background
      use: these are powers of two, it's like 4 bits,1=0001;2=0010,4=0100,8=1000
      add the together to get all the scrolls you cant, so 1+2=3 is the map scrolling both ways
      1+2+4=7 is map scrolling both ways, the background only scrolling horizontal
      1+8=9= the map scrolling hotizontal, the background scrolling vertical
      etc...
   */
       //sets the levels background images 
End

Process level_mask();
Begin
   load_fpg(".\sprites\level\mask\testlevelmask.fpg");
   levelmask=1;
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

Drumpi

Are you using 32bits FPG? if not, the graphics get converted. 32 bits it's the only bpp who contains alpha channel. 16 bits uses black color (0,0,0) as transparent and 8 bits uses color 0, so FPG edit convert your file into one of this types. I don't know if it reads alpha channel to make pixels transparents or RGB information, so be sure you convert it with another tool before.

This is why all people recomends using 8bits maps tou hardness maps: it's easier to program, needs less functions and don't have any errors of this kind.
Unfortunally, there isn't too much tools to work with 8bits images, and the best choice is DIV graphic editor itself, but it doesn't works on 7.
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

#2
I have dosbox if that helps. Im trying fpgedit 2009 right now and im making an 8bit palette so see if itll work. nope, it doesnt, and remember, fenix 0.84b for dreamcast, doesnt support 32 bit, ill switch to bennu once its ported over (i dont need any custom .dll's, i just need it to self boot, and use the controller, and save to the vmu, so if its easy to port that way like i heard the wii was, then someone show me how :)).

hmmm....i saw a tutorial that for hardness maps you have to make specific values to the rgb but that made no sense at all
http://www.gp32x.com/board/index.php?/topic/19088-hardness-maps/
werg

handsource-dyko

Well, you can use Grafx2. Although it doesn't support map or fpg files, it does support png's and bmp's.
Grafx2 is specially designed for 8 bit color palette images. Be aware that all the graphics in 8 bit 256
color mode need to share the same colorpalette. In 8 bit mode, each color number represents a rgb color.

I do recommend DIV as well, if you google for it you may find a copy. It works very  well with dosbox.

MisterN

#4
hmm nothing seems to be working. i just want to be able to save this and call it there. why is it that its doing this even though its set only to meet with the rgb colors? ...
any help? look at my game so far, youll see what i mean by it floating up
werg

Eckolin

I had a quick look at your code. I think you mean blue < 200 to be solid, rather than blue > 200.

Secondly, you still load fpgs inside the processes as well as in the main process. This seems redundant.

MisterN

ok its working, its still buggy though. you can fall off the level when you go right and they way the enemy spawned it automatically walks off and everythings about 2 pixels into the ground.

i still loaded it because you never know, doesnt hurt anything.
werg

MisterN

#7
ok got some of it to work now, still a little iffy though, ill reupload it so you can look at it.
*enemy sorta "swirls around" while walking
*sometimes you might go through walls
*if theres no blue then you can fall through the level (unlike when it was a .png, once you got to the end, that was it, it acted like blue even though nothing was there.
werg