Trying to change how my player moves

Started by MisterN, January 25, 2012, 01:12:05 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MisterN

//Player Movement 
        if (key (_left) or _JKEY_AXIS_X<0)
            flags = 1;
            dir = -1;           
            //ii = 0;
            //while (ii <4) 
                pixel = map_get_pixel(0, levelmask, levelmap.playerx-12, levelmap.playery);   
                get_rgb (pixel, & red, & green, & blue); 
                if (blue>220 or x==topx) 
                    //ii = 0;
                    //break; 
                    x+=walk_speed;
                else 
                    if (player_status!=2 and player_status!=3 and player_status!=6 and player_status!=7) player_status=1; end
                    walking=true;
                end               
                //ii = ii + 1; 
            //end
            x-=walk_speed;
        end 
        if (key (_right) or _JKEY_AXIS_X>0)
            flags = 0;
            dir = 1;
            //ii = 0;
            //while (ii <4)
                pixel = map_get_pixel(0, levelmask, levelmap.playerx+12, levelmap.playery); 
                get_rgb (pixel, & red, & green, & blue); 
                if (blue>220 or x==botx) 
                    //ii = 0;
                    //break; 
                    x-=walk_speed;
                else 
                    if (player_status!=2 and player_status!=3 and player_status!=6 and player_status!=7) player_status=1; end
                    walking=true;
                end   
                //ii = ii + 1;
            //end 
            x+=walk_speed;
        end


// Jumping 
        if (key (__A) or (joy_getbutton(0,_jkey_a)))
            if(!key_jump_is_already_pressed)
                if(gun_ready)
                    player_status=6;
                    levelmap.player_obj.player_emotion = 2;
                else
                    player_status=2;
                    levelmap.player_obj.player_emotion = 2;
                end
            falling=true;
            pixel = map_get_pixel(0, levelmask, x, y +16);   
            get_rgb (pixel, & red, & green, & blue);   
            if (blue>220)
                play_wav(jump_sound,0);
                fall =- 18;   
            end
            pixel = map_get_pixel(0, levelmask, x+6, y +16);   
            get_rgb (pixel, & red, & green, & blue);   
            if (blue>220)
                play_wav(jump_sound,0);
                fall =- 18;   
            end
            pixel = map_get_pixel(0, levelmask, x-6, y +16);   
            get_rgb (pixel, & red, & green, & blue);   
            if (blue>220)
                play_wav(jump_sound,0);
                fall =- 18;   
            end
           
        end
            key_jump_is_already_pressed = true;//as long as x is held down, this is true
          else
            key_jump_is_already_pressed = false;//once space is released, this is false
        end
       
        // Implementation of fall.   
        ii = fall;   
        if(ii > 0)
            while(ii != 0)
                pixel=map_get_pixel(0, levelmask, x+6, y + (fall-ii) +15); //falling onto the left side of the mask
                get_rgb (pixel, & red, & green, & blue); 
                if (blue>0) 
                    ii = ii + 1;
                    falling=false;
                        if(!walking);
                            player_status=0;
                        else
                            player_status=1;
                        end
                    break; 
                end
                pixel=map_get_pixel(0, levelmask, x-6, y + (fall-ii) +15); //falling onto the right side of the mask
                get_rgb (pixel, & red, & green, & blue); 
                if (blue>0) 
                    ii = ii + 1;
                    falling=false;
                        if(!walking);
                            player_status=0;
                        else
                            player_status=1;
                        end
                    break; 
                end
                pixel=map_get_pixel(0, levelmask, x, y + (fall-ii) +15); //falling onto the right side of the mask
                get_rgb (pixel, & red, & green, & blue); 
                if (blue>0) 
                    ii = ii + 1;
                    falling=false;
                        if(!walking);
                            player_status=0;
                        else
                            player_status=1;
                        end
                    break; 
                end
                ii = ii - 1; 
            end   
        else   
            ii = 0; 
        end
       
        //Hitting the ceiling
        if(!on_ground)
            pixel = map_get_pixel(0, levelmask, x+6, y-1); //for the far left side
            get_rgb (pixel, & red, & green, & blue);   
                if (blue>0) if (hit_ceiling==false) hit_ceiling = true; else end end
            pixel = map_get_pixel(0, levelmask, x-6, y-1); //for the far right side 
            get_rgb (pixel, & red, & green, & blue);   
                if (blue>0) if (hit_ceiling==false) hit_ceiling = true; else end end
            pixel = map_get_pixel(0, levelmask, x, y-1);
            get_rgb (pixel, & red, & green, & blue);   
                if (blue>0) if (hit_ceiling==false) hit_ceiling = true; else end end
        end
        pixel = map_get_pixel(0, levelmask, x+6, y-16); //for the far left side
        get_rgb (pixel, & red, & green, & blue);   
            if (blue>0) if (hit_ceiling==false) hit_ceiling = true; else end end
        pixel = map_get_pixel(0, levelmask, x-6, y-16); //for the far right side 
        get_rgb (pixel, & red, & green, & blue);   
            if (blue>0) if (hit_ceiling==false) hit_ceiling = true; else end end
        pixel = map_get_pixel(0, levelmask, x, y-16);
        get_rgb (pixel, & red, & green, & blue);   
            if (blue>0) if (hit_ceiling==false) hit_ceiling = true; else end end
       
        if(hit_ceiling==true)
            fall = 3;
            hit_ceiling=false;
        end
   
        // Move the fall until we can.   
        y = y + (fall-ii);
 
        // Acceleration of gravity   
        if (ii == 0)   
            on_ground = false;
            fall = fall + 3; 
            levelmap.player_obj.player_emotion = 3;
            falling=true;
        else
            fall = 0;
            on_ground = true;
        end


What am I trying to do? Well for starters ive always been unhappy with the collision system. You can sink into platforms and stuff and I discovered that instead of doing ii, the regular x/y stuff works. Problem is I cant figure out how to rewrite the jumping/falling portion to use y instead. I have these set up in private:
    walk_speed = 3.8;
    jump_speed = 3.8;
        jump_apex = 19;

apex is the climax of the jump by the way. Anytime I manage to get a system with y's, the player disappears (cause i usually have it set so when you land on a platform, y+=0;). I was wondering how I change the y system of my player. thanks

werg

FreeYourMind


MisterN

#2
what?
werg

FreeYourMind


MisterN

werg

FreeYourMind

Sorry, I'm kiding, but i'm curious about your c# program :)

MisterN

give me your email and i will send it, its just a shell though, it really doesnt do much.

could you help with the y?
werg

FreeYourMind


MisterN

werg

FreeYourMind

sorry, i'm busy today, tomorrow, i promess, by the way, you don't send me the c# program...

MisterN

i havent gotten home till now ill zip it up and send it off
werg

FreeYourMind

taking a fast look at your code:

put this only one time inside the loop ... frame; end

pixel = map_get_pixel(0, levelmask, levelmap.playerx+12, levelmap.playery);

after this, put player 'if' conditions, don't use the while sentence because you only need to get the pixel one time per frame inside the main loop.
This value is valid for all stuffs of conditions you put after that in the same process...

At the night I will try your demo to help you

MisterN

#12
could you email me an example later?

EDIT:

doing what you said to do does not work
werg