Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void object::Update(background A_Field){
- if (newframe){delayU=Frames[currframe].delay;newframe=false;}
- if (delayU==0){previousframe=currframe;currframe=Frames[currframe].nxt;newframe=true;}else{ //update frame and loop on the delay
- delayU--;}
- if (previousframe!=4321 && Frames[currframe].loop_condition==previousframe && !doloop && Frames[currframe].loop_length!=0&&newframe){ //loop tag
- U_loop_length= Frames[currframe].loop_length;
- doloop=true;
- }
- if (Frames[currframe].loop_condition==previousframe && doloop&&newframe){
- if (U_loop_length == 0){
- previousframe=currframe;currframe=Frames[currframe].loop_goto;
- doloop=false;newframe=true;
- }else{
- U_loop_length--;}
- }
- if(Frames[currframe].state==0&&total_fx!=0){ //apply friction
- if (total_fx>0){
- total_fx-=FRICTION;
- if (total_fx<0) total_fx=0;
- }else if (total_fx<0){
- total_fx+=FRICTION;
- if (total_fx>0) total_fx=0;
- }
- }
- if (Frames[currframe].f_x!=0){ //f_x tag
- if (Frames[currframe].f_x!=4321){
- total_fx=Frames[currframe].f_x;
- }else{total_fx=0;}
- }
- if (facing==0) {
- Move(total_fx, 'x',A_Field);
- }else{Move(-total_fx, 'x',A_Field);
- }
- total_fx+=Frames[currframe].acc; //acc tag
- if (P_UP==true){Move(-Frames[currframe].zhlddstnc, 'z', A_Field);} //z_hold_distance tag
- if (P_DOWN==true){Move(Frames[currframe].zhlddstnc, 'z', A_Field);}
- if (P_RIGHT==true){Move(Frames[currframe].xhlddstnc, 'x', A_Field);} //x_hold_distance tag
- if (P_LEFT==true){Move(-Frames[currframe].xhlddstnc, 'x', A_Field);}
- //This is the part which deals with running (called dashing here):
- if ((P_UP==true||P_DOWN==true||P_LEFT==true||P_RIGHT==true)&&Frames[currframe].state==0){
- if (DASHR==1&&P_RIGHT==true&&facing==0){
- previousframe=currframe;currframe=dashing;newframe=true;DASHR=0;DASHL=0;DshClksIntrvlL,DshClksIntrvlR=0;
- }else if(DASHL==1&&P_LEFT==true&&facing==1){
- previousframe=currframe;currframe=dashing;newframe=true;DASHL=0;DASHR=0;DshClksIntrvlL,DshClksIntrvlR=0;
- }else{
- previousframe=currframe;currframe=walking;newframe=true;}}
- if(Frames[currframe].state==1 && !(P_UP==true||P_DOWN==true||P_LEFT==true||P_RIGHT==true)){
- currframe=standing;newframe=true;previousframe=currframe;
- }
- if (Frames[currframe].state==1){
- if (P_UP==true){movedirz = 0;}
- else if (P_DOWN==true){movedirz =1;}else movedirz = 2;
- if (P_LEFT==true){movedirx = 1;}
- else if (P_RIGHT==true){movedirx= 0;}else movedirx = 2;
- Walk(movedirx, movedirz, A_Field);}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement