Framerate issues with Arcade











up vote
0
down vote

favorite












So I'm making a platformer 2D game with Arcade, and for some reason, my game always goes ~30 FPS instead of going 60 FPS.



Not only that, when I press the left arrow key to move my character to the left, it goes down to ~4 FPS.



Code for my movement system (I had to make a camera)



def update(self, x):
# update player
if self.player != None:
self.player.real_x += self.player.movement
self.player.center_y -= gravityConstant


I use 'real_x' variable instead of using 'center_x' because of the camera.
Ignore the fact that the gravity doens't acelerate and always make the character fall at a constant speed (will fix that).



The player will always be in the center of the screen:



    self.player.center_x = self.x / 2;


At first I thought it was that the movement of the Sprite caused lag, but when I added gravity, I noticed that the problem is only with the X axis movement. When the character falls due to gravity, it runs at 30 FPS, but when it is moving in any direction that isn't Y (X, -X) it will slow down the game to ~4 FPS.



My computer is pretty bad though, but I don't think it's the responsable for this framerate issues.



Specs:
Processor: 1.58 GHz
RAM: 3.99 / 4.00 GB



EDIT:
This happens with both left and right movements. The movement is handled through a arcade.Window class.



Code of the functions:



def onKeyDown(self, symbol):
if symbol == arcade.key.LEFT:
self.movement = -self.walk_speed;
elif symbol == arcade.key.RIGHT:
self.movement = self.walk_speed;
elif symbol == arcade.key.UP:
self.jumping = True;

def onKeyUp(self, symbol):
if symbol == arcade.key.LEFT:
self.movement = 0;
elif symbol == arcade.key.RIGHT:
self.movement = 0;
elif symbol == arcade.key.UP:
self.jumping = False;


Code of the on_key_press and on_key_release:



def on_key_press(self, symbol, modifier):
if self.player != None:
self.player.onKeyDown(symbol);

def on_key_release(self, symbol, modifier):
if self.player != None:
self.player.onKeyUp(symbol);


Note: This works with Classes, so these functions are inside a Player Class.










share|improve this question




























    up vote
    0
    down vote

    favorite












    So I'm making a platformer 2D game with Arcade, and for some reason, my game always goes ~30 FPS instead of going 60 FPS.



    Not only that, when I press the left arrow key to move my character to the left, it goes down to ~4 FPS.



    Code for my movement system (I had to make a camera)



    def update(self, x):
    # update player
    if self.player != None:
    self.player.real_x += self.player.movement
    self.player.center_y -= gravityConstant


    I use 'real_x' variable instead of using 'center_x' because of the camera.
    Ignore the fact that the gravity doens't acelerate and always make the character fall at a constant speed (will fix that).



    The player will always be in the center of the screen:



        self.player.center_x = self.x / 2;


    At first I thought it was that the movement of the Sprite caused lag, but when I added gravity, I noticed that the problem is only with the X axis movement. When the character falls due to gravity, it runs at 30 FPS, but when it is moving in any direction that isn't Y (X, -X) it will slow down the game to ~4 FPS.



    My computer is pretty bad though, but I don't think it's the responsable for this framerate issues.



    Specs:
    Processor: 1.58 GHz
    RAM: 3.99 / 4.00 GB



    EDIT:
    This happens with both left and right movements. The movement is handled through a arcade.Window class.



    Code of the functions:



    def onKeyDown(self, symbol):
    if symbol == arcade.key.LEFT:
    self.movement = -self.walk_speed;
    elif symbol == arcade.key.RIGHT:
    self.movement = self.walk_speed;
    elif symbol == arcade.key.UP:
    self.jumping = True;

    def onKeyUp(self, symbol):
    if symbol == arcade.key.LEFT:
    self.movement = 0;
    elif symbol == arcade.key.RIGHT:
    self.movement = 0;
    elif symbol == arcade.key.UP:
    self.jumping = False;


    Code of the on_key_press and on_key_release:



    def on_key_press(self, symbol, modifier):
    if self.player != None:
    self.player.onKeyDown(symbol);

    def on_key_release(self, symbol, modifier):
    if self.player != None:
    self.player.onKeyUp(symbol);


    Note: This works with Classes, so these functions are inside a Player Class.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      So I'm making a platformer 2D game with Arcade, and for some reason, my game always goes ~30 FPS instead of going 60 FPS.



      Not only that, when I press the left arrow key to move my character to the left, it goes down to ~4 FPS.



      Code for my movement system (I had to make a camera)



      def update(self, x):
      # update player
      if self.player != None:
      self.player.real_x += self.player.movement
      self.player.center_y -= gravityConstant


      I use 'real_x' variable instead of using 'center_x' because of the camera.
      Ignore the fact that the gravity doens't acelerate and always make the character fall at a constant speed (will fix that).



      The player will always be in the center of the screen:



          self.player.center_x = self.x / 2;


      At first I thought it was that the movement of the Sprite caused lag, but when I added gravity, I noticed that the problem is only with the X axis movement. When the character falls due to gravity, it runs at 30 FPS, but when it is moving in any direction that isn't Y (X, -X) it will slow down the game to ~4 FPS.



      My computer is pretty bad though, but I don't think it's the responsable for this framerate issues.



      Specs:
      Processor: 1.58 GHz
      RAM: 3.99 / 4.00 GB



      EDIT:
      This happens with both left and right movements. The movement is handled through a arcade.Window class.



      Code of the functions:



      def onKeyDown(self, symbol):
      if symbol == arcade.key.LEFT:
      self.movement = -self.walk_speed;
      elif symbol == arcade.key.RIGHT:
      self.movement = self.walk_speed;
      elif symbol == arcade.key.UP:
      self.jumping = True;

      def onKeyUp(self, symbol):
      if symbol == arcade.key.LEFT:
      self.movement = 0;
      elif symbol == arcade.key.RIGHT:
      self.movement = 0;
      elif symbol == arcade.key.UP:
      self.jumping = False;


      Code of the on_key_press and on_key_release:



      def on_key_press(self, symbol, modifier):
      if self.player != None:
      self.player.onKeyDown(symbol);

      def on_key_release(self, symbol, modifier):
      if self.player != None:
      self.player.onKeyUp(symbol);


      Note: This works with Classes, so these functions are inside a Player Class.










      share|improve this question















      So I'm making a platformer 2D game with Arcade, and for some reason, my game always goes ~30 FPS instead of going 60 FPS.



      Not only that, when I press the left arrow key to move my character to the left, it goes down to ~4 FPS.



      Code for my movement system (I had to make a camera)



      def update(self, x):
      # update player
      if self.player != None:
      self.player.real_x += self.player.movement
      self.player.center_y -= gravityConstant


      I use 'real_x' variable instead of using 'center_x' because of the camera.
      Ignore the fact that the gravity doens't acelerate and always make the character fall at a constant speed (will fix that).



      The player will always be in the center of the screen:



          self.player.center_x = self.x / 2;


      At first I thought it was that the movement of the Sprite caused lag, but when I added gravity, I noticed that the problem is only with the X axis movement. When the character falls due to gravity, it runs at 30 FPS, but when it is moving in any direction that isn't Y (X, -X) it will slow down the game to ~4 FPS.



      My computer is pretty bad though, but I don't think it's the responsable for this framerate issues.



      Specs:
      Processor: 1.58 GHz
      RAM: 3.99 / 4.00 GB



      EDIT:
      This happens with both left and right movements. The movement is handled through a arcade.Window class.



      Code of the functions:



      def onKeyDown(self, symbol):
      if symbol == arcade.key.LEFT:
      self.movement = -self.walk_speed;
      elif symbol == arcade.key.RIGHT:
      self.movement = self.walk_speed;
      elif symbol == arcade.key.UP:
      self.jumping = True;

      def onKeyUp(self, symbol):
      if symbol == arcade.key.LEFT:
      self.movement = 0;
      elif symbol == arcade.key.RIGHT:
      self.movement = 0;
      elif symbol == arcade.key.UP:
      self.jumping = False;


      Code of the on_key_press and on_key_release:



      def on_key_press(self, symbol, modifier):
      if self.player != None:
      self.player.onKeyDown(symbol);

      def on_key_release(self, symbol, modifier):
      if self.player != None:
      self.player.onKeyUp(symbol);


      Note: This works with Classes, so these functions are inside a Player Class.







      python python-3.x






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 3:04

























      asked Nov 11 at 2:11









      VetraDebesis

      698




      698
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Do you mind putting the part of the code responsible for the movements?



          also, check where you put things on screen, you want to make a variable, set it to the image, and call that var. as for it only happening when moving left , make sure the left script is the same as right but - instead of +.






          share|improve this answer





















          • It doens't only happen to the left movement, it also happens to the right movement. Code of the movement: def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False; And this is handled by the Game class, with on_key_press, and on_key_release.
            – VetraDebesis
            Nov 11 at 2:52












          • for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
            – idk
            Nov 18 at 1:14












          • also, when you move the char, dont wait to upddate the character to move it. just move it then.
            – idk
            Nov 18 at 1:17











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245257%2fframerate-issues-with-arcade%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Do you mind putting the part of the code responsible for the movements?



          also, check where you put things on screen, you want to make a variable, set it to the image, and call that var. as for it only happening when moving left , make sure the left script is the same as right but - instead of +.






          share|improve this answer





















          • It doens't only happen to the left movement, it also happens to the right movement. Code of the movement: def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False; And this is handled by the Game class, with on_key_press, and on_key_release.
            – VetraDebesis
            Nov 11 at 2:52












          • for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
            – idk
            Nov 18 at 1:14












          • also, when you move the char, dont wait to upddate the character to move it. just move it then.
            – idk
            Nov 18 at 1:17















          up vote
          0
          down vote













          Do you mind putting the part of the code responsible for the movements?



          also, check where you put things on screen, you want to make a variable, set it to the image, and call that var. as for it only happening when moving left , make sure the left script is the same as right but - instead of +.






          share|improve this answer





















          • It doens't only happen to the left movement, it also happens to the right movement. Code of the movement: def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False; And this is handled by the Game class, with on_key_press, and on_key_release.
            – VetraDebesis
            Nov 11 at 2:52












          • for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
            – idk
            Nov 18 at 1:14












          • also, when you move the char, dont wait to upddate the character to move it. just move it then.
            – idk
            Nov 18 at 1:17













          up vote
          0
          down vote










          up vote
          0
          down vote









          Do you mind putting the part of the code responsible for the movements?



          also, check where you put things on screen, you want to make a variable, set it to the image, and call that var. as for it only happening when moving left , make sure the left script is the same as right but - instead of +.






          share|improve this answer












          Do you mind putting the part of the code responsible for the movements?



          also, check where you put things on screen, you want to make a variable, set it to the image, and call that var. as for it only happening when moving left , make sure the left script is the same as right but - instead of +.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 2:37









          idk

          154




          154












          • It doens't only happen to the left movement, it also happens to the right movement. Code of the movement: def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False; And this is handled by the Game class, with on_key_press, and on_key_release.
            – VetraDebesis
            Nov 11 at 2:52












          • for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
            – idk
            Nov 18 at 1:14












          • also, when you move the char, dont wait to upddate the character to move it. just move it then.
            – idk
            Nov 18 at 1:17


















          • It doens't only happen to the left movement, it also happens to the right movement. Code of the movement: def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False; And this is handled by the Game class, with on_key_press, and on_key_release.
            – VetraDebesis
            Nov 11 at 2:52












          • for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
            – idk
            Nov 18 at 1:14












          • also, when you move the char, dont wait to upddate the character to move it. just move it then.
            – idk
            Nov 18 at 1:17
















          It doens't only happen to the left movement, it also happens to the right movement. Code of the movement: def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False; And this is handled by the Game class, with on_key_press, and on_key_release.
          – VetraDebesis
          Nov 11 at 2:52






          It doens't only happen to the left movement, it also happens to the right movement. Code of the movement: def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False; And this is handled by the Game class, with on_key_press, and on_key_release.
          – VetraDebesis
          Nov 11 at 2:52














          for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
          – idk
          Nov 18 at 1:14






          for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
          – idk
          Nov 18 at 1:14














          also, when you move the char, dont wait to upddate the character to move it. just move it then.
          – idk
          Nov 18 at 1:17




          also, when you move the char, dont wait to upddate the character to move it. just move it then.
          – idk
          Nov 18 at 1:17


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245257%2fframerate-issues-with-arcade%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Bressuire

          Vorschmack

          Quarantine