Message Board


Message Board > Fenix / Bennu / Gemix / DIV > So far with my platform game

March 10, 2011, 01:35
DoctorN
Whiskered
91 posts
Ive got a perfectly walking megaman and the level. Im still stuck with the jump animation (it still shows for a split second then goes back to standing/walking) and my character cant run into the red walls i planted in the level, i had them coded in at some point, but the game crashed and i took out so much code the program itself crashed so i lost it inbetween the craks. could you fix those two meesly things?
Quote:
Program platform_engine;
//these are global variables
Global
    Playerfpg;
   
    //initializes the player's sprites
    int Player_graph[14];
   
    //initializes the level
    int level;
    int levelmask;

//this sets up things like the games resolution and whatnot   
Begin
    Set_mode(256,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; 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_grap[X] you have
    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");

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

    Player(PlayerFPG,1,50,100);
   
    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,graph,x,y)
Private
    xspeed=3;
    yspeed=0;

    y_start_acceleration=4;
    y_acceleration=0;
   
    int fall;

    jump=0;
   
    int i;
    int ii;
    int pixel;
    int red,blue,green;

Begin
    ctype=c_scroll;
    Loop
        // Walking
        If (key(_left) or key(_right))
            If (graph==Player_graph[12])
                graph=Player_graph[i];
                //Animation for movement [0] thru [11] - 12 frames of animation
                i=(i+1)%12;
            End
            If (key(_left))
            flags=1;
            x-=xspeed;
            graph=Player_graph[i];;
            //Animation for movement [0] thru [11] - 12 frames of animation
            i=(i+1)%12;
            End
            if (key(_right))
            flags=0;
            x+=xspeed;
            graph=Player_graph[i];;
            //Animation for movement [0] thru [11] - 12 frames of animation
            i=(i+1)%12;
            End
        Else
        // Standing still
            graph=Player_Graph[12];
        End
        // Jumping
        if (key (_space))
            pixel = map_get_pixel(0, levelmask, x, y +1 +15);
            get_rgb (pixel, & red, & green, & blue);
            if (blue> 200)
                graph=Player_graph[13];
                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;
                    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 + 5;
        else
            fall = 0;
        end   
        Frame;
    End
End


[Edited on March 10, 2011 by DoctorN]
____________
#

Message Board > Fenix / Bennu / Gemix / DIV > So far with my platform game

Quick reply


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