saboteur Posted March 22, 2017 Author Share Posted March 22, 2017 Ran into an issue last night regarding player movement and animation. The player can move left and right no problem but I utilise a 16*16 bmp with 8 frames ( 4 for left and for 4 right ) and using a global frame counter I can cycle through the frames as required.... but it's way to fast. Anyway to slow this down ? SUB Player_Update_Position LOCAL LVAR_x%, LVAR_pad% LVAR_x=rgetobj(ID_player,R_sprite_x) ' get player's current X position LVAR_pad=getpad(1) ' get PAD1 status (from U235) rlocate 100,80 print "PLAYER DIRECTION ", player_direction, rlocate 100,100 print "FRAME ", GVAR_player_frame IF LVAR_pad=PAD_LEFT THEN ' was LEFT pressed? IF player_direction = 1 THEN IF GVAR_player_frame < 7 THEN GVAR_player_frame = GVAR_player_frame + 1 ELSEIF GVAR_player_frame = 7 THEN GVAR_player_frame = 4 ENDIF ELSEIF player_direction = 2 THEN GVAR_player_frame = 0 ENDIF player_direction = 1 IF LVAR_x<>(37<<16) THEN ' already at far-left position? LVAR_x=LVAR_x-(1<<16) ' subtract 1 from X-position endif ELSEIF LVAR_pad=PAD_RIGHT THEN ' was RIGHT pressed? IF player_direction = 2 THEN IF GVAR_player_frame < 3 THEN GVAR_player_frame = GVAR_player_frame + 1 ELSEIF GVAR_player_frame = 3 THEN GVAR_player_frame = 0 ENDIF ELSEIF player_direction = 1 THEN GVAR_player_frame = 4 ENDIF player_direction = 2 IF LVAR_x<>(300<<16) THEN ' already at far-right position? LVAR_x=LVAR_x+(1<<16) ' add 1 to X-position ENDIF ELSEIF LVAR_pad=PAD_A THEN ' was JUMP pressed? rlocate 100,120 print "JUMP PRESSED" GVAR_player_is_jump = 1 GVAR_player_x = rgetobj(ID_player, R_sprite_x) GVAR_player_y = rgetobj(ID_player, R_sprite_y) ENDIF 'rsetobj(ID_player,R_sprite_x,LVAR_x) ' store the new x-position RSETOBJ(ID_player, R_sprite_x, LVAR_x) RSETOBJ(ID_player, R_sprite_gfxbase, GVAR_player_gfx_loc + (GVAR_player_gfx_size*GVAR_player_frame)) END SUB ' exit Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.